Fixed planex theme change and removed unused planex controls

This commit is contained in:
Arnaud Vergnet 2020-05-01 21:41:08 +02:00
parent d8f7dc72d4
commit 0c9b70998d
2 changed files with 28 additions and 8 deletions

View file

@ -18,6 +18,7 @@ type Props = {
collapsibleStack: Object, collapsibleStack: Object,
onMessage: Function, onMessage: Function,
onScroll: Function, onScroll: Function,
showAdvancedControls: boolean,
} }
const AnimatedWebView = Animated.createAnimatedComponent(WebView); const AnimatedWebView = Animated.createAnimatedComponent(WebView);
@ -29,6 +30,7 @@ class WebViewScreen extends React.PureComponent<Props> {
static defaultProps = { static defaultProps = {
customJS: '', customJS: '',
showAdvancedControls: true,
}; };
webviewRef: Object; webviewRef: Object;
@ -45,9 +47,10 @@ class WebViewScreen extends React.PureComponent<Props> {
* Creates refresh button after mounting * Creates refresh button after mounting
*/ */
componentDidMount() { componentDidMount() {
const rightButton = this.getRefreshButton.bind(this);
this.props.navigation.setOptions({ this.props.navigation.setOptions({
headerRight: rightButton, headerRight: this.props.showAdvancedControls
? this.getAdvancedButtons
: this.getBasicButton,
}); });
this.props.navigation.addListener( this.props.navigation.addListener(
'focus', 'focus',
@ -80,7 +83,22 @@ class WebViewScreen extends React.PureComponent<Props> {
* *
* @return {*} * @return {*}
*/ */
getRefreshButton() { getBasicButton = () => {
return (
<MaterialHeaderButtons>
<Item
title="refresh"
iconName="refresh"
onPress={this.onRefreshClicked}/>
<Item
title={i18n.t("general.openInBrowser")}
iconName="open-in-new"
onPress={this.onOpenClicked}/>
</MaterialHeaderButtons>
);
};
getAdvancedButtons = () => {
return ( return (
<MaterialHeaderButtons> <MaterialHeaderButtons>
<Item <Item
@ -101,7 +119,7 @@ class WebViewScreen extends React.PureComponent<Props> {
onPress={this.onOpenClicked}/> onPress={this.onOpenClicked}/>
</MaterialHeaderButtons> </MaterialHeaderButtons>
); );
}; }
/** /**
* Callback to use when refresh button is clicked. Reloads the webview. * Callback to use when refresh button is clicked. Reloads the webview.

View file

@ -207,10 +207,11 @@ class PlanexScreen extends React.Component<Props, State> {
+ 'true;'; // Prevents crash on ios + 'true;'; // Prevents crash on ios
} }
// componentWillUpdate(prevProps: Props) { shouldComponentUpdate(nextProps: Props): boolean {
// if (prevProps.theme.dark !== this.props.theme.dark) if (nextProps.theme.dark !== this.props.theme.dark)
// this.generateInjectedCSS(); this.generateInjectedJS(this.state.currentGroup.id);
// } return true;
}
/** /**
* Callback used when closing the banner. * Callback used when closing the banner.
@ -291,6 +292,7 @@ class PlanexScreen extends React.Component<Props, State> {
customJS={this.customInjectedJS} customJS={this.customInjectedJS}
onMessage={this.onMessage} onMessage={this.onMessage}
onScroll={this.onScroll} onScroll={this.onScroll}
showAdvancedControls={false}
/> />
</View> </View>
); );