Browse Source

Fixed planex theme change and removed unused planex controls

Arnaud Vergnet 4 years ago
parent
commit
0c9b70998d
2 changed files with 28 additions and 8 deletions
  1. 22
    4
      src/components/Screens/WebViewScreen.js
  2. 6
    4
      src/screens/Planex/PlanexScreen.js

+ 22
- 4
src/components/Screens/WebViewScreen.js View File

@@ -18,6 +18,7 @@ type Props = {
18 18
     collapsibleStack: Object,
19 19
     onMessage: Function,
20 20
     onScroll: Function,
21
+    showAdvancedControls: boolean,
21 22
 }
22 23
 
23 24
 const AnimatedWebView = Animated.createAnimatedComponent(WebView);
@@ -29,6 +30,7 @@ class WebViewScreen extends React.PureComponent<Props> {
29 30
 
30 31
     static defaultProps = {
31 32
         customJS: '',
33
+        showAdvancedControls: true,
32 34
     };
33 35
 
34 36
     webviewRef: Object;
@@ -45,9 +47,10 @@ class WebViewScreen extends React.PureComponent<Props> {
45 47
      * Creates refresh button after mounting
46 48
      */
47 49
     componentDidMount() {
48
-        const rightButton = this.getRefreshButton.bind(this);
49 50
         this.props.navigation.setOptions({
50
-            headerRight: rightButton,
51
+            headerRight: this.props.showAdvancedControls
52
+                ? this.getAdvancedButtons
53
+                : this.getBasicButton,
51 54
         });
52 55
         this.props.navigation.addListener(
53 56
             'focus',
@@ -80,7 +83,22 @@ class WebViewScreen extends React.PureComponent<Props> {
80 83
      *
81 84
      * @return {*}
82 85
      */
83
-    getRefreshButton() {
86
+    getBasicButton = () => {
87
+        return (
88
+            <MaterialHeaderButtons>
89
+                <Item
90
+                    title="refresh"
91
+                    iconName="refresh"
92
+                    onPress={this.onRefreshClicked}/>
93
+                <Item
94
+                    title={i18n.t("general.openInBrowser")}
95
+                    iconName="open-in-new"
96
+                    onPress={this.onOpenClicked}/>
97
+            </MaterialHeaderButtons>
98
+        );
99
+    };
100
+
101
+    getAdvancedButtons = () => {
84 102
         return (
85 103
             <MaterialHeaderButtons>
86 104
                 <Item
@@ -101,7 +119,7 @@ class WebViewScreen extends React.PureComponent<Props> {
101 119
                     onPress={this.onOpenClicked}/>
102 120
             </MaterialHeaderButtons>
103 121
         );
104
-    };
122
+    }
105 123
 
106 124
     /**
107 125
      * Callback to use when refresh button is clicked. Reloads the webview.

+ 6
- 4
src/screens/Planex/PlanexScreen.js View File

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

Loading…
Cancel
Save