Browse Source

More work on SideMenu inside BottomTabs screen before adding e2e

Guy Carmeli 6 years ago
parent
commit
aef066494e

+ 3
- 1
lib/android/app/src/main/java/com/reactnativenavigation/parse/TopBarBackgroundOptions.java View File

1
 package com.reactnativenavigation.parse;
1
 package com.reactnativenavigation.parse;
2
 
2
 
3
+import android.graphics.Color;
4
+
3
 import com.reactnativenavigation.parse.params.Colour;
5
 import com.reactnativenavigation.parse.params.Colour;
4
 import com.reactnativenavigation.parse.params.NullColor;
6
 import com.reactnativenavigation.parse.params.NullColor;
5
 import com.reactnativenavigation.parse.parsers.ColorParser;
7
 import com.reactnativenavigation.parse.parsers.ColorParser;
15
         options.component = Component.parse(json.optJSONObject("component"));
17
         options.component = Component.parse(json.optJSONObject("component"));
16
 
18
 
17
         if (options.component.hasValue()) {
19
         if (options.component.hasValue()) {
18
-            options.color = new Colour(android.graphics.Color.TRANSPARENT);
20
+            options.color = new Colour(Color.TRANSPARENT);
19
         }
21
         }
20
 
22
 
21
         return options;
23
         return options;

+ 2
- 1
lib/android/app/src/main/java/com/reactnativenavigation/views/topbar/TopBar.java View File

2
 
2
 
3
 import android.annotation.SuppressLint;
3
 import android.annotation.SuppressLint;
4
 import android.content.Context;
4
 import android.content.Context;
5
+import android.graphics.Color;
5
 import android.graphics.Typeface;
6
 import android.graphics.Typeface;
6
 import android.os.Build;
7
 import android.os.Build;
7
 import android.support.annotation.ColorInt;
8
 import android.support.annotation.ColorInt;
97
 
98
 
98
     private View createBorder() {
99
     private View createBorder() {
99
         View border = new View(getContext());
100
         View border = new View(getContext());
100
-        border.setBackgroundColor(android.graphics.Color.TRANSPARENT);
101
+        border.setBackgroundColor(Color.TRANSPARENT);
101
         FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(MATCH_PARENT, 0);
102
         FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(MATCH_PARENT, 0);
102
         lp.gravity = Gravity.BOTTOM;
103
         lp.gravity = Gravity.BOTTOM;
103
         border.setLayoutParams(lp);
104
         border.setLayoutParams(lp);

+ 27
- 28
playground/src/screens/ComplexLayout.js View File

7
 const testIDs = require('../testIDs');
7
 const testIDs = require('../testIDs');
8
 
8
 
9
 class ComplexLayout extends Component {
9
 class ComplexLayout extends Component {
10
-  constructor(props) {
11
-    super(props);
12
-  }
13
-
14
   render() {
10
   render() {
15
     return (
11
     return (
16
       <View style={styles.root}>
12
       <View style={styles.root}>
17
         <Text style={styles.h1} testID={testIDs.CENTERED_TEXT_HEADER}>{this.props.text || 'Complex layout screen'}</Text>
13
         <Text style={styles.h1} testID={testIDs.CENTERED_TEXT_HEADER}>{this.props.text || 'Complex layout screen'}</Text>
18
-        <Button title={'External component in stack'} testID={testIDs.EXTERNAL_COMPONENT_IN_STACK} onPress={() => this.onExternalComponentInStackPressed()} />
19
-        <Button title={'External component in deep stack'} testID={testIDs.EXTERNAL_COMPONENT_IN_DEEP_STACK} onPress={() => this.onExternalComponentInDeepStackPressed()} />
20
-        <Button title={'Sidemenu layout inside a bottomTab'} testID={testIDs.SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB} onPress={() => this.onSideMenuLayoutInsideBottomTabPressed()} />
14
+        <Button title={'External component in stack'} testID={testIDs.EXTERNAL_COMPONENT_IN_STACK} onPress={this.onExternalComponentInStackPressed} />
15
+        <Button title={'External component in deep stack'} testID={testIDs.EXTERNAL_COMPONENT_IN_DEEP_STACK} onPress={this.onExternalComponentInDeepStackPressed} />
16
+        <Button title={'SideMenu layout inside a bottomTab'} testID={testIDs.SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB} onPress={this.onSideMenuLayoutInsideBottomTabPressed} />
21
       </View>
17
       </View>
22
     );
18
     );
23
   }
19
   }
24
 
20
 
25
-  onExternalComponentInStackPressed() {
21
+  onExternalComponentInStackPressed = () => {
26
     Navigation.showModal({
22
     Navigation.showModal({
27
       stack: {
23
       stack: {
28
         children: [{
24
         children: [{
37
     });
33
     });
38
   }
34
   }
39
 
35
 
40
-  onExternalComponentInDeepStackPressed() {
36
+  onExternalComponentInDeepStackPressed = () => {
41
     Navigation.showModal({
37
     Navigation.showModal({
42
       stack: {
38
       stack: {
43
         children: [{
39
         children: [{
57
     });
53
     });
58
   }
54
   }
59
 
55
 
60
-  onSideMenuLayoutInsideBottomTabPressed() {
56
+  onSideMenuLayoutInsideBottomTabPressed = () => {
61
     Navigation.dismissAllModals();
57
     Navigation.dismissAllModals();
62
     Navigation.setRoot({
58
     Navigation.setRoot({
63
       root: {
59
       root: {
68
                 children: [
64
                 children: [
69
                   {
65
                   {
70
                     component: {
66
                     component: {
71
-                      name: 'navigation.playground.TextScreen',
72
-                    },
73
-                  },
67
+                      name: 'navigation.playground.TextScreen'
68
+                    }
69
+                  }
74
                 ],
70
                 ],
75
                 options: {
71
                 options: {
76
                   bottomTab: {
72
                   bottomTab: {
77
                     text: 'Stack',
73
                     text: 'Stack',
78
-                    icon: require('../images/one.png'),
79
-                  },
80
-                },
81
-              },
74
+                    icon: require('../images/one.png')
75
+                  }
76
+                }
77
+              }
82
             },
78
             },
83
             {
79
             {
84
               sideMenu: {
80
               sideMenu: {
85
                 left: {
81
                 left: {
86
                   component: {
82
                   component: {
87
                     name: 'navigation.playground.SideMenuScreen',
83
                     name: 'navigation.playground.SideMenuScreen',
88
-                  },
84
+                    passProps: {
85
+                      side: 'left'
86
+                    }
87
+                  }
89
                 },
88
                 },
90
                 center: {
89
                 center: {
91
                   stack: {
90
                   stack: {
92
                     children: [
91
                     children: [
93
                       {
92
                       {
94
                         component: {
93
                         component: {
95
-                          name: 'navigation.playground.TextScreen',
96
-                        },
97
-                      },
98
-                    ],
99
-                  },
94
+                          name: 'complexLayout.bottomTabThatOpensSideMenu'
95
+                        }
96
+                      }
97
+                    ]
98
+                  }
100
                 },
99
                 },
101
                 options: {
100
                 options: {
102
                   bottomTab: {
101
                   bottomTab: {
103
                     text: 'SideMenu',
102
                     text: 'SideMenu',
104
-                    icon: require('../images/two.png'),
105
-                  },
106
-                },
107
-              },
108
-            },
103
+                    icon: require('../images/two.png')
104
+                  }
105
+                }
106
+              }
107
+            }
109
            ]
108
            ]
110
         }
109
         }
111
       }
110
       }

+ 37
- 0
playground/src/screens/complexlayouts/BottomTabSideMenuScreen.js View File

1
+const React = require('react');
2
+const { Component } = require('react');
3
+const { View, Button } = require('react-native');
4
+const { Navigation } = require('react-native-navigation');
5
+
6
+class BottomTabSideMenuScreen extends Component {
7
+   onOpenSideMenuPress = () => {
8
+   Navigation.mergeOptions(this.props.componentId, {
9
+      sideMenu: {
10
+        left: {
11
+          visible: true
12
+        }
13
+      }
14
+    });
15
+  }
16
+   render() {
17
+    return (
18
+      <View style={styles.root}>
19
+        <Button
20
+          title="Open SideMenu"
21
+          color="blue"
22
+          onPress={this.onOpenSideMenuPress}
23
+          //TODO: testID for detox 
24
+        />
25
+      </View>
26
+    );
27
+  }
28
+}
29
+ module.exports = BottomTabSideMenuScreen;
30
+ const styles = {
31
+  root: {
32
+    flexGrow: 1,
33
+    justifyContent: 'center',
34
+    alignItems: 'center',
35
+    backgroundColor: '#f5fcff'
36
+  }
37
+};

+ 2
- 0
playground/src/screens/index.js View File

25
 const ComplexLayout = require('./ComplexLayout');
25
 const ComplexLayout = require('./ComplexLayout');
26
 const SearchScreen = require('./SearchScreen');
26
 const SearchScreen = require('./SearchScreen');
27
 const KeyboardScreen = require('./KeyboardScreen');
27
 const KeyboardScreen = require('./KeyboardScreen');
28
+const BottomTabSideMenuScreen = require('./complexlayouts/BottomTabSideMenuScreen');
28
 
29
 
29
 function registerScreens() {
30
 function registerScreens() {
30
   Navigation.registerComponent(`navigation.playground.CustomTransitionDestination`, () => CustomTransitionDestination);
31
   Navigation.registerComponent(`navigation.playground.CustomTransitionDestination`, () => CustomTransitionDestination);
53
   Navigation.registerComponent('TopBarBackground', () => TopBarBackground);
54
   Navigation.registerComponent('TopBarBackground', () => TopBarBackground);
54
   Navigation.registerComponent('navigation.playground.SearchControllerScreen', () => SearchScreen);
55
   Navigation.registerComponent('navigation.playground.SearchControllerScreen', () => SearchScreen);
55
   Navigation.registerComponent('navigation.playground.KeyboardScreen', () => KeyboardScreen);
56
   Navigation.registerComponent('navigation.playground.KeyboardScreen', () => KeyboardScreen);
57
+  Navigation.registerComponent('complexLayout.bottomTabThatOpensSideMenu', () => BottomTabSideMenuScreen);
56
 }
58
 }
57
 
59
 
58
 module.exports = {
60
 module.exports = {