Browse Source

Initial TitleBar setStyle

Guy Carmeli 8 years ago
parent
commit
6cbd51fe30

+ 10
- 6
android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java View File

26
     }
26
     }
27
 
27
 
28
     public void setStyleFromScreen(ScreenStyleParams params) {
28
     public void setStyleFromScreen(ScreenStyleParams params) {
29
-        if (params.bottomTabsColor.hasColor()) {
30
-            setDefaultBackgroundColor(params.bottomTabsColor.getColor());
31
-        } else {
32
-            setDefaultBackgroundColor(Color.WHITE);
33
-        }
29
+        setBackgroundColor(params.bottomTabsColor);
34
 
30
 
35
-//        setForceTitlesDisplay(true);
31
+        //        setForceTitlesDisplay(true);
36
 //        setInactiveColor(params.bottomTabsButtonColor.getColor());
32
 //        setInactiveColor(params.bottomTabsButtonColor.getColor());
37
 //        setAccentColor(params.selectedBottomTabsButtonColor.getColor());
33
 //        setAccentColor(params.selectedBottomTabsButtonColor.getColor());
38
     }
34
     }
35
+
36
+    private void setBackgroundColor(ScreenStyleParams.Color bottomTabsColor) {
37
+        if (bottomTabsColor.hasColor()) {
38
+            setDefaultBackgroundColor(bottomTabsColor.getColor());
39
+        } else {
40
+            setDefaultBackgroundColor(Color.WHITE);
41
+        }
42
+    }
39
 }
43
 }

+ 14
- 9
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java View File

5
 import android.view.Menu;
5
 import android.view.Menu;
6
 
6
 
7
 import com.reactnativenavigation.animation.VisibilityAnimator;
7
 import com.reactnativenavigation.animation.VisibilityAnimator;
8
+import com.reactnativenavigation.params.ScreenStyleParams;
8
 import com.reactnativenavigation.params.TitleBarButtonParams;
9
 import com.reactnativenavigation.params.TitleBarButtonParams;
9
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
10
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
10
 
11
 
31
         addButtonsToTitleBar(rightButtons, navigatorEventId, menu);
32
         addButtonsToTitleBar(rightButtons, navigatorEventId, menu);
32
     }
33
     }
33
 
34
 
35
+    public void setLeftButton(TitleBarLeftButtonParams leftButtonParams,
36
+                               TitleBarBackButtonListener titleBarBackButtonListener, String navigatorEventId) {
37
+        if (shouldSetLeftButton(leftButtonParams)) {
38
+            createAndSetLeftButton(leftButtonParams, titleBarBackButtonListener, navigatorEventId);
39
+        } else if (hasLeftButton()) {
40
+            updateLeftButton(leftButtonParams);
41
+        }
42
+    }
43
+
44
+    public void setStyle(ScreenStyleParams params) {
45
+        setVisibility(params.titleBarHidden ? GONE : VISIBLE);
46
+    }
47
+
34
     private void addButtonsToTitleBar(List<TitleBarButtonParams> rightButtons, String navigatorEventId, Menu menu) {
48
     private void addButtonsToTitleBar(List<TitleBarButtonParams> rightButtons, String navigatorEventId, Menu menu) {
35
         for (int i = 0; i < rightButtons.size(); i++) {
49
         for (int i = 0; i < rightButtons.size(); i++) {
36
             final TitleBarButton button = new TitleBarButton(menu, this, rightButtons.get(i), navigatorEventId);
50
             final TitleBarButton button = new TitleBarButton(menu, this, rightButtons.get(i), navigatorEventId);
43
         button.addToMenu(index);
57
         button.addToMenu(index);
44
     }
58
     }
45
 
59
 
46
-    public void setLeftButton(TitleBarLeftButtonParams leftButtonParams,
47
-                               TitleBarBackButtonListener titleBarBackButtonListener, String navigatorEventId) {
48
-        if (shouldSetLeftButton(leftButtonParams)) {
49
-            createAndSetLeftButton(leftButtonParams, titleBarBackButtonListener, navigatorEventId);
50
-        } else if (hasLeftButton()) {
51
-            updateLeftButton(leftButtonParams);
52
-        }
53
-    }
54
-
55
     private boolean hasLeftButton() {
60
     private boolean hasLeftButton() {
56
         return leftButton != null;
61
         return leftButton != null;
57
     }
62
     }

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

40
             setBackgroundColor(styleParams.topBarColor.getColor());
40
             setBackgroundColor(styleParams.topBarColor.getColor());
41
         }
41
         }
42
         setVisibility(styleParams.topBarHidden ? GONE : VISIBLE);
42
         setVisibility(styleParams.topBarHidden ? GONE : VISIBLE);
43
-        titleBar.setVisibility(styleParams.titleBarHidden ? GONE : VISIBLE);
43
+        titleBar.setStyle(styleParams);
44
     }
44
     }
45
 
45
 
46
     public void setTitleBarRightButtons(String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {
46
     public void setTitleBarRightButtons(String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {