forked from vergnet/application-amicale
Fixed planex theme change and removed unused planex controls
This commit is contained in:
parent
d8f7dc72d4
commit
0c9b70998d
2 changed files with 28 additions and 8 deletions
|
@ -18,6 +18,7 @@ type Props = {
|
|||
collapsibleStack: Object,
|
||||
onMessage: Function,
|
||||
onScroll: Function,
|
||||
showAdvancedControls: boolean,
|
||||
}
|
||||
|
||||
const AnimatedWebView = Animated.createAnimatedComponent(WebView);
|
||||
|
@ -29,6 +30,7 @@ class WebViewScreen extends React.PureComponent<Props> {
|
|||
|
||||
static defaultProps = {
|
||||
customJS: '',
|
||||
showAdvancedControls: true,
|
||||
};
|
||||
|
||||
webviewRef: Object;
|
||||
|
@ -45,9 +47,10 @@ class WebViewScreen extends React.PureComponent<Props> {
|
|||
* Creates refresh button after mounting
|
||||
*/
|
||||
componentDidMount() {
|
||||
const rightButton = this.getRefreshButton.bind(this);
|
||||
this.props.navigation.setOptions({
|
||||
headerRight: rightButton,
|
||||
headerRight: this.props.showAdvancedControls
|
||||
? this.getAdvancedButtons
|
||||
: this.getBasicButton,
|
||||
});
|
||||
this.props.navigation.addListener(
|
||||
'focus',
|
||||
|
@ -80,7 +83,22 @@ class WebViewScreen extends React.PureComponent<Props> {
|
|||
*
|
||||
* @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 (
|
||||
<MaterialHeaderButtons>
|
||||
<Item
|
||||
|
@ -101,7 +119,7 @@ class WebViewScreen extends React.PureComponent<Props> {
|
|||
onPress={this.onOpenClicked}/>
|
||||
</MaterialHeaderButtons>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to use when refresh button is clicked. Reloads the webview.
|
||||
|
|
|
@ -207,10 +207,11 @@ class PlanexScreen extends React.Component<Props, State> {
|
|||
+ 'true;'; // Prevents crash on ios
|
||||
}
|
||||
|
||||
// componentWillUpdate(prevProps: Props) {
|
||||
// if (prevProps.theme.dark !== this.props.theme.dark)
|
||||
// this.generateInjectedCSS();
|
||||
// }
|
||||
shouldComponentUpdate(nextProps: Props): boolean {
|
||||
if (nextProps.theme.dark !== this.props.theme.dark)
|
||||
this.generateInjectedJS(this.state.currentGroup.id);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback used when closing the banner.
|
||||
|
@ -291,6 +292,7 @@ class PlanexScreen extends React.Component<Props, State> {
|
|||
customJS={this.customInjectedJS}
|
||||
onMessage={this.onMessage}
|
||||
onScroll={this.onScroll}
|
||||
showAdvancedControls={false}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue