react-native-navigation 7.25.3 → 7.26.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java +9 -7
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/BottomTabOptions.java +0 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/OverlayOptions.java +2 -3
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/parsers/JSONParser.java +2 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenter.java +1 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java +4 -31
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildController.java +13 -6
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +46 -54
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/modal/ModalStack.java +0 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/navigator/Navigator.java +6 -20
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManager.kt +33 -104
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/parent/ParentController.java +9 -86
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuController.java +0 -12
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java +2 -19
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenter.java +244 -212
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/TopBarController.kt +22 -185
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonController.kt +5 -32
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonPresenter.kt +1 -9
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/RootPresenter.java +1 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewController.java +0 -12
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabs.java +1 -29
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabsContainer.kt +0 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabsLayout.java +1 -10
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/component/ComponentLayout.java +2 -10
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/sidemenu/SideMenuRoot.java +1 -9
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/StackLayout.java +4 -14
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/TopBar.java +1 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/ButtonBar.kt +12 -7
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleAndButtonsContainer.kt +2 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleSubTitleLayout.kt +7 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/toptabs/TopTabsStyleHelper.java +1 -0
- package/lib/dist/src/interfaces/Options.d.ts +0 -24
- package/lib/src/interfaces/Options.ts +0 -26
- package/package.json +1 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/OverlayOptions.kt +0 -31
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/overlay/AttachedOverlayContainer.kt +0 -69
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/overlay/ViewTooltip.java +0 -921
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
package com.reactnativenavigation.viewcontrollers.stack;
|
|
2
2
|
|
|
3
|
-
import static com.reactnativenavigation.utils.CollectionUtils.filter;
|
|
4
|
-
import static com.reactnativenavigation.utils.CollectionUtils.forEach;
|
|
5
|
-
import static com.reactnativenavigation.utils.CollectionUtils.isNullOrEmpty;
|
|
6
|
-
import static com.reactnativenavigation.utils.CollectionUtils.merge;
|
|
7
|
-
import static com.reactnativenavigation.utils.ObjectUtils.perform;
|
|
8
|
-
import static com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarControllerKt.DEFAULT_BORDER_COLOR;
|
|
9
|
-
|
|
10
3
|
import android.animation.Animator;
|
|
11
4
|
import android.app.Activity;
|
|
12
5
|
import android.graphics.Color;
|
|
13
|
-
import android.util.Pair;
|
|
14
|
-
import android.view.MenuItem;
|
|
15
6
|
import android.view.View;
|
|
16
|
-
import android.view.ViewGroup;
|
|
17
7
|
import android.view.ViewGroup.LayoutParams;
|
|
18
8
|
import android.view.ViewGroup.MarginLayoutParams;
|
|
19
9
|
import android.widget.FrameLayout;
|
|
@@ -51,26 +41,36 @@ import com.reactnativenavigation.viewcontrollers.viewcontroller.IReactView;
|
|
|
51
41
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
52
42
|
import com.reactnativenavigation.views.stack.topbar.TopBar;
|
|
53
43
|
import com.reactnativenavigation.views.stack.topbar.TopBarBackgroundViewCreator;
|
|
54
|
-
import com.reactnativenavigation.views.stack.topbar.titlebar.ButtonBar;
|
|
55
44
|
import com.reactnativenavigation.views.stack.topbar.titlebar.TitleBarButtonCreator;
|
|
56
45
|
import com.reactnativenavigation.views.stack.topbar.titlebar.TitleBarReactViewCreator;
|
|
57
46
|
|
|
58
47
|
import java.util.ArrayList;
|
|
59
|
-
import java.util.Collection;
|
|
60
48
|
import java.util.Collections;
|
|
61
49
|
import java.util.HashMap;
|
|
50
|
+
import java.util.LinkedHashMap;
|
|
62
51
|
import java.util.List;
|
|
63
52
|
import java.util.Map;
|
|
64
53
|
import java.util.Objects;
|
|
65
54
|
|
|
55
|
+
import static com.reactnativenavigation.utils.CollectionUtils.difference;
|
|
56
|
+
import static com.reactnativenavigation.utils.CollectionUtils.filter;
|
|
57
|
+
import static com.reactnativenavigation.utils.CollectionUtils.first;
|
|
58
|
+
import static com.reactnativenavigation.utils.CollectionUtils.forEach;
|
|
59
|
+
import static com.reactnativenavigation.utils.CollectionUtils.getOrDefault;
|
|
60
|
+
import static com.reactnativenavigation.utils.CollectionUtils.isNullOrEmpty;
|
|
61
|
+
import static com.reactnativenavigation.utils.CollectionUtils.keyBy;
|
|
62
|
+
import static com.reactnativenavigation.utils.CollectionUtils.merge;
|
|
63
|
+
import static com.reactnativenavigation.utils.ObjectUtils.perform;
|
|
64
|
+
import static com.reactnativenavigation.utils.ObjectUtils.take;
|
|
65
|
+
|
|
66
66
|
public class StackPresenter {
|
|
67
|
+
private static final int DEFAULT_BORDER_COLOR = Color.BLACK;
|
|
67
68
|
private static final double DEFAULT_ELEVATION = 4d;
|
|
68
69
|
private final Activity activity;
|
|
69
70
|
|
|
70
71
|
private TopBar topBar;
|
|
71
72
|
private TopBarController topBarController;
|
|
72
|
-
private @Nullable
|
|
73
|
-
BottomTabsController bottomTabsController;
|
|
73
|
+
private @Nullable BottomTabsController bottomTabsController;
|
|
74
74
|
private final TitleBarReactViewCreator titleViewCreator;
|
|
75
75
|
private ButtonController.OnClickListener onClickListener;
|
|
76
76
|
private final RenderChecker renderChecker;
|
|
@@ -78,21 +78,23 @@ public class StackPresenter {
|
|
|
78
78
|
private final TitleBarButtonCreator buttonCreator;
|
|
79
79
|
private Options defaultOptions;
|
|
80
80
|
|
|
81
|
+
private List<ButtonController> currentRightButtons = new ArrayList<>();
|
|
82
|
+
private List<ButtonController> currentLeftButtons = new ArrayList<>();
|
|
81
83
|
private final Map<View, TitleBarReactViewController> titleControllers = new HashMap();
|
|
82
84
|
private final Map<View, TopBarBackgroundViewController> backgroundControllers = new HashMap();
|
|
83
|
-
private final Map<View, Map<String, ButtonController>>
|
|
84
|
-
private final Map<View, Map<String, ButtonController>>
|
|
85
|
+
private final Map<View, Map<String, ButtonController>> componentRightButtons = new HashMap();
|
|
86
|
+
private final Map<View, Map<String, ButtonController>> componentLeftButtons = new HashMap();
|
|
85
87
|
private final IconResolver iconResolver;
|
|
86
88
|
private final TypefaceLoader typefaceLoader;
|
|
87
89
|
|
|
88
90
|
public StackPresenter(Activity activity,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
TitleBarReactViewCreator titleViewCreator,
|
|
92
|
+
TopBarBackgroundViewCreator topBarBackgroundViewCreator,
|
|
93
|
+
TitleBarButtonCreator buttonCreator,
|
|
94
|
+
IconResolver iconResolver,
|
|
95
|
+
TypefaceLoader typefaceLoader,
|
|
96
|
+
RenderChecker renderChecker,
|
|
97
|
+
Options defaultOptions) {
|
|
96
98
|
this.activity = activity;
|
|
97
99
|
this.titleViewCreator = titleViewCreator;
|
|
98
100
|
this.topBarBackgroundViewCreator = topBarBackgroundViewCreator;
|
|
@@ -123,31 +125,42 @@ public class StackPresenter {
|
|
|
123
125
|
|
|
124
126
|
public boolean isRendered(View component) {
|
|
125
127
|
ArrayList<ViewController<?>> controllers = new ArrayList<>();
|
|
126
|
-
controllers.addAll(perform(
|
|
127
|
-
controllers.addAll(perform(
|
|
128
|
+
controllers.addAll(perform(componentRightButtons.get(component), new ArrayList<>(), Map::values));
|
|
129
|
+
controllers.addAll(perform(componentLeftButtons.get(component), new ArrayList<>(), Map::values));
|
|
128
130
|
controllers.add(backgroundControllers.get(component));
|
|
129
131
|
controllers.add(titleControllers.get(component));
|
|
130
132
|
return renderChecker.areRendered(filter(controllers, ObjectUtils::notNull));
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
public void mergeOptions(Options options, StackController stack, ViewController<?> currentChild) {
|
|
134
|
-
TopBarOptions resolvedTopBarOptions = options.topBar.copy()
|
|
136
|
+
TopBarOptions resolvedTopBarOptions = options.topBar.copy()
|
|
137
|
+
.mergeWithDefault(stack.resolveChildOptions(currentChild).topBar)
|
|
138
|
+
.mergeWithDefault(defaultOptions.topBar);
|
|
135
139
|
mergeOrientation(options.layout.orientation);
|
|
140
|
+
// mergeButtons(topBar, withDefault.topBar.buttons, child);
|
|
136
141
|
mergeTopBarOptions(resolvedTopBarOptions, options, stack, currentChild);
|
|
137
142
|
mergeTopTabsOptions(options.topTabs);
|
|
138
143
|
mergeTopTabOptions(options.topTabOptions);
|
|
139
144
|
}
|
|
140
145
|
|
|
141
|
-
public void onConfigurationChanged(Options options
|
|
142
|
-
if (topBar == null)
|
|
146
|
+
public void onConfigurationChanged(Options options) {
|
|
147
|
+
if (topBar == null)
|
|
148
|
+
return;
|
|
143
149
|
Options withDefault = options.copy().withDefaultOptions(defaultOptions);
|
|
150
|
+
if (currentRightButtons != null && !currentRightButtons.isEmpty())
|
|
151
|
+
topBarController.applyRightButtons(currentRightButtons);
|
|
152
|
+
if (currentLeftButtons != null && !currentLeftButtons.isEmpty())
|
|
153
|
+
topBarController.applyLeftButtons(currentLeftButtons);
|
|
144
154
|
if (withDefault.topBar.buttons.back.visible.isTrue()) {
|
|
145
|
-
|
|
155
|
+
topBar.setBackButton(createButtonController(withDefault.topBar.buttons.back));
|
|
146
156
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
topBar.setOverflowButtonColor(withDefault.topBar.rightButtonColor.get(Color.BLACK));
|
|
158
|
+
topBar.applyTopTabsColors(withDefault.topTabs.selectedTabColor,
|
|
159
|
+
withDefault.topTabs.unselectedTabColor);
|
|
160
|
+
topBar.setBorderColor(withDefault.topBar.borderColor.get(DEFAULT_BORDER_COLOR));
|
|
161
|
+
topBar.setBackgroundColor(withDefault.topBar.background.color.get(Color.WHITE));
|
|
162
|
+
topBar.setTitleTextColor(withDefault.topBar.title.color.get(TopBar.DEFAULT_TITLE_COLOR));
|
|
163
|
+
topBar.setSubtitleColor(withDefault.topBar.subtitle.color.get(TopBar.DEFAULT_TITLE_COLOR));
|
|
151
164
|
}
|
|
152
165
|
|
|
153
166
|
public void applyInitialChildLayoutOptions(Options options) {
|
|
@@ -172,14 +185,15 @@ public class StackPresenter {
|
|
|
172
185
|
public void onChildDestroyed(ViewController<?> child) {
|
|
173
186
|
perform(titleControllers.remove(child.getView()), TitleBarReactViewController::destroy);
|
|
174
187
|
perform(backgroundControllers.remove(child.getView()), TopBarBackgroundViewController::destroy);
|
|
175
|
-
destroyButtons(
|
|
176
|
-
destroyButtons(
|
|
177
|
-
|
|
178
|
-
|
|
188
|
+
destroyButtons(componentRightButtons.get(child.getView()));
|
|
189
|
+
destroyButtons(componentLeftButtons.get(child.getView()));
|
|
190
|
+
componentRightButtons.remove(child.getView());
|
|
191
|
+
componentLeftButtons.remove(child.getView());
|
|
179
192
|
}
|
|
180
193
|
|
|
181
194
|
private void destroyButtons(@Nullable Map<String, ButtonController> buttons) {
|
|
182
|
-
if (buttons != null)
|
|
195
|
+
if (buttons != null)
|
|
196
|
+
forEach(buttons.values(), ViewController::destroy);
|
|
183
197
|
}
|
|
184
198
|
|
|
185
199
|
private void applyTopBarOptions(Options options, StackController stack, ViewController<?> child) {
|
|
@@ -193,7 +207,8 @@ public class StackPresenter {
|
|
|
193
207
|
applyStatusBarDrawBehindOptions(topBarOptions, withDefault);
|
|
194
208
|
topBar.setElevation(topBarOptions.elevation.get(DEFAULT_ELEVATION));
|
|
195
209
|
if (topBarOptions.topMargin.hasValue() && topBar.getLayoutParams() instanceof MarginLayoutParams) {
|
|
196
|
-
((MarginLayoutParams) topBar.getLayoutParams()).topMargin = UiUtils.dpToPx(activity,
|
|
210
|
+
((MarginLayoutParams) topBar.getLayoutParams()).topMargin = UiUtils.dpToPx(activity,
|
|
211
|
+
topBarOptions.topMargin.get(0));
|
|
197
212
|
}
|
|
198
213
|
|
|
199
214
|
topBar.setTitleHeight(topBarOptions.title.height.get(UiUtils.getTopBarHeightDp(activity)));
|
|
@@ -203,7 +218,8 @@ public class StackPresenter {
|
|
|
203
218
|
if (titleControllers.containsKey(component)) {
|
|
204
219
|
topBarController.setTitleComponent(Objects.requireNonNull(titleControllers.get(component)));
|
|
205
220
|
} else {
|
|
206
|
-
TitleBarReactViewController controller = new TitleBarReactViewController(activity, titleViewCreator,
|
|
221
|
+
TitleBarReactViewController controller = new TitleBarReactViewController(activity, titleViewCreator,
|
|
222
|
+
topBarOptions.title.component);
|
|
207
223
|
controller.setWaitForRender(topBarOptions.title.component.waitForRender);
|
|
208
224
|
titleControllers.put(component, controller);
|
|
209
225
|
topBarController.setTitleComponent(controller);
|
|
@@ -215,7 +231,6 @@ public class StackPresenter {
|
|
|
215
231
|
topBarController.alignTitleComponent(topBarOptions.title.alignment);
|
|
216
232
|
}
|
|
217
233
|
|
|
218
|
-
|
|
219
234
|
topBar.setBorderHeight(topBarOptions.borderHeight.get(0d));
|
|
220
235
|
topBar.setBorderColor(topBarOptions.borderColor.get(DEFAULT_BORDER_COLOR));
|
|
221
236
|
topBar.setBackgroundColor(topBarOptions.background.color.get(Color.WHITE));
|
|
@@ -225,11 +240,13 @@ public class StackPresenter {
|
|
|
225
240
|
if (createdComponent != null) {
|
|
226
241
|
topBar.setBackgroundComponent(createdComponent);
|
|
227
242
|
} else {
|
|
228
|
-
TopBarBackgroundViewController controller = new TopBarBackgroundViewController(activity,
|
|
243
|
+
TopBarBackgroundViewController controller = new TopBarBackgroundViewController(activity,
|
|
244
|
+
topBarBackgroundViewCreator);
|
|
229
245
|
controller.setWaitForRender(topBarOptions.background.waitForRender);
|
|
230
246
|
backgroundControllers.put(component, controller);
|
|
231
247
|
controller.setComponent(topBarOptions.background.component);
|
|
232
|
-
controller.getView().setLayoutParams(new RelativeLayout.LayoutParams(
|
|
248
|
+
controller.getView().setLayoutParams(new RelativeLayout.LayoutParams(
|
|
249
|
+
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
|
233
250
|
topBar.setBackgroundComponent(controller.getView());
|
|
234
251
|
}
|
|
235
252
|
} else {
|
|
@@ -249,30 +266,33 @@ public class StackPresenter {
|
|
|
249
266
|
private void applyStatusBarDrawBehindOptions(TopBarOptions topBarOptions, Options withDefault) {
|
|
250
267
|
if (withDefault.statusBar.visible.isTrueOrUndefined() && withDefault.statusBar.drawBehind.isTrue()) {
|
|
251
268
|
topBar.setTopPadding(SystemUiUtils.getStatusBarHeight(activity));
|
|
252
|
-
topBar.setHeight(topBarOptions.height.get(UiUtils.getTopBarHeightDp(activity))
|
|
269
|
+
topBar.setHeight(topBarOptions.height.get(UiUtils.getTopBarHeightDp(activity))
|
|
270
|
+
+ SystemUiUtils.getStatusBarHeightDp(activity));
|
|
253
271
|
|
|
254
272
|
} else {
|
|
255
273
|
topBar.setTopPadding(0);
|
|
256
274
|
topBar.setHeight(topBarOptions.height.get(UiUtils.getTopBarHeightDp(activity)));
|
|
257
275
|
}
|
|
258
276
|
}
|
|
259
|
-
|
|
277
|
+
|
|
260
278
|
private void mergeStatusBarDrawBehindOptions(TopBarOptions topBarOptions, Options childOptions) {
|
|
261
|
-
if(childOptions.statusBar.visible.isTrueOrUndefined()){
|
|
279
|
+
if (childOptions.statusBar.visible.isTrueOrUndefined()) {
|
|
262
280
|
if (childOptions.statusBar.drawBehind.hasValue()) {
|
|
263
281
|
if (childOptions.statusBar.drawBehind.isTrue()) {
|
|
264
282
|
topBar.setTopPadding(SystemUiUtils.getStatusBarHeight(activity));
|
|
265
|
-
topBar.setHeight(topBarOptions.height.get(UiUtils.getTopBarHeightDp(activity))
|
|
283
|
+
topBar.setHeight(topBarOptions.height.get(UiUtils.getTopBarHeightDp(activity))
|
|
284
|
+
+ SystemUiUtils.getStatusBarHeightDp(activity));
|
|
266
285
|
} else {
|
|
267
286
|
topBar.setTopPadding(0);
|
|
268
287
|
topBar.setHeight(topBarOptions.height.get(UiUtils.getTopBarHeightDp(activity)));
|
|
269
288
|
}
|
|
270
289
|
}
|
|
271
|
-
}else{
|
|
290
|
+
} else {
|
|
272
291
|
if (childOptions.statusBar.drawBehind.hasValue()) {
|
|
273
292
|
if (childOptions.statusBar.drawBehind.isFalseOrUndefined()) {
|
|
274
293
|
topBar.setTopPadding(SystemUiUtils.getStatusBarHeight(activity));
|
|
275
|
-
topBar.setHeight(topBarOptions.height.get(UiUtils.getTopBarHeightDp(activity))
|
|
294
|
+
topBar.setHeight(topBarOptions.height.get(UiUtils.getTopBarHeightDp(activity))
|
|
295
|
+
+ SystemUiUtils.getStatusBarHeightDp(activity));
|
|
276
296
|
} else {
|
|
277
297
|
topBar.setTopPadding(0);
|
|
278
298
|
topBar.setHeight(topBarOptions.height.get(UiUtils.getTopBarHeightDp(activity)));
|
|
@@ -286,15 +306,18 @@ public class StackPresenter {
|
|
|
286
306
|
private View findBackgroundComponent(ComponentOptions component) {
|
|
287
307
|
for (TopBarBackgroundViewController controller : backgroundControllers.values()) {
|
|
288
308
|
if (ObjectUtils.equalsNotNull(controller.getComponent().name.get(null), component.name.get(null)) &&
|
|
289
|
-
ObjectUtils.equalsNotNull(controller.getComponent().componentId.get(null),
|
|
309
|
+
ObjectUtils.equalsNotNull(controller.getComponent().componentId.get(null),
|
|
310
|
+
component.componentId.get(null))) {
|
|
290
311
|
return controller.getView();
|
|
291
312
|
}
|
|
292
313
|
}
|
|
293
314
|
return null;
|
|
294
315
|
}
|
|
295
316
|
|
|
296
|
-
private void applyTopBarVisibilityIfChildIsNotBeingAnimated(TopBarOptions options, StackController stack,
|
|
297
|
-
|
|
317
|
+
private void applyTopBarVisibilityIfChildIsNotBeingAnimated(TopBarOptions options, StackController stack,
|
|
318
|
+
ViewController<?> child) {
|
|
319
|
+
if (!stack.isChildInTransition(child) || options.animate.isFalse())
|
|
320
|
+
applyTopBarVisibility(options);
|
|
298
321
|
}
|
|
299
322
|
|
|
300
323
|
private void applyTopBarVisibility(TopBarOptions options) {
|
|
@@ -307,30 +330,75 @@ public class StackPresenter {
|
|
|
307
330
|
}
|
|
308
331
|
|
|
309
332
|
private void applyButtons(TopBarOptions options, ViewController<?> child) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
333
|
+
if (options.buttons.right != null) {
|
|
334
|
+
List<ButtonOptions> rightButtons = mergeButtonsWithColor(options.buttons.right,
|
|
335
|
+
options.rightButtonColor, options.rightButtonDisabledColor);
|
|
336
|
+
List<ButtonController> rightButtonControllers = getOrCreateButtonControllersByInstanceId(
|
|
337
|
+
componentRightButtons.get(child.getView()), rightButtons);
|
|
338
|
+
componentRightButtons.put(child.getView(),
|
|
339
|
+
keyBy(rightButtonControllers, ButtonController::getButtonInstanceId));
|
|
340
|
+
if (!CollectionUtils.equals(currentRightButtons, rightButtonControllers)) {
|
|
341
|
+
currentRightButtons = rightButtonControllers;
|
|
342
|
+
topBarController.applyRightButtons(currentRightButtons);
|
|
343
|
+
}
|
|
344
|
+
} else {
|
|
345
|
+
currentRightButtons = null;
|
|
346
|
+
topBar.clearRightButtons();
|
|
347
|
+
}
|
|
317
348
|
|
|
318
|
-
|
|
349
|
+
if (options.buttons.left != null) {
|
|
350
|
+
List<ButtonOptions> leftButtons = mergeButtonsWithColor(options.buttons.left,
|
|
351
|
+
options.leftButtonColor,
|
|
352
|
+
options.leftButtonDisabledColor);
|
|
353
|
+
List<ButtonController> leftButtonControllers = getOrCreateButtonControllersByInstanceId(
|
|
354
|
+
componentLeftButtons.get(child.getView()), leftButtons);
|
|
355
|
+
componentLeftButtons.put(child.getView(),
|
|
356
|
+
keyBy(leftButtonControllers, ButtonController::getButtonInstanceId));
|
|
357
|
+
if (!CollectionUtils.equals(currentLeftButtons, leftButtonControllers)) {
|
|
358
|
+
currentLeftButtons = leftButtonControllers;
|
|
359
|
+
topBarController.applyLeftButtons(currentLeftButtons);
|
|
360
|
+
}
|
|
361
|
+
} else {
|
|
362
|
+
currentLeftButtons = null;
|
|
363
|
+
topBar.clearLeftButtons();
|
|
364
|
+
}
|
|
319
365
|
|
|
320
366
|
if (options.buttons.back.visible.isTrue() && !options.buttons.hasLeftButtons()) {
|
|
321
|
-
|
|
367
|
+
topBar.setBackButton(createButtonController(options.buttons.back));
|
|
322
368
|
}
|
|
323
|
-
|
|
369
|
+
if (options.animateRightButtons.hasValue())
|
|
370
|
+
topBar.animateRightButtons(options.animateRightButtons.isTrue());
|
|
371
|
+
if (options.animateLeftButtons.hasValue())
|
|
372
|
+
topBar.animateLeftButtons(options.animateLeftButtons.isTrue());
|
|
324
373
|
topBar.setOverflowButtonColor(options.rightButtonColor.get(Color.BLACK));
|
|
325
374
|
}
|
|
326
375
|
|
|
376
|
+
private List<ButtonController> getOrCreateButtonControllersByInstanceId(
|
|
377
|
+
@Nullable Map<String, ButtonController> currentButtons, @Nullable List<ButtonOptions> buttons) {
|
|
378
|
+
if (buttons == null)
|
|
379
|
+
return null;
|
|
380
|
+
Map<String, ButtonController> result = new LinkedHashMap<>();
|
|
381
|
+
forEach(buttons, b -> result.put(b.instanceId,
|
|
382
|
+
getOrDefault(currentButtons, b.instanceId, () -> createButtonController(b))));
|
|
383
|
+
return new ArrayList<>(result.values());
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
private List<ButtonController> getOrCreateButtonControllers(@Nullable Map<String, ButtonController> currentButtons,
|
|
387
|
+
@NonNull List<ButtonOptions> buttons) {
|
|
388
|
+
ArrayList<ButtonController> result = new ArrayList<>();
|
|
389
|
+
for (ButtonOptions b : buttons) {
|
|
390
|
+
result.add(take(first(perform(currentButtons, null, Map::values), button -> button.getButton().equals(b)),
|
|
391
|
+
createButtonController(b)));
|
|
392
|
+
}
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
395
|
+
|
|
327
396
|
private ButtonController createButtonController(ButtonOptions button) {
|
|
328
397
|
ButtonController controller = new ButtonController(activity,
|
|
329
398
|
new ButtonPresenter(activity, button, iconResolver),
|
|
330
399
|
button,
|
|
331
400
|
buttonCreator,
|
|
332
|
-
onClickListener
|
|
333
|
-
);
|
|
401
|
+
onClickListener);
|
|
334
402
|
controller.setWaitForRender(button.component.waitForRender);
|
|
335
403
|
return controller;
|
|
336
404
|
}
|
|
@@ -349,28 +417,32 @@ public class StackPresenter {
|
|
|
349
417
|
}
|
|
350
418
|
}
|
|
351
419
|
|
|
352
|
-
public List<Animator> getAdditionalPushAnimations(StackController stack, ViewController<?> appearing,
|
|
420
|
+
public List<Animator> getAdditionalPushAnimations(StackController stack, ViewController<?> appearing,
|
|
421
|
+
Options appearingOptions) {
|
|
353
422
|
return CollectionUtils.asList(
|
|
354
|
-
topBarController.getPushAnimation(appearingOptions,
|
|
355
|
-
|
|
356
|
-
|
|
423
|
+
topBarController.getPushAnimation(appearingOptions,
|
|
424
|
+
getTopBarTranslationAnimationDelta(stack, appearing)),
|
|
425
|
+
perform(bottomTabsController, null, btc -> btc.getPushAnimation(appearingOptions)));
|
|
357
426
|
}
|
|
358
427
|
|
|
359
428
|
public List<Animator> getAdditionalPopAnimations(Options appearingOptions, Options disappearingOptions) {
|
|
360
429
|
return CollectionUtils.asList(
|
|
361
430
|
topBarController.getPopAnimation(appearingOptions, disappearingOptions),
|
|
362
|
-
perform(bottomTabsController, null, btc -> btc.getPopAnimation(appearingOptions, disappearingOptions))
|
|
363
|
-
);
|
|
431
|
+
perform(bottomTabsController, null, btc -> btc.getPopAnimation(appearingOptions, disappearingOptions)));
|
|
364
432
|
}
|
|
365
433
|
|
|
366
|
-
public List<Animator> getAdditionalSetRootAnimations(StackController stack, ViewController<?> appearing,
|
|
434
|
+
public List<Animator> getAdditionalSetRootAnimations(StackController stack, ViewController<?> appearing,
|
|
435
|
+
Options appearingOptions) {
|
|
367
436
|
return CollectionUtils.asList(
|
|
368
|
-
topBarController.getSetStackRootAnimation(appearingOptions,
|
|
369
|
-
|
|
370
|
-
|
|
437
|
+
topBarController.getSetStackRootAnimation(appearingOptions,
|
|
438
|
+
getTopBarTranslationAnimationDelta(stack, appearing)),
|
|
439
|
+
perform(bottomTabsController, null, btc -> btc.getSetStackRootAnimation(appearingOptions)));
|
|
371
440
|
}
|
|
372
|
-
|
|
373
|
-
|
|
441
|
+
|
|
442
|
+
public void mergeChildOptions(Options toMerge, Options resolvedOptions, StackController stack,
|
|
443
|
+
ViewController<?> child) {
|
|
444
|
+
TopBarOptions topBar = toMerge.copy().topBar.mergeWithDefault(resolvedOptions.topBar)
|
|
445
|
+
.mergeWithDefault(defaultOptions.topBar);
|
|
374
446
|
mergeOrientation(toMerge.layout.orientation);
|
|
375
447
|
mergeButtons(topBar, toMerge.topBar, child.getView(), stack);
|
|
376
448
|
mergeTopBarOptions(topBar, toMerge, stack, child);
|
|
@@ -379,17 +451,13 @@ public class StackPresenter {
|
|
|
379
451
|
}
|
|
380
452
|
|
|
381
453
|
private void mergeOrientation(OrientationOptions orientationOptions) {
|
|
382
|
-
if (orientationOptions.hasValue())
|
|
454
|
+
if (orientationOptions.hasValue())
|
|
455
|
+
applyOrientation(orientationOptions);
|
|
383
456
|
}
|
|
384
457
|
|
|
385
458
|
private void mergeButtons(TopBarOptions options, TopBarOptions optionsToMerge, View child, StackController stack) {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
if (optionsToMerge.animateLeftButtons.hasValue())
|
|
389
|
-
topBarController.animateLeftButtons(optionsToMerge.animateLeftButtons.isTrue());
|
|
390
|
-
|
|
391
|
-
mergeRightButtonsOptions(options, optionsToMerge.buttons, child);
|
|
392
|
-
mergeLeftButtonsOptions(options, optionsToMerge.buttons, child);
|
|
459
|
+
mergeRightButtons(options, optionsToMerge.buttons, child);
|
|
460
|
+
mergeLeftButton(options, optionsToMerge.buttons, child);
|
|
393
461
|
mergeLeftButtonsColor(child, optionsToMerge.leftButtonColor, optionsToMerge.leftButtonDisabledColor);
|
|
394
462
|
mergeRightButtonsColor(child, optionsToMerge.rightButtonColor, optionsToMerge.rightButtonDisabledColor);
|
|
395
463
|
mergeBackButton(optionsToMerge.buttons, stack);
|
|
@@ -397,7 +465,7 @@ public class StackPresenter {
|
|
|
397
465
|
|
|
398
466
|
private void mergeLeftButtonsColor(View child, ThemeColour color, ThemeColour disabledColor) {
|
|
399
467
|
if (color.hasValue() || disabledColor.hasValue()) {
|
|
400
|
-
Map<String, ButtonController> stringButtonControllerMap =
|
|
468
|
+
Map<String, ButtonController> stringButtonControllerMap = componentLeftButtons.get(child);
|
|
401
469
|
if (stringButtonControllerMap != null) {
|
|
402
470
|
forEach(stringButtonControllerMap.values(), (btnController) -> {
|
|
403
471
|
if (color.hasValue()) {
|
|
@@ -413,7 +481,7 @@ public class StackPresenter {
|
|
|
413
481
|
|
|
414
482
|
private void mergeRightButtonsColor(View child, ThemeColour color, ThemeColour disabledColor) {
|
|
415
483
|
if (color.hasValue() || disabledColor.hasValue()) {
|
|
416
|
-
Map<String, ButtonController> stringButtonControllerMap =
|
|
484
|
+
Map<String, ButtonController> stringButtonControllerMap = componentRightButtons.get(child);
|
|
417
485
|
if (stringButtonControllerMap != null) {
|
|
418
486
|
forEach(stringButtonControllerMap.values(), (btnController) -> {
|
|
419
487
|
if (color.hasValue()) {
|
|
@@ -427,96 +495,87 @@ public class StackPresenter {
|
|
|
427
495
|
}
|
|
428
496
|
}
|
|
429
497
|
|
|
430
|
-
private void
|
|
431
|
-
if (
|
|
432
|
-
|
|
433
|
-
options.leftButtonColor
|
|
434
|
-
, options.leftButtonDisabledColor);
|
|
435
|
-
final ViewGroup childView = child.getView();
|
|
436
|
-
final Map<String, ButtonController> btnControllers = getOrCreateButtonControllerMap(childView, leftButtonControllers);
|
|
437
|
-
topBarController.applyLeftButtonsOptions(btnControllers, leftButtons, this::createButtonController);
|
|
438
|
-
} else {
|
|
439
|
-
topBarController.clearLeftButtons();
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
private void applyRightButtonsOptions(TopBarOptions options, ViewController<?> child) {
|
|
444
|
-
if (options.buttons.right != null) {
|
|
445
|
-
List<ButtonOptions> rightButtons = mergeButtonsWithColor(options.buttons.right,
|
|
446
|
-
options.rightButtonColor
|
|
447
|
-
, options.rightButtonDisabledColor);
|
|
448
|
-
final ViewGroup childView = child.getView();
|
|
449
|
-
final Map<String, ButtonController> btnControllers = getOrCreateButtonControllerMap(childView, rightButtonControllers);
|
|
450
|
-
topBarController.applyRightButtonsOptions(btnControllers, rightButtons, this::createButtonController);
|
|
451
|
-
} else {
|
|
452
|
-
topBarController.clearRightButtons();
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
private void mergeRightButtonsOptions(TopBarOptions options, TopBarButtons buttons, View child) {
|
|
457
|
-
if (buttons.right == null) return;
|
|
498
|
+
private void mergeRightButtons(TopBarOptions options, TopBarButtons buttons, View child) {
|
|
499
|
+
if (buttons.right == null)
|
|
500
|
+
return;
|
|
458
501
|
List<ButtonOptions> rightButtons = mergeButtonsWithColor(buttons.right, options.rightButtonColor,
|
|
459
502
|
options.rightButtonDisabledColor);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
503
|
+
List<ButtonController> toMerge = getOrCreateButtonControllers(componentRightButtons.get(child), rightButtons);
|
|
504
|
+
List<ButtonController> toRemove = difference(currentRightButtons, toMerge, ButtonController::areButtonsEqual);
|
|
505
|
+
forEach(toRemove, ButtonController::destroy);
|
|
506
|
+
|
|
507
|
+
if (!CollectionUtils.equals(currentRightButtons, toMerge)) {
|
|
508
|
+
componentRightButtons.put(child, keyBy(toMerge, ButtonController::getButtonInstanceId));
|
|
509
|
+
topBarController.mergeRightButtons(toMerge, toRemove);
|
|
510
|
+
currentRightButtons = toMerge;
|
|
511
|
+
}
|
|
512
|
+
if (options.rightButtonColor.hasValue())
|
|
513
|
+
topBar.setOverflowButtonColor(options.rightButtonColor.get());
|
|
463
514
|
}
|
|
464
515
|
|
|
465
|
-
private void
|
|
466
|
-
if (buttons.left == null)
|
|
516
|
+
private void mergeLeftButton(TopBarOptions options, TopBarButtons buttons, View child) {
|
|
517
|
+
if (buttons.left == null)
|
|
518
|
+
return;
|
|
467
519
|
List<ButtonOptions> leftButtons = mergeButtonsWithColor(buttons.left, options.leftButtonColor,
|
|
468
520
|
options.leftButtonDisabledColor);
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
final Map<String, ButtonController> btnControllers = controllerMap != null ? controllerMap : new HashMap<>();
|
|
478
|
-
if (controllerMap == null)
|
|
479
|
-
buttonControllers.put(child, btnControllers);
|
|
480
|
-
return btnControllers;
|
|
521
|
+
List<ButtonController> toMerge = getOrCreateButtonControllers(componentLeftButtons.get(child), leftButtons);
|
|
522
|
+
List<ButtonController> toRemove = difference(currentLeftButtons, toMerge, ButtonController::areButtonsEqual);
|
|
523
|
+
forEach(toRemove, ButtonController::destroy);
|
|
524
|
+
if (!CollectionUtils.equals(currentLeftButtons, toMerge)) {
|
|
525
|
+
componentLeftButtons.put(child, keyBy(toMerge, ButtonController::getButtonInstanceId));
|
|
526
|
+
topBarController.mergeLeftButtons(toMerge, toRemove);
|
|
527
|
+
currentLeftButtons = toMerge;
|
|
528
|
+
}
|
|
481
529
|
}
|
|
482
530
|
|
|
483
531
|
private void mergeBackButton(TopBarButtons buttons, StackController stack) {
|
|
484
532
|
if (buttons.back.hasValue() && isNullOrEmpty(buttons.left)) {
|
|
485
533
|
if (buttons.back.visible.isFalse()) {
|
|
486
|
-
|
|
534
|
+
topBar.clearBackButton();
|
|
487
535
|
} else if (stack.size() > 1) {
|
|
488
|
-
|
|
536
|
+
topBar.setBackButton(createButtonController(buttons.back));
|
|
489
537
|
}
|
|
490
538
|
}
|
|
491
539
|
}
|
|
492
540
|
|
|
493
541
|
private List<ButtonOptions> mergeButtonsWithColor(@NonNull List<ButtonOptions> buttons, ThemeColour buttonColor,
|
|
494
|
-
|
|
542
|
+
ThemeColour disabledColor) {
|
|
495
543
|
List<ButtonOptions> result = new ArrayList<>();
|
|
496
544
|
for (ButtonOptions button : buttons) {
|
|
497
545
|
ButtonOptions copy = button.copy();
|
|
498
|
-
if (!button.color.hasValue())
|
|
499
|
-
|
|
546
|
+
if (!button.color.hasValue())
|
|
547
|
+
copy.color = buttonColor;
|
|
548
|
+
if (!button.disabledColor.hasValue())
|
|
549
|
+
copy.disabledColor = disabledColor;
|
|
500
550
|
result.add(copy);
|
|
501
551
|
}
|
|
502
552
|
return result;
|
|
503
553
|
}
|
|
504
554
|
|
|
505
555
|
private void mergeTopBarOptions(TopBarOptions resolveOptions, Options toMerge, StackController stack,
|
|
506
|
-
|
|
556
|
+
ViewController<?> child) {
|
|
507
557
|
TopBarOptions topBarOptions = toMerge.topBar;
|
|
508
558
|
final View component = child.getView();
|
|
509
|
-
if (toMerge.layout.direction.hasValue())
|
|
510
|
-
|
|
511
|
-
if (topBarOptions.
|
|
559
|
+
if (toMerge.layout.direction.hasValue())
|
|
560
|
+
topBar.setLayoutDirection(toMerge.layout.direction);
|
|
561
|
+
if (topBarOptions.height.hasValue())
|
|
562
|
+
topBar.setHeight(topBarOptions.height.get());
|
|
563
|
+
if (topBarOptions.elevation.hasValue())
|
|
564
|
+
topBar.setElevation(topBarOptions.elevation.get());
|
|
512
565
|
if (topBarOptions.topMargin.hasValue() && topBar.getLayoutParams() instanceof MarginLayoutParams) {
|
|
513
|
-
((MarginLayoutParams) topBar.getLayoutParams()).topMargin = UiUtils.dpToPx(activity,
|
|
566
|
+
((MarginLayoutParams) topBar.getLayoutParams()).topMargin = UiUtils.dpToPx(activity,
|
|
567
|
+
topBarOptions.topMargin.get());
|
|
514
568
|
}
|
|
515
569
|
Options childOptions = stack.resolveChildOptions(child).mergeWith(toMerge).withDefaultOptions(defaultOptions);
|
|
516
570
|
mergeStatusBarDrawBehindOptions(resolveOptions, childOptions);
|
|
517
|
-
if (topBarOptions.title.height.hasValue())
|
|
518
|
-
|
|
519
|
-
|
|
571
|
+
if (topBarOptions.title.height.hasValue())
|
|
572
|
+
topBar.setTitleHeight(topBarOptions.title.height.get());
|
|
573
|
+
if (topBarOptions.title.topMargin.hasValue())
|
|
574
|
+
topBar.setTitleTopMargin(topBarOptions.title.topMargin.get());
|
|
575
|
+
if (topBarOptions.animateLeftButtons.hasValue())
|
|
576
|
+
topBar.animateLeftButtons(topBarOptions.animateLeftButtons.isTrue());
|
|
577
|
+
if (topBarOptions.animateRightButtons.hasValue())
|
|
578
|
+
topBar.animateRightButtons(topBarOptions.animateRightButtons.isTrue());
|
|
520
579
|
if (topBarOptions.title.component.hasValue()) {
|
|
521
580
|
TitleBarReactViewController controller = findTitleComponent(topBarOptions.title.component);
|
|
522
581
|
if (controller == null) {
|
|
@@ -534,15 +593,19 @@ public class StackPresenter {
|
|
|
534
593
|
topBarController.alignTitleComponent(resolveOptions.title.alignment);
|
|
535
594
|
}
|
|
536
595
|
|
|
537
|
-
if (resolveOptions.title.color.hasValue())
|
|
538
|
-
|
|
539
|
-
if (resolveOptions.title.
|
|
596
|
+
if (resolveOptions.title.color.hasValue())
|
|
597
|
+
topBar.setTitleTextColor(resolveOptions.title.color.get());
|
|
598
|
+
if (resolveOptions.title.fontSize.hasValue())
|
|
599
|
+
topBar.setTitleFontSize(resolveOptions.title.fontSize.get());
|
|
600
|
+
if (resolveOptions.title.font.hasValue())
|
|
601
|
+
topBar.setTitleTypeface(typefaceLoader, resolveOptions.title.font);
|
|
540
602
|
|
|
541
603
|
if (resolveOptions.subtitle.text.hasValue()) {
|
|
542
604
|
topBar.setSubtitle(resolveOptions.subtitle.text.get());
|
|
543
605
|
topBar.setSubtitleAlignment(resolveOptions.subtitle.alignment);
|
|
544
606
|
}
|
|
545
|
-
if (resolveOptions.subtitle.color.hasValue())
|
|
607
|
+
if (resolveOptions.subtitle.color.hasValue())
|
|
608
|
+
topBar.setSubtitleColor(resolveOptions.subtitle.color.get());
|
|
546
609
|
if (resolveOptions.subtitle.fontSize.hasValue()) {
|
|
547
610
|
topBar.setSubtitleFontSize(resolveOptions.subtitle.fontSize.get());
|
|
548
611
|
}
|
|
@@ -550,21 +613,25 @@ public class StackPresenter {
|
|
|
550
613
|
topBar.setSubtitleTypeface(typefaceLoader, resolveOptions.subtitle.font);
|
|
551
614
|
}
|
|
552
615
|
|
|
553
|
-
if (topBarOptions.background.color.hasValue())
|
|
616
|
+
if (topBarOptions.background.color.hasValue())
|
|
617
|
+
topBar.setBackgroundColor(topBarOptions.background.color.get());
|
|
554
618
|
|
|
555
619
|
if (topBarOptions.background.component.hasValue()) {
|
|
556
620
|
if (backgroundControllers.containsKey(component)) {
|
|
557
621
|
topBar.setBackgroundComponent(Objects.requireNonNull(backgroundControllers.get(component)).getView());
|
|
558
622
|
} else {
|
|
559
|
-
TopBarBackgroundViewController controller = new TopBarBackgroundViewController(activity,
|
|
623
|
+
TopBarBackgroundViewController controller = new TopBarBackgroundViewController(activity,
|
|
624
|
+
topBarBackgroundViewCreator);
|
|
560
625
|
backgroundControllers.put(component, controller);
|
|
561
626
|
controller.setComponent(topBarOptions.background.component);
|
|
562
|
-
controller.getView().setLayoutParams(new RelativeLayout.LayoutParams(
|
|
627
|
+
controller.getView().setLayoutParams(new RelativeLayout.LayoutParams(
|
|
628
|
+
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
|
563
629
|
topBar.setBackgroundComponent(controller.getView());
|
|
564
630
|
}
|
|
565
631
|
}
|
|
566
632
|
|
|
567
|
-
if (topBarOptions.testId.hasValue())
|
|
633
|
+
if (topBarOptions.testId.hasValue())
|
|
634
|
+
topBar.setTestId(topBarOptions.testId.get());
|
|
568
635
|
|
|
569
636
|
if (topBarOptions.visible.isFalse()) {
|
|
570
637
|
if (topBarOptions.animate.isTrueOrUndefined()) {
|
|
@@ -591,7 +658,8 @@ public class StackPresenter {
|
|
|
591
658
|
private TitleBarReactViewController findTitleComponent(ComponentOptions component) {
|
|
592
659
|
for (TitleBarReactViewController controller : titleControllers.values()) {
|
|
593
660
|
if (ObjectUtils.equalsNotNull(controller.getComponent().name.get(null), component.name.get(null)) &&
|
|
594
|
-
ObjectUtils.equalsNotNull(controller.getComponent().componentId.get(null),
|
|
661
|
+
ObjectUtils.equalsNotNull(controller.getComponent().componentId.get(null),
|
|
662
|
+
component.componentId.get(null))) {
|
|
595
663
|
return controller;
|
|
596
664
|
}
|
|
597
665
|
}
|
|
@@ -602,9 +670,12 @@ public class StackPresenter {
|
|
|
602
670
|
if (options.selectedTabColor.hasValue() && options.unselectedTabColor.hasValue()) {
|
|
603
671
|
topBar.applyTopTabsColors(options.selectedTabColor, options.unselectedTabColor);
|
|
604
672
|
}
|
|
605
|
-
if (options.fontSize.hasValue())
|
|
606
|
-
|
|
607
|
-
if (options.
|
|
673
|
+
if (options.fontSize.hasValue())
|
|
674
|
+
topBar.applyTopTabsFontSize(options.fontSize);
|
|
675
|
+
if (options.visible.hasValue())
|
|
676
|
+
topBar.setTopTabsVisible(options.visible.isTrue());
|
|
677
|
+
if (options.height.hasValue())
|
|
678
|
+
topBar.setTopTabsHeight(options.height.get(LayoutParams.WRAP_CONTENT));
|
|
608
679
|
}
|
|
609
680
|
|
|
610
681
|
private void mergeTopTabOptions(TopTabOptions topTabOptions) {
|
|
@@ -638,23 +709,28 @@ public class StackPresenter {
|
|
|
638
709
|
}
|
|
639
710
|
|
|
640
711
|
@RestrictTo(RestrictTo.Scope.TESTS)
|
|
641
|
-
public void setComponentsButtonController(View child, ButtonController rightController,
|
|
642
|
-
|
|
643
|
-
forEach(
|
|
712
|
+
public void setComponentsButtonController(View child, ButtonController rightController,
|
|
713
|
+
ButtonController leftController) {
|
|
714
|
+
forEach(componentLeftButtons.get(child).keySet(),
|
|
715
|
+
(key) -> componentLeftButtons.get(child).put(key, leftController));
|
|
716
|
+
forEach(componentRightButtons.get(child).keySet(),
|
|
717
|
+
(key) -> componentRightButtons.get(child).put(key, rightController));
|
|
644
718
|
}
|
|
645
719
|
|
|
646
|
-
|
|
647
720
|
public void applyTopInsets(StackController stack, ViewController<?> child) {
|
|
648
|
-
if (stack.isCurrentChild(child))
|
|
721
|
+
if (stack.isCurrentChild(child))
|
|
722
|
+
applyStatusBarInsets(stack, child);
|
|
649
723
|
child.applyTopInset();
|
|
650
724
|
}
|
|
651
725
|
|
|
652
726
|
private List<ButtonController> getRightButtons(View child) {
|
|
653
|
-
return
|
|
727
|
+
return componentRightButtons.containsKey(child) ? new ArrayList<>(componentRightButtons.get(child).values())
|
|
728
|
+
: null;
|
|
654
729
|
}
|
|
655
730
|
|
|
656
731
|
private List<ButtonController> getLeftButtons(View child) {
|
|
657
|
-
return
|
|
732
|
+
return componentLeftButtons.containsKey(child) ? new ArrayList<>(componentLeftButtons.get(child).values())
|
|
733
|
+
: null;
|
|
658
734
|
}
|
|
659
735
|
|
|
660
736
|
private void applyStatusBarInsets(StackController stack, ViewController<?> child) {
|
|
@@ -671,58 +747,14 @@ public class StackPresenter {
|
|
|
671
747
|
private int getTopBarTopMargin(StackController stack, ViewController<?> child) {
|
|
672
748
|
Options withDefault = stack.resolveChildOptions(child).withDefaultOptions(defaultOptions);
|
|
673
749
|
int topMargin = UiUtils.dpToPx(activity, withDefault.topBar.topMargin.get(0));
|
|
674
|
-
int statusBarInset = withDefault.statusBar.visible.isTrueOrUndefined()
|
|
750
|
+
int statusBarInset = withDefault.statusBar.visible.isTrueOrUndefined()
|
|
751
|
+
&& !withDefault.statusBar.drawBehind.isTrue() ? SystemUiUtils.getStatusBarHeight(child.getActivity())
|
|
752
|
+
: 0;
|
|
675
753
|
return topMargin + statusBarInset;
|
|
676
754
|
}
|
|
677
755
|
|
|
678
756
|
public int getTopInset(Options resolvedOptions) {
|
|
679
|
-
return resolvedOptions.withDefaultOptions(defaultOptions).topBar.isHiddenOrDrawBehind() ? 0
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
private TitleBarReactViewController findTitleById(String id){
|
|
684
|
-
final Collection<TitleBarReactViewController> values = titleControllers.values();
|
|
685
|
-
for(TitleBarReactViewController child: values){
|
|
686
|
-
if(child.getId().equals(id)){
|
|
687
|
-
return child;
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
return null;
|
|
691
|
-
}
|
|
692
|
-
private Pair<ButtonController, ButtonBar> findButtonById(String id){
|
|
693
|
-
final Collection<Map<String, ButtonController>> leftControllers = leftButtonControllers.values();
|
|
694
|
-
final Collection<Map<String, ButtonController>> rightControllers = rightButtonControllers.values();
|
|
695
|
-
for(Map<String, ButtonController> map : leftControllers){
|
|
696
|
-
if(map.containsKey(id)){
|
|
697
|
-
return Pair.create(map.get(id),topBar.getLeftButtonBar());
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
for(Map<String, ButtonController> map : rightControllers){
|
|
701
|
-
if(map.containsKey(id)){
|
|
702
|
-
return Pair.create(map.get(id),topBar.getRightButtonBar());
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
return null;
|
|
706
|
-
}
|
|
707
|
-
@Nullable
|
|
708
|
-
public View findTopBarViewById(String id) {
|
|
709
|
-
final Pair<ButtonController, ButtonBar> buttonById = findButtonById(id);
|
|
710
|
-
if(buttonById!=null){
|
|
711
|
-
final View view = buttonById.first.getNullableView();
|
|
712
|
-
if(view==null){
|
|
713
|
-
final MenuItem menuItem = buttonById.first.getMenuItem();
|
|
714
|
-
if(menuItem!=null){
|
|
715
|
-
final int order = menuItem.getOrder();
|
|
716
|
-
return buttonById.second.getChildAt(order/10);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
return view;
|
|
720
|
-
}else {
|
|
721
|
-
final TitleBarReactViewController titleById = findTitleById(id);
|
|
722
|
-
if(titleById!=null){
|
|
723
|
-
return titleById.getView();
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
return null;
|
|
757
|
+
return resolvedOptions.withDefaultOptions(defaultOptions).topBar.isHiddenOrDrawBehind() ? 0
|
|
758
|
+
: topBarController.getHeight();
|
|
727
759
|
}
|
|
728
760
|
}
|