Guy Carmeli 8 jaren geleden
bovenliggende
commit
7abc5f8736
18 gewijzigde bestanden met toevoegingen van 184 en 73 verwijderingen
  1. 1
    1
      android/app/build.gradle
  2. 1
    1
      android/app/src/main/java/com/reactnativenavigation/params/ScreenParams.java
  3. 2
    2
      android/app/src/main/java/com/reactnativenavigation/params/StyleParams.java
  4. 1
    1
      android/app/src/main/java/com/reactnativenavigation/params/TitleBarButtonParams.java
  5. 4
    0
      android/app/src/main/java/com/reactnativenavigation/params/parsers/ActivityParamsParser.java
  6. 1
    1
      android/app/src/main/java/com/reactnativenavigation/params/parsers/ScreenParamsParser.java
  7. 0
    32
      android/app/src/main/java/com/reactnativenavigation/params/parsers/ScreenStyleParamsParser.java
  8. 122
    0
      android/app/src/main/java/com/reactnativenavigation/params/parsers/StyleParamsParser.java
  9. 2
    2
      android/app/src/main/java/com/reactnativenavigation/params/parsers/TitleBarButtonParamsParser.java
  10. 1
    1
      android/app/src/main/java/com/reactnativenavigation/screens/FragmentScreen.java
  11. 5
    5
      android/app/src/main/java/com/reactnativenavigation/screens/Screen.java
  12. 2
    2
      android/app/src/main/java/com/reactnativenavigation/screens/ScreenStack.java
  13. 1
    1
      android/app/src/main/java/com/reactnativenavigation/screens/SingleScreen.java
  14. 1
    1
      android/app/src/main/java/com/reactnativenavigation/screens/ViewPagerScreen.java
  15. 4
    3
      android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java
  16. 3
    3
      android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java
  17. 2
    2
      android/app/src/main/java/com/reactnativenavigation/views/TopBar.java
  18. 31
    15
      src/deprecated/platformSpecificDeprecated.android.js

+ 1
- 1
android/app/build.gradle Bestand weergeven

@@ -46,7 +46,7 @@ allprojects { p ->
46 46
 
47 47
 dependencies {
48 48
     compile fileTree(dir: "libs", include: ["*.jar"])
49
-    compile "com.aurelhubert:ahbottomnavigation:1.3.0"
49
+    compile "com.aurelhubert:ahbottomnavigation:1.3.3"
50 50
     compile "com.android.support:appcompat-v7:23.0.1"
51 51
     compile 'com.android.support:design:23.1.1'
52 52
     compile "com.facebook.react:react-native:+"  // From node_modules

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/params/ScreenParams.java Bestand weergeven

@@ -11,7 +11,7 @@ public class ScreenParams {
11 11
     public List<TitleBarButtonParams> rightButtons;
12 12
     public TitleBarLeftButtonParams leftButton;
13 13
     public String title;
14
-    public ScreenStyleParams styleParams;
14
+    public StyleParams styleParams;
15 15
     public List<TopTabParams> topTabParams;
16 16
     public String fragmentCreatorClassName;
17 17
 

android/app/src/main/java/com/reactnativenavigation/params/ScreenStyleParams.java → android/app/src/main/java/com/reactnativenavigation/params/StyleParams.java Bestand weergeven

@@ -2,7 +2,7 @@ package com.reactnativenavigation.params;
2 2
 
3 3
 import android.support.annotation.ColorInt;
4 4
 
5
-public class ScreenStyleParams {
5
+public class StyleParams {
6 6
     public static class Color {
7 7
         @ColorInt
8 8
         private int color = -1;
@@ -41,5 +41,5 @@ public class ScreenStyleParams {
41 41
 
42 42
     public Color navigationBarColor;
43 43
 
44
-    public boolean drawBelowTopBar;
44
+    public boolean drawScreenBelowTopBar;
45 45
 }

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/params/TitleBarButtonParams.java Bestand weergeven

@@ -20,7 +20,7 @@ public class TitleBarButtonParams {
20 20
     public String eventId;
21 21
     public String label;
22 22
     public Drawable icon;
23
-    public ScreenStyleParams.Color color;
23
+    public StyleParams.Color color;
24 24
     public ShowAsAction showAsAction;
25 25
     public boolean enabled = true;
26 26
 }

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/ActivityParamsParser.java Bestand weergeven

@@ -3,10 +3,14 @@ package com.reactnativenavigation.params.parsers;
3 3
 import android.os.Bundle;
4 4
 
5 5
 import com.reactnativenavigation.params.ActivityParams;
6
+import com.reactnativenavigation.params.StyleParams;
6 7
 
7 8
 public class ActivityParamsParser extends Parser {
8 9
     public static ActivityParams parse(Bundle params) {
9 10
         ActivityParams result = new ActivityParams();
11
+
12
+        StyleParamsParser.setAppStyle(params);
13
+
10 14
         if (hasKey(params, "screen")) {
11 15
             result.type = ActivityParams.Type.SingleScreen;
12 16
             result.screenParams = ScreenParamsParser.parse(params.getBundle("screen"));

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/params/parsers/ScreenParamsParser.java Bestand weergeven

@@ -38,7 +38,7 @@ public class ScreenParamsParser extends Parser {
38 38
             result.leftButton = new TitleBarLeftButtonParamsParser().parseSingleButton(params.getBundle(KEY_LEFT_BUTTON));
39 39
         }
40 40
         result.title = params.getString(KEY_TITLE);
41
-        result.styleParams = ScreenStyleParamsParser.parse(params.getBundle(STYLE_PARAMS));
41
+        result.styleParams = new StyleParamsParser(params.getBundle(STYLE_PARAMS)).parse();
42 42
         if (hasKey(params, TOP_TABS)) {
43 43
             result.topTabParams = TopTabParamsParser.parse(params.getBundle(TOP_TABS));
44 44
         }

+ 0
- 32
android/app/src/main/java/com/reactnativenavigation/params/parsers/ScreenStyleParamsParser.java Bestand weergeven

@@ -1,32 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.reactnativenavigation.params.ScreenStyleParams;
6
-
7
-public class ScreenStyleParamsParser {
8
-    public static ScreenStyleParams parse(Bundle params) {
9
-        ScreenStyleParams result = new ScreenStyleParams();
10
-        if (params == null) {
11
-            return result;
12
-        }
13
-
14
-        result.statusBarColor = new ScreenStyleParams.Color(ColorParser.parse(params.getString("statusBarColor")));
15
-        result.topBarColor = new ScreenStyleParams.Color(ColorParser.parse(params.getString("topBarColor")));
16
-        result.navigationBarColor = new ScreenStyleParams.Color(ColorParser.parse(params.getString("navigationBarColor")));
17
-        result.titleBarHidden = params.getBoolean("titleBarHidden");
18
-        result.titleBarTitleColor =
19
-                new ScreenStyleParams.Color(ColorParser.parse(params.getString("titleBarTitleColor")));
20
-        result.backButtonHidden = params.getBoolean("backButtonHidden");
21
-        result.topTabsHidden = params.getBoolean("topTabsHidden");
22
-        result.bottomTabsHidden = params.getBoolean("bottomTabsHidden");
23
-        result.bottomTabsHiddenOnScroll = params.getBoolean("bottomTabsHiddenOnScroll");
24
-        result.bottomTabsColor = new ScreenStyleParams.Color(ColorParser.parse(params.getString("bottomTabsColor")));
25
-        result.bottomTabsButtonColor =
26
-                new ScreenStyleParams.Color(ColorParser.parse(params.getString("bottomTabsButtonColor")));
27
-        result.selectedBottomTabsButtonColor =
28
-                new ScreenStyleParams.Color(ColorParser.parse(params.getString("selectedBottomTabsButtonColor")));
29
-        result.drawBelowTopBar = params.getBoolean("drawBelowTopBar", false);
30
-        return result;
31
-    }
32
-}

+ 122
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/StyleParamsParser.java Bestand weergeven

@@ -0,0 +1,122 @@
1
+package com.reactnativenavigation.params.parsers;
2
+
3
+import android.os.Bundle;
4
+import android.support.annotation.NonNull;
5
+import android.support.annotation.Nullable;
6
+
7
+import com.reactnativenavigation.params.StyleParams;
8
+
9
+public class StyleParamsParser {
10
+    private static StyleParams appStyle;
11
+    private Bundle params;
12
+
13
+    public static void setAppStyle(Bundle params) {
14
+        StyleParamsParser.appStyle = new StyleParamsParser(params.getBundle("appStyle")).parse();
15
+    }
16
+
17
+    public StyleParamsParser(Bundle params) {
18
+        this.params = params;
19
+    }
20
+
21
+    public StyleParams parse() {
22
+        StyleParams result = new StyleParams();
23
+        if (params == null) {
24
+            return result;
25
+        }
26
+
27
+        result.statusBarColor = getColor("statusBarColor", getDefaultStatusBarColor());
28
+
29
+        result.topBarColor = getColor("topBarColor", getDefaultTopBarColor());
30
+        result.titleBarHidden = getBoolean("titleBarHidden", isDefaultTopBarHidden());
31
+        result.titleBarTitleColor = getColor("titleBarTitleColor", getDefaultTitleBarColor());
32
+        result.backButtonHidden = getBoolean("backButtonHidden", isDefaultBackButtonHidden());
33
+        result.topTabsHidden = getBoolean("topTabsHidden", isDefaultTopTabsHidden());
34
+
35
+        result.drawScreenBelowTopBar = params.getBoolean("drawBelowTopBar", isDefaultScreenBelowTopBar());
36
+
37
+        result.bottomTabsHidden = getBoolean("bottomTabsHidden", isDefaultBottomTabsHidden());
38
+        result.bottomTabsHiddenOnScroll =
39
+                getBoolean("bottomTabsHiddenOnScroll", isDefaultBottomTabsHiddenOnScroll());
40
+        result.bottomTabsColor = getColor("bottomTabsColor", getDefaultBottomTabsColor());
41
+        result.bottomTabsButtonColor = getColor("bottomTabsButtonColor", getDefaultBottomTabsButtonColor());
42
+        result.selectedBottomTabsButtonColor =
43
+                getColor("selectedBottomTabsButtonColor", getDefaultSelectedBottomTabsButtonColor());
44
+
45
+        result.navigationBarColor = getColor("navigationBarColor", getDefaultNavigationColor());
46
+
47
+        return result;
48
+    }
49
+
50
+    @Nullable
51
+    private StyleParams.Color getDefaultNavigationColor() {
52
+        return appStyle == null ? new StyleParams.Color(-1) : appStyle.navigationBarColor;
53
+    }
54
+
55
+    @Nullable
56
+    private StyleParams.Color getDefaultSelectedBottomTabsButtonColor() {
57
+        return appStyle == null ? new StyleParams.Color(-1) : appStyle.selectedBottomTabsButtonColor;
58
+    }
59
+
60
+    @Nullable
61
+    private StyleParams.Color getDefaultBottomTabsButtonColor() {
62
+        return appStyle == null ? new StyleParams.Color(-1) : appStyle.bottomTabsButtonColor;
63
+    }
64
+
65
+    @Nullable
66
+    private StyleParams.Color getDefaultBottomTabsColor() {
67
+        return appStyle == null ? new StyleParams.Color(-1) : appStyle.bottomTabsColor;
68
+    }
69
+
70
+    private boolean isDefaultBottomTabsHiddenOnScroll() {
71
+        return appStyle != null && appStyle.bottomTabsHiddenOnScroll;
72
+    }
73
+
74
+    private boolean isDefaultBottomTabsHidden() {
75
+        return appStyle != null && appStyle.bottomTabsHidden;
76
+    }
77
+
78
+    private boolean isDefaultScreenBelowTopBar() {
79
+        return appStyle == null || appStyle.drawScreenBelowTopBar;
80
+    }
81
+
82
+    private boolean isDefaultTopTabsHidden() {
83
+        return appStyle != null && appStyle.topTabsHidden;
84
+    }
85
+
86
+    private boolean isDefaultBackButtonHidden() {
87
+        return appStyle != null && appStyle.backButtonHidden;
88
+    }
89
+
90
+    @Nullable
91
+    private StyleParams.Color getDefaultTitleBarColor() {
92
+        return appStyle == null ? new StyleParams.Color(-1) : appStyle.titleBarTitleColor;
93
+    }
94
+
95
+    private boolean isDefaultTopBarHidden() {
96
+        return appStyle != null && appStyle.titleBarHidden;
97
+    }
98
+
99
+    @Nullable
100
+    private StyleParams.Color getDefaultTopBarColor() {
101
+        return appStyle == null ? new StyleParams.Color(-1) : appStyle.topBarColor;
102
+    }
103
+
104
+    @Nullable
105
+    private StyleParams.Color getDefaultStatusBarColor() {
106
+        return appStyle == null ? new StyleParams.Color(-1) : appStyle.statusBarColor;
107
+    }
108
+
109
+    private boolean getBoolean(String titleBarHidden, boolean defaultValue) {
110
+        return params.containsKey(titleBarHidden) ? params.getBoolean(titleBarHidden) : defaultValue;
111
+    }
112
+
113
+    @NonNull
114
+    private StyleParams.Color getColor(String key, StyleParams.Color defaultColor) {
115
+        StyleParams.Color color = new StyleParams.Color(ColorParser.parse(params.getString(key)));
116
+        if (color.hasColor()) {
117
+            return color;
118
+        } else {
119
+            return defaultColor.hasColor() ? defaultColor : color;
120
+        }
121
+    }
122
+}

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/params/parsers/TitleBarButtonParamsParser.java Bestand weergeven

@@ -2,7 +2,7 @@ package com.reactnativenavigation.params.parsers;
2 2
 
3 3
 import android.os.Bundle;
4 4
 
5
-import com.reactnativenavigation.params.ScreenStyleParams;
5
+import com.reactnativenavigation.params.StyleParams;
6 6
 import com.reactnativenavigation.params.TitleBarButtonParams;
7 7
 import com.reactnativenavigation.react.ImageLoader;
8 8
 
@@ -25,7 +25,7 @@ public class TitleBarButtonParamsParser extends Parser {
25 25
         if (hasKey(bundle,"icon")) {
26 26
             result.icon = ImageLoader.loadImage(bundle.getString("icon"));
27 27
         }
28
-        result.color = new ScreenStyleParams.Color(ColorParser.parse(bundle.getString("color")));
28
+        result.color = new StyleParams.Color(ColorParser.parse(bundle.getString("color")));
29 29
         result.showAsAction = parseShowAsAction(bundle.getString("showAsAction"));
30 30
         result.enabled = bundle.getBoolean("enabled", true);
31 31
         result.eventId = bundle.getString("id");

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/screens/FragmentScreen.java Bestand weergeven

@@ -41,7 +41,7 @@ public class FragmentScreen extends Screen {
41 41
         ContentView contentView = new ContentView(getContext(), screenParams.screenId, screenParams.passProps, screenParams.navigationParams, null);
42 42
         addView(contentView, 0, 0);
43 43
         LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
44
-        if (screenParams.styleParams.drawBelowTopBar) {
44
+        if (screenParams.styleParams.drawScreenBelowTopBar) {
45 45
             params.addRule(BELOW, topBar.getId());
46 46
         }
47 47
         addView(content, params);

+ 5
- 5
android/app/src/main/java/com/reactnativenavigation/screens/Screen.java Bestand weergeven

@@ -11,7 +11,7 @@ import android.widget.RelativeLayout;
11 11
 
12 12
 import com.reactnativenavigation.animation.VisibilityAnimator;
13 13
 import com.reactnativenavigation.params.ScreenParams;
14
-import com.reactnativenavigation.params.ScreenStyleParams;
14
+import com.reactnativenavigation.params.StyleParams;
15 15
 import com.reactnativenavigation.params.TitleBarButtonParams;
16 16
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
17 17
 import com.reactnativenavigation.utils.SdkSupports;
@@ -74,14 +74,14 @@ public abstract class Screen extends RelativeLayout implements ScrollDirectionLi
74 74
         });
75 75
     }
76 76
 
77
-    private void setStyle(ScreenStyleParams styleParams) {
77
+    private void setStyle(StyleParams styleParams) {
78 78
         setStatusBarColor(styleParams.statusBarColor);
79 79
         setNavigationBarColor(styleParams.navigationBarColor);
80 80
         topBar.setStyle(styleParams);
81 81
     }
82 82
 
83 83
     @TargetApi(Build.VERSION_CODES.LOLLIPOP)
84
-    private void setStatusBarColor(ScreenStyleParams.Color statusBarColor) {
84
+    private void setStatusBarColor(StyleParams.Color statusBarColor) {
85 85
         if (!SdkSupports.lollipop()) {
86 86
             return;
87 87
         }
@@ -96,7 +96,7 @@ public abstract class Screen extends RelativeLayout implements ScrollDirectionLi
96 96
     }
97 97
 
98 98
     @TargetApi(Build.VERSION_CODES.LOLLIPOP)
99
-    public void setNavigationBarColor(ScreenStyleParams.Color navigationBarColor) {
99
+    public void setNavigationBarColor(StyleParams.Color navigationBarColor) {
100 100
         if (!SdkSupports.lollipop()) {
101 101
             return;
102 102
         }
@@ -154,7 +154,7 @@ public abstract class Screen extends RelativeLayout implements ScrollDirectionLi
154 154
         topBar.setTitleBarRightButton(navigatorEventId, backButtonListener, titleBarLeftButtonParams);
155 155
     }
156 156
 
157
-    public ScreenStyleParams getStyleParams() {
157
+    public StyleParams getStyleParams() {
158 158
         return screenParams.styleParams;
159 159
     }
160 160
 }

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/screens/ScreenStack.java Bestand weergeven

@@ -5,7 +5,7 @@ import android.support.v7.app.AppCompatActivity;
5 5
 import android.widget.FrameLayout;
6 6
 
7 7
 import com.reactnativenavigation.params.ScreenParams;
8
-import com.reactnativenavigation.params.ScreenStyleParams;
8
+import com.reactnativenavigation.params.StyleParams;
9 9
 import com.reactnativenavigation.params.TitleBarButtonParams;
10 10
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
11 11
 import com.reactnativenavigation.utils.Task;
@@ -134,7 +134,7 @@ public class ScreenStack extends FrameLayout implements TitleBarBackButtonListen
134 134
         }
135 135
     }
136 136
 
137
-    public ScreenStyleParams getCurrentScreenStyleParams() {
137
+    public StyleParams getCurrentScreenStyleParams() {
138 138
         return stack.peek().getStyleParams();
139 139
     }
140 140
 

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/screens/SingleScreen.java Bestand weergeven

@@ -21,7 +21,7 @@ public class SingleScreen extends Screen {
21 21
     protected void createContent() {
22 22
         contentView = new ContentView(getContext(), screenParams.screenId, screenParams.passProps, screenParams.navigationParams, this);
23 23
         LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
24
-        if (screenParams.styleParams.drawBelowTopBar) {
24
+        if (screenParams.styleParams.drawScreenBelowTopBar) {
25 25
             params.addRule(BELOW, topBar.getId());
26 26
         }
27 27
         addView(contentView, params);

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/screens/ViewPagerScreen.java Bestand weergeven

@@ -52,7 +52,7 @@ public class ViewPagerScreen extends Screen {
52 52
 
53 53
     private void addContent(ContentView contentView) {
54 54
         LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
55
-        if (screenParams.styleParams.drawBelowTopBar) {
55
+        if (screenParams.styleParams.drawScreenBelowTopBar) {
56 56
             params.addRule(BELOW, topBar.getId());
57 57
         }
58 58
         viewPager.addView(contentView, params);

+ 4
- 3
android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java Bestand weergeven

@@ -6,7 +6,7 @@ import android.graphics.Color;
6 6
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
7 7
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
8 8
 import com.reactnativenavigation.params.ScreenParams;
9
-import com.reactnativenavigation.params.ScreenStyleParams;
9
+import com.reactnativenavigation.params.StyleParams;
10 10
 
11 11
 import java.util.List;
12 12
 
@@ -25,8 +25,9 @@ public class BottomTabs extends AHBottomNavigation {
25 25
         }
26 26
     }
27 27
 
28
-    public void setStyleFromScreen(ScreenStyleParams params) {
28
+    public void setStyleFromScreen(StyleParams params) {
29 29
         setBackgroundColor(params.bottomTabsColor);
30
+
30 31
         if (params.bottomTabsButtonColor.hasColor()) {
31 32
             setInactiveColor(params.bottomTabsButtonColor.getColor());
32 33
         }
@@ -36,7 +37,7 @@ public class BottomTabs extends AHBottomNavigation {
36 37
         }
37 38
     }
38 39
 
39
-    private void setBackgroundColor(ScreenStyleParams.Color bottomTabsColor) {
40
+    private void setBackgroundColor(StyleParams.Color bottomTabsColor) {
40 41
         if (bottomTabsColor.hasColor()) {
41 42
             setDefaultBackgroundColor(bottomTabsColor.getColor());
42 43
         } else {

+ 3
- 3
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java Bestand weergeven

@@ -5,7 +5,7 @@ import android.support.v7.widget.Toolbar;
5 5
 import android.view.Menu;
6 6
 
7 7
 import com.reactnativenavigation.animation.VisibilityAnimator;
8
-import com.reactnativenavigation.params.ScreenStyleParams;
8
+import com.reactnativenavigation.params.StyleParams;
9 9
 import com.reactnativenavigation.params.TitleBarButtonParams;
10 10
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
11 11
 
@@ -41,12 +41,12 @@ public class TitleBar extends Toolbar {
41 41
         }
42 42
     }
43 43
 
44
-    public void setStyle(ScreenStyleParams params) {
44
+    public void setStyle(StyleParams params) {
45 45
         setVisibility(params.titleBarHidden ? GONE : VISIBLE);
46 46
         setTitleTextColor(params);
47 47
     }
48 48
 
49
-    private void setTitleTextColor(ScreenStyleParams params) {
49
+    private void setTitleTextColor(StyleParams params) {
50 50
         if (params.titleBarTitleColor.hasColor()) {
51 51
             setTitleTextColor(params.titleBarTitleColor.getColor());
52 52
         }

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/views/TopBar.java Bestand weergeven

@@ -4,7 +4,7 @@ import android.content.Context;
4 4
 import android.support.design.widget.AppBarLayout;
5 5
 import android.support.design.widget.TabLayout;
6 6
 
7
-import com.reactnativenavigation.params.ScreenStyleParams;
7
+import com.reactnativenavigation.params.StyleParams;
8 8
 import com.reactnativenavigation.params.TitleBarButtonParams;
9 9
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
10 10
 import com.reactnativenavigation.utils.ViewUtils;
@@ -35,7 +35,7 @@ public class TopBar extends AppBarLayout {
35 35
         titleBar.setTitle(title);
36 36
     }
37 37
 
38
-    public void setStyle(ScreenStyleParams styleParams) {
38
+    public void setStyle(StyleParams styleParams) {
39 39
         if (styleParams.topBarColor.hasColor()) {
40 40
             setBackgroundColor(styleParams.topBarColor.getColor());
41 41
         }

+ 31
- 15
src/deprecated/platformSpecificDeprecated.android.js Bestand weergeven

@@ -24,9 +24,11 @@ function startSingleScreenApp(params) {
24 24
   /*
25 25
    * adapt to new API
26 26
    */
27
+  console.log('0');
27 28
   screen.screenId = screen.screen;
28 29
   params.screen = adaptNavigationStyleToScreenStyle(screen);
29 30
   params.screen = adaptNavigationParams(screen);
31
+  params.appStyle = convertStyleParams(params.appStyle);
30 32
 
31 33
   newPlatformSpecific.startApp(params);
32 34
 }
@@ -81,25 +83,33 @@ function adaptNavigationStyleToScreenStyle(screen) {
81 83
     return screen;
82 84
   }
83 85
 
84
-  screen.styleParams = {
85
-    statusBarColor: navigatorStyle.statusBarColor,
86
-    topBarColor: navigatorStyle.toolBarColor,
87
-    navigationBarColor: navigatorStyle.navigationBarColor,
88
-    titleBarHidden: navigatorStyle.navBarHidden,
89
-    titleBarTitleColor: navigatorStyle.navBarTextColor,
90
-    backButtonHidden: navigatorStyle.backButtonHidden,
91
-    topTabsHidden: navigatorStyle.topTabsHidden,
92
-    bottomTabsHidden: navigatorStyle.tabBarHidden,
93
-    bottomTabsHiddenOnScroll: navigatorStyle.bottomTabsHiddenOnScroll,
94
-    drawBelowTopBar: !navigatorStyle.drawUnderNavBar,
95
-    bottomTabsColor: navigatorStyle.tabBarBackgroundColor,
96
-    bottomTabsButtonColor: navigatorStyle.tabBarButtonColor,
97
-    selectedBottomTabsButtonColor: navigatorStyle.tabBarButtonColor
98
-  };
86
+  screen.styleParams = convertStyleParams(navigatorStyle);
99 87
 
100 88
   return _.omit(screen, ['navigatorStyle']);
101 89
 }
102 90
 
91
+function convertStyleParams(originalStyleObject) {
92
+  if (!originalStyleObject) {
93
+    return null;
94
+  }
95
+
96
+  return {
97
+    statusBarColor: originalStyleObject.statusBarColor,
98
+    topBarColor: originalStyleObject.toolBarColor,
99
+    navigationBarColor: originalStyleObject.navigationBarColor,
100
+    titleBarHidden: originalStyleObject.navBarHidden,
101
+    titleBarTitleColor: originalStyleObject.navBarTextColor,
102
+    backButtonHidden: originalStyleObject.backButtonHidden,
103
+    topTabsHidden: originalStyleObject.topTabsHidden,
104
+    bottomTabsHidden: originalStyleObject.tabBarHidden,
105
+    bottomTabsHiddenOnScroll: originalStyleObject.bottomTabsHiddenOnScroll,
106
+    drawBelowTopBar: !originalStyleObject.drawUnderNavBar,
107
+    bottomTabsColor: originalStyleObject.tabBarBackgroundColor,
108
+    bottomTabsButtonColor: originalStyleObject.tabBarButtonColor,
109
+    selectedBottomTabsButtonColor: originalStyleObject.tabBarSelectedButtonColor
110
+  }
111
+}
112
+
103 113
 function adaptNavigationParams(screen) {
104 114
   screen.navigationParams = {
105 115
     screenInstanceID: screen.screenInstanceID,
@@ -128,6 +138,12 @@ function startTabBasedApp(params) {
128 138
     tab.screen = adaptNavigationParams(tab);
129 139
   });
130 140
 
141
+  params.appStyle = convertStyleParams(params.appStyle);
142
+
143
+  console.log('appStyle.bottomTabsButtonColor', params.appStyle.bottomTabsButtonColor);
144
+  console.log('appStyle.bottomTabsColor', params.appStyle.bottomTabsColor);
145
+  console.log('appStyle.selectedBottomTabsButtonColor', params.appStyle.selectedBottomTabsButtonColor);
146
+
131 147
   // TODO: add drawer params
132 148
   newPlatformSpecific.startApp(params);
133 149
 }