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,5 +1,7 @@
1 1
 package com.reactnativenavigation.parse;
2 2
 
3
+import android.graphics.Color;
4
+
3 5
 import com.reactnativenavigation.parse.params.Colour;
4 6
 import com.reactnativenavigation.parse.params.NullColor;
5 7
 import com.reactnativenavigation.parse.parsers.ColorParser;
@@ -15,7 +17,7 @@ public class TopBarBackgroundOptions {
15 17
         options.component = Component.parse(json.optJSONObject("component"));
16 18
 
17 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 23
         return options;

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

@@ -2,6 +2,7 @@ package com.reactnativenavigation.views.topbar;
2 2
 
3 3
 import android.annotation.SuppressLint;
4 4
 import android.content.Context;
5
+import android.graphics.Color;
5 6
 import android.graphics.Typeface;
6 7
 import android.os.Build;
7 8
 import android.support.annotation.ColorInt;
@@ -97,7 +98,7 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
97 98
 
98 99
     private View createBorder() {
99 100
         View border = new View(getContext());
100
-        border.setBackgroundColor(android.graphics.Color.TRANSPARENT);
101
+        border.setBackgroundColor(Color.TRANSPARENT);
101 102
         FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(MATCH_PARENT, 0);
102 103
         lp.gravity = Gravity.BOTTOM;
103 104
         border.setLayoutParams(lp);

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

@@ -7,22 +7,18 @@ const { Navigation } = require('react-native-navigation');
7 7
 const testIDs = require('../testIDs');
8 8
 
9 9
 class ComplexLayout extends Component {
10
-  constructor(props) {
11
-    super(props);
12
-  }
13
-
14 10
   render() {
15 11
     return (
16 12
       <View style={styles.root}>
17 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 17
       </View>
22 18
     );
23 19
   }
24 20
 
25
-  onExternalComponentInStackPressed() {
21
+  onExternalComponentInStackPressed = () => {
26 22
     Navigation.showModal({
27 23
       stack: {
28 24
         children: [{
@@ -37,7 +33,7 @@ class ComplexLayout extends Component {
37 33
     });
38 34
   }
39 35
 
40
-  onExternalComponentInDeepStackPressed() {
36
+  onExternalComponentInDeepStackPressed = () => {
41 37
     Navigation.showModal({
42 38
       stack: {
43 39
         children: [{
@@ -57,7 +53,7 @@ class ComplexLayout extends Component {
57 53
     });
58 54
   }
59 55
 
60
-  onSideMenuLayoutInsideBottomTabPressed() {
56
+  onSideMenuLayoutInsideBottomTabPressed = () => {
61 57
     Navigation.dismissAllModals();
62 58
     Navigation.setRoot({
63 59
       root: {
@@ -68,44 +64,47 @@ class ComplexLayout extends Component {
68 64
                 children: [
69 65
                   {
70 66
                     component: {
71
-                      name: 'navigation.playground.TextScreen',
72
-                    },
73
-                  },
67
+                      name: 'navigation.playground.TextScreen'
68
+                    }
69
+                  }
74 70
                 ],
75 71
                 options: {
76 72
                   bottomTab: {
77 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 80
               sideMenu: {
85 81
                 left: {
86 82
                   component: {
87 83
                     name: 'navigation.playground.SideMenuScreen',
88
-                  },
84
+                    passProps: {
85
+                      side: 'left'
86
+                    }
87
+                  }
89 88
                 },
90 89
                 center: {
91 90
                   stack: {
92 91
                     children: [
93 92
                       {
94 93
                         component: {
95
-                          name: 'navigation.playground.TextScreen',
96
-                        },
97
-                      },
98
-                    ],
99
-                  },
94
+                          name: 'complexLayout.bottomTabThatOpensSideMenu'
95
+                        }
96
+                      }
97
+                    ]
98
+                  }
100 99
                 },
101 100
                 options: {
102 101
                   bottomTab: {
103 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

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