|
@@ -1,16 +1,23 @@
|
1
|
1
|
package com.reactnativenavigation.layouts;
|
2
|
2
|
|
|
3
|
+import android.annotation.TargetApi;
|
|
4
|
+import android.app.Activity;
|
3
|
5
|
import android.content.Context;
|
|
6
|
+import android.graphics.Color;
|
|
7
|
+import android.os.Build;
|
4
|
8
|
import android.os.Bundle;
|
|
9
|
+import android.support.annotation.ColorInt;
|
|
10
|
+import android.view.Window;
|
5
|
11
|
import android.widget.LinearLayout;
|
6
|
12
|
|
7
|
13
|
import com.facebook.react.ReactInstanceManager;
|
8
|
14
|
import com.reactnativenavigation.controllers.ScreenParams;
|
9
|
15
|
import com.reactnativenavigation.controllers.ScreenStyleParams;
|
10
|
|
-import com.reactnativenavigation.views.TitleBarButton;
|
|
16
|
+import com.reactnativenavigation.utils.SdkSupports;
|
11
|
17
|
import com.reactnativenavigation.views.ContentView;
|
12
|
18
|
import com.reactnativenavigation.views.ScrollDirectionListener;
|
13
|
19
|
import com.reactnativenavigation.views.TitleBar;
|
|
20
|
+import com.reactnativenavigation.views.TitleBarButton;
|
14
|
21
|
|
15
|
22
|
import java.util.List;
|
16
|
23
|
|
|
@@ -62,16 +69,55 @@ public class ScreenLayout extends LinearLayout implements ScrollDirectionListene
|
62
|
69
|
|
63
|
70
|
private void setStyle(ScreenStyleParams styleParams) {
|
64
|
71
|
setStatusBarColor(styleParams.statusBarColor);
|
|
72
|
+ setTopBarColor(styleParams.topBarColor);
|
|
73
|
+ setNavigationBarColor(styleParams.navigationBarColor);
|
|
74
|
+ setTitleBarHidden(styleParams.titleBarHidden);
|
|
75
|
+ }
|
65
|
76
|
|
|
77
|
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
78
|
+ private void setStatusBarColor(@ColorInt int statusBarColor) {
|
|
79
|
+ if (!SdkSupports.lollipop()) {
|
|
80
|
+ return;
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ final Activity context = (Activity) getContext();
|
|
84
|
+ final Window window = context.getWindow();
|
|
85
|
+ if (statusBarColor > 0) {
|
|
86
|
+ window.setStatusBarColor(statusBarColor);
|
|
87
|
+ } else {
|
|
88
|
+ window.setStatusBarColor(Color.BLACK);
|
|
89
|
+ }
|
66
|
90
|
}
|
67
|
91
|
|
68
|
|
- private void setStatusBarColor(int statusBarColor) {
|
|
92
|
+ private void setTopBarColor(@ColorInt int topBarColor) {
|
|
93
|
+ if (topBarColor > 0) {
|
|
94
|
+ topBar.setBackgroundColor(topBarColor);
|
|
95
|
+ }
|
|
96
|
+ }
|
69
|
97
|
|
|
98
|
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
99
|
+ public void setNavigationBarColor(int navigationBarColor) {
|
|
100
|
+ if (!SdkSupports.lollipop()) {
|
|
101
|
+ return;
|
|
102
|
+ }
|
|
103
|
+
|
|
104
|
+ final Activity context = (Activity) getContext();
|
|
105
|
+ final Window window = context.getWindow();
|
|
106
|
+ if (navigationBarColor > 0) {
|
|
107
|
+ window.setNavigationBarColor(navigationBarColor);
|
|
108
|
+ } else {
|
|
109
|
+ window.setNavigationBarColor(Color.BLACK);
|
|
110
|
+ }
|
70
|
111
|
}
|
71
|
112
|
|
72
|
|
- private void
|
|
113
|
+ private void setTitleBarHidden(boolean titleBarHidden) {
|
|
114
|
+ if (titleBarHidden) {
|
|
115
|
+
|
|
116
|
+ }
|
|
117
|
+ }
|
73
|
118
|
|
74
|
119
|
@Override
|
75
|
120
|
public void onScrollChanged(ScrollDirectionListener.Direction direction) {
|
|
121
|
+
|
76
|
122
|
}
|
77
|
123
|
}
|