|
@@ -127,7 +127,7 @@ public class StackPresenter {
|
127
|
127
|
public void mergeOptions(Options options, Component currentChild) {
|
128
|
128
|
mergeOrientation(options.layout.orientation);
|
129
|
129
|
// mergeButtons(topBar, withDefault.topBar.buttons, child);
|
130
|
|
- mergeTopBarOptions(options.topBar, options.animations, currentChild);
|
|
130
|
+ mergeTopBarOptions(options, currentChild);
|
131
|
131
|
mergeTopTabsOptions(options.topTabs);
|
132
|
132
|
mergeTopTabOptions(options.topTabOptions);
|
133
|
133
|
}
|
|
@@ -141,7 +141,7 @@ public class StackPresenter {
|
141
|
141
|
Options withDefault = options.copy().withDefaultOptions(defaultOptions);
|
142
|
142
|
applyOrientation(withDefault.layout.orientation);
|
143
|
143
|
applyButtons(withDefault.topBar, child);
|
144
|
|
- applyTopBarOptions(withDefault.topBar, withDefault.animations, child, options);
|
|
144
|
+ applyTopBarOptions(withDefault, child, options);
|
145
|
145
|
applyTopTabsOptions(withDefault.topTabs);
|
146
|
146
|
applyTopTabOptions(withDefault.topTabOptions);
|
147
|
147
|
}
|
|
@@ -164,55 +164,59 @@ public class StackPresenter {
|
164
|
164
|
if (buttons != null) forEach(buttons.values(), ViewController::destroy);
|
165
|
165
|
}
|
166
|
166
|
|
167
|
|
- private void applyTopBarOptions(TopBarOptions options, AnimationsOptions animationOptions, Component component, Options componentOptions) {
|
168
|
|
- topBar.setHeight(options.height.get(UiUtils.getTopBarHeightDp(activity)));
|
169
|
|
- topBar.setElevation(options.elevation.get(DEFAULT_ELEVATION));
|
|
167
|
+ private void applyTopBarOptions(Options options, Component component, Options componentOptions) {
|
|
168
|
+ TopBarOptions topBarOptions = options.topBar;
|
|
169
|
+ AnimationsOptions animationOptions = options.animations;
|
|
170
|
+
|
|
171
|
+ topBar.setLayoutDirection(options.layout.direction);
|
|
172
|
+ topBar.setHeight(topBarOptions.height.get(UiUtils.getTopBarHeightDp(activity)));
|
|
173
|
+ topBar.setElevation(topBarOptions.elevation.get(DEFAULT_ELEVATION));
|
170
|
174
|
if (topBar.getLayoutParams() instanceof MarginLayoutParams) {
|
171
|
|
- ((MarginLayoutParams) topBar.getLayoutParams()).topMargin = UiUtils.dpToPx(activity, options.topMargin.get(0));
|
|
175
|
+ ((MarginLayoutParams) topBar.getLayoutParams()).topMargin = UiUtils.dpToPx(activity, topBarOptions.topMargin.get(0));
|
172
|
176
|
}
|
173
|
177
|
|
174
|
|
- topBar.setTitleHeight(options.title.height.get(UiUtils.getTopBarHeightDp(activity)));
|
175
|
|
- topBar.setTitle(options.title.text.get(""));
|
176
|
|
- topBar.setTitleTopMargin(options.title.topMargin.get(0));
|
|
178
|
+ topBar.setTitleHeight(topBarOptions.title.height.get(UiUtils.getTopBarHeightDp(activity)));
|
|
179
|
+ topBar.setTitle(topBarOptions.title.text.get(""));
|
|
180
|
+ topBar.setTitleTopMargin(topBarOptions.title.topMargin.get(0));
|
177
|
181
|
|
178
|
|
- if (options.title.component.hasValue()) {
|
|
182
|
+ if (topBarOptions.title.component.hasValue()) {
|
179
|
183
|
if (titleControllers.containsKey(component)) {
|
180
|
184
|
topBar.setTitleComponent(titleControllers.get(component).getView());
|
181
|
185
|
} else {
|
182
|
186
|
TitleBarReactViewController controller = new TitleBarReactViewController(activity, titleViewCreator);
|
183
|
|
- controller.setWaitForRender(options.title.component.waitForRender);
|
|
187
|
+ controller.setWaitForRender(topBarOptions.title.component.waitForRender);
|
184
|
188
|
titleControllers.put(component, controller);
|
185
|
|
- controller.setComponent(options.title.component);
|
186
|
|
- controller.getView().setLayoutParams(getComponentLayoutParams(options.title.component));
|
|
189
|
+ controller.setComponent(topBarOptions.title.component);
|
|
190
|
+ controller.getView().setLayoutParams(getComponentLayoutParams(topBarOptions.title.component));
|
187
|
191
|
topBar.setTitleComponent(controller.getView());
|
188
|
192
|
}
|
189
|
193
|
}
|
190
|
194
|
|
191
|
|
- topBar.setTitleFontSize(options.title.fontSize.get(defaultTitleFontSize));
|
192
|
|
- topBar.setTitleTextColor(options.title.color.get(DEFAULT_TITLE_COLOR));
|
193
|
|
- topBar.setTitleTypeface(options.title.fontFamily);
|
194
|
|
- topBar.setTitleAlignment(options.title.alignment);
|
|
195
|
+ topBar.setTitleFontSize(topBarOptions.title.fontSize.get(defaultTitleFontSize));
|
|
196
|
+ topBar.setTitleTextColor(topBarOptions.title.color.get(DEFAULT_TITLE_COLOR));
|
|
197
|
+ topBar.setTitleTypeface(topBarOptions.title.fontFamily);
|
|
198
|
+ topBar.setTitleAlignment(topBarOptions.title.alignment);
|
195
|
199
|
|
196
|
|
- topBar.setSubtitle(options.subtitle.text.get(""));
|
197
|
|
- topBar.setSubtitleFontSize(options.subtitle.fontSize.get(defaultSubtitleFontSize));
|
198
|
|
- topBar.setSubtitleColor(options.subtitle.color.get(DEFAULT_SUBTITLE_COLOR));
|
199
|
|
- topBar.setSubtitleFontFamily(options.subtitle.fontFamily);
|
200
|
|
- topBar.setSubtitleAlignment(options.subtitle.alignment);
|
|
200
|
+ topBar.setSubtitle(topBarOptions.subtitle.text.get(""));
|
|
201
|
+ topBar.setSubtitleFontSize(topBarOptions.subtitle.fontSize.get(defaultSubtitleFontSize));
|
|
202
|
+ topBar.setSubtitleColor(topBarOptions.subtitle.color.get(DEFAULT_SUBTITLE_COLOR));
|
|
203
|
+ topBar.setSubtitleFontFamily(topBarOptions.subtitle.fontFamily);
|
|
204
|
+ topBar.setSubtitleAlignment(topBarOptions.subtitle.alignment);
|
201
|
205
|
|
202
|
|
- topBar.setBorderHeight(options.borderHeight.get(0d));
|
203
|
|
- topBar.setBorderColor(options.borderColor.get(DEFAULT_BORDER_COLOR));
|
|
206
|
+ topBar.setBorderHeight(topBarOptions.borderHeight.get(0d));
|
|
207
|
+ topBar.setBorderColor(topBarOptions.borderColor.get(DEFAULT_BORDER_COLOR));
|
204
|
208
|
|
205
|
|
- topBar.setBackgroundColor(options.background.color.get(Color.WHITE));
|
|
209
|
+ topBar.setBackgroundColor(topBarOptions.background.color.get(Color.WHITE));
|
206
|
210
|
|
207
|
|
- if (options.background.component.hasValue()) {
|
208
|
|
- View createdComponent = findBackgroundComponent(options.background.component);
|
|
211
|
+ if (topBarOptions.background.component.hasValue()) {
|
|
212
|
+ View createdComponent = findBackgroundComponent(topBarOptions.background.component);
|
209
|
213
|
if (createdComponent != null) {
|
210
|
214
|
topBar.setBackgroundComponent(createdComponent);
|
211
|
215
|
} else {
|
212
|
216
|
TopBarBackgroundViewController controller = new TopBarBackgroundViewController(activity, topBarBackgroundViewCreator);
|
213
|
|
- controller.setWaitForRender(options.background.waitForRender);
|
|
217
|
+ controller.setWaitForRender(topBarOptions.background.waitForRender);
|
214
|
218
|
backgroundControllers.put(component, controller);
|
215
|
|
- controller.setComponent(options.background.component);
|
|
219
|
+ controller.setComponent(topBarOptions.background.component);
|
216
|
220
|
controller.getView().setLayoutParams(new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
217
|
221
|
topBar.setBackgroundComponent(controller.getView());
|
218
|
222
|
}
|
|
@@ -220,18 +224,18 @@ public class StackPresenter {
|
220
|
224
|
topBar.clearBackgroundComponent();
|
221
|
225
|
}
|
222
|
226
|
|
223
|
|
- if (options.testId.hasValue()) topBar.setTestId(options.testId.get());
|
224
|
|
- applyTopBarVisibility(options, animationOptions, componentOptions);
|
225
|
|
- if (options.drawBehind.isTrue() && !componentOptions.layout.topMargin.hasValue()) {
|
|
227
|
+ if (topBarOptions.testId.hasValue()) topBar.setTestId(topBarOptions.testId.get());
|
|
228
|
+ applyTopBarVisibility(topBarOptions, animationOptions, componentOptions);
|
|
229
|
+ if (topBarOptions.drawBehind.isTrue() && !componentOptions.layout.topMargin.hasValue()) {
|
226
|
230
|
component.drawBehindTopBar();
|
227
|
|
- } else if (options.drawBehind.isFalseOrUndefined()) {
|
|
231
|
+ } else if (topBarOptions.drawBehind.isFalseOrUndefined()) {
|
228
|
232
|
component.drawBelowTopBar(topBar);
|
229
|
233
|
}
|
230
|
|
- if (options.hideOnScroll.isTrue()) {
|
|
234
|
+ if (topBarOptions.hideOnScroll.isTrue()) {
|
231
|
235
|
if (component instanceof IReactView) {
|
232
|
236
|
topBar.enableCollapse(((IReactView) component).getScrollEventListener());
|
233
|
237
|
}
|
234
|
|
- } else if (options.hideOnScroll.isFalseOrUndefined()) {
|
|
238
|
+ } else if (topBarOptions.hideOnScroll.isFalseOrUndefined()) {
|
235
|
239
|
topBar.disableCollapse();
|
236
|
240
|
}
|
237
|
241
|
}
|
|
@@ -351,7 +355,7 @@ public class StackPresenter {
|
351
|
355
|
TopBarOptions topBar = toMerge.copy().mergeWith(resolvedOptions).withDefaultOptions(defaultOptions).topBar;
|
352
|
356
|
mergeOrientation(toMerge.layout.orientation);
|
353
|
357
|
mergeButtons(topBar, toMerge.topBar.buttons, child);
|
354
|
|
- mergeTopBarOptions(toMerge.topBar, toMerge.animations, child);
|
|
358
|
+ mergeTopBarOptions(toMerge, child);
|
355
|
359
|
mergeTopTabsOptions(toMerge.topTabs);
|
356
|
360
|
mergeTopTabOptions(toMerge.topTabOptions);
|
357
|
361
|
}
|
|
@@ -403,78 +407,82 @@ public class StackPresenter {
|
403
|
407
|
return result;
|
404
|
408
|
}
|
405
|
409
|
|
406
|
|
- private void mergeTopBarOptions(TopBarOptions options, AnimationsOptions animationsOptions, Component component) {
|
407
|
|
- if (options.height.hasValue()) topBar.setHeight(options.height.get());
|
408
|
|
- if (options.elevation.hasValue()) topBar.setElevation(options.elevation.get());
|
409
|
|
- if (options.topMargin.hasValue() && topBar.getLayoutParams() instanceof MarginLayoutParams) {
|
410
|
|
- ((MarginLayoutParams) topBar.getLayoutParams()).topMargin = UiUtils.dpToPx(activity, options.topMargin.get());
|
|
410
|
+ private void mergeTopBarOptions(Options options, Component component) {
|
|
411
|
+ TopBarOptions topBarOptions = options.topBar;
|
|
412
|
+ AnimationsOptions animationsOptions = options.animations;
|
|
413
|
+
|
|
414
|
+ if (options.layout.direction.hasValue()) topBar.setLayoutDirection(options.layout.direction);
|
|
415
|
+ if (topBarOptions.height.hasValue()) topBar.setHeight(topBarOptions.height.get());
|
|
416
|
+ if (topBarOptions.elevation.hasValue()) topBar.setElevation(topBarOptions.elevation.get());
|
|
417
|
+ if (topBarOptions.topMargin.hasValue() && topBar.getLayoutParams() instanceof MarginLayoutParams) {
|
|
418
|
+ ((MarginLayoutParams) topBar.getLayoutParams()).topMargin = UiUtils.dpToPx(activity, topBarOptions.topMargin.get());
|
411
|
419
|
}
|
412
|
420
|
|
413
|
|
- if (options.title.height.hasValue()) topBar.setTitleHeight(options.title.height.get());
|
414
|
|
- if (options.title.text.hasValue()) topBar.setTitle(options.title.text.get());
|
415
|
|
- if (options.title.topMargin.hasValue()) topBar.setTitleTopMargin(options.title.topMargin.get());
|
|
421
|
+ if (topBarOptions.title.height.hasValue()) topBar.setTitleHeight(topBarOptions.title.height.get());
|
|
422
|
+ if (topBarOptions.title.text.hasValue()) topBar.setTitle(topBarOptions.title.text.get());
|
|
423
|
+ if (topBarOptions.title.topMargin.hasValue()) topBar.setTitleTopMargin(topBarOptions.title.topMargin.get());
|
416
|
424
|
|
417
|
|
- if (options.title.component.hasValue()) {
|
|
425
|
+ if (topBarOptions.title.component.hasValue()) {
|
418
|
426
|
if (titleControllers.containsKey(component)) {
|
419
|
427
|
topBar.setTitleComponent(titleControllers.get(component).getView());
|
420
|
428
|
} else {
|
421
|
429
|
TitleBarReactViewController controller = new TitleBarReactViewController(activity, titleViewCreator);
|
422
|
430
|
titleControllers.put(component, controller);
|
423
|
|
- controller.setComponent(options.title.component);
|
424
|
|
- controller.getView().setLayoutParams(getComponentLayoutParams(options.title.component));
|
|
431
|
+ controller.setComponent(topBarOptions.title.component);
|
|
432
|
+ controller.getView().setLayoutParams(getComponentLayoutParams(topBarOptions.title.component));
|
425
|
433
|
topBar.setTitleComponent(controller.getView());
|
426
|
434
|
}
|
427
|
435
|
}
|
428
|
436
|
|
429
|
|
- if (options.title.color.hasValue()) topBar.setTitleTextColor(options.title.color.get());
|
430
|
|
- if (options.title.fontSize.hasValue()) topBar.setTitleFontSize(options.title.fontSize.get());
|
431
|
|
- if (options.title.fontFamily != null) topBar.setTitleTypeface(options.title.fontFamily);
|
|
437
|
+ if (topBarOptions.title.color.hasValue()) topBar.setTitleTextColor(topBarOptions.title.color.get());
|
|
438
|
+ if (topBarOptions.title.fontSize.hasValue()) topBar.setTitleFontSize(topBarOptions.title.fontSize.get());
|
|
439
|
+ if (topBarOptions.title.fontFamily != null) topBar.setTitleTypeface(topBarOptions.title.fontFamily);
|
432
|
440
|
|
433
|
|
- if (options.subtitle.text.hasValue()) topBar.setSubtitle(options.subtitle.text.get());
|
434
|
|
- if (options.subtitle.color.hasValue()) topBar.setSubtitleColor(options.subtitle.color.get());
|
435
|
|
- if (options.subtitle.fontSize.hasValue()) topBar.setSubtitleFontSize(options.subtitle.fontSize.get());
|
436
|
|
- if (options.subtitle.fontFamily != null) topBar.setSubtitleFontFamily(options.subtitle.fontFamily);
|
|
441
|
+ if (topBarOptions.subtitle.text.hasValue()) topBar.setSubtitle(topBarOptions.subtitle.text.get());
|
|
442
|
+ if (topBarOptions.subtitle.color.hasValue()) topBar.setSubtitleColor(topBarOptions.subtitle.color.get());
|
|
443
|
+ if (topBarOptions.subtitle.fontSize.hasValue()) topBar.setSubtitleFontSize(topBarOptions.subtitle.fontSize.get());
|
|
444
|
+ if (topBarOptions.subtitle.fontFamily != null) topBar.setSubtitleFontFamily(topBarOptions.subtitle.fontFamily);
|
437
|
445
|
|
438
|
|
- if (options.background.color.hasValue()) topBar.setBackgroundColor(options.background.color.get());
|
|
446
|
+ if (topBarOptions.background.color.hasValue()) topBar.setBackgroundColor(topBarOptions.background.color.get());
|
439
|
447
|
|
440
|
|
- if (options.background.component.hasValue()) {
|
|
448
|
+ if (topBarOptions.background.component.hasValue()) {
|
441
|
449
|
if (backgroundControllers.containsKey(component)) {
|
442
|
450
|
topBar.setBackgroundComponent(backgroundControllers.get(component).getView());
|
443
|
451
|
} else {
|
444
|
452
|
TopBarBackgroundViewController controller = new TopBarBackgroundViewController(activity, topBarBackgroundViewCreator);
|
445
|
453
|
backgroundControllers.put(component, controller);
|
446
|
|
- controller.setComponent(options.background.component);
|
|
454
|
+ controller.setComponent(topBarOptions.background.component);
|
447
|
455
|
controller.getView().setLayoutParams(new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
448
|
456
|
topBar.setBackgroundComponent(controller.getView());
|
449
|
457
|
}
|
450
|
458
|
}
|
451
|
459
|
|
452
|
|
- if (options.testId.hasValue()) topBar.setTestId(options.testId.get());
|
|
460
|
+ if (topBarOptions.testId.hasValue()) topBar.setTestId(topBarOptions.testId.get());
|
453
|
461
|
|
454
|
|
- if (options.visible.isFalse()) {
|
455
|
|
- if (options.animate.isTrueOrUndefined()) {
|
|
462
|
+ if (topBarOptions.visible.isFalse()) {
|
|
463
|
+ if (topBarOptions.animate.isTrueOrUndefined()) {
|
456
|
464
|
topBar.hideAnimate(animationsOptions.pop.topBar);
|
457
|
465
|
} else {
|
458
|
466
|
topBar.hide();
|
459
|
467
|
}
|
460
|
468
|
}
|
461
|
|
- if (options.visible.isTrue()) {
|
462
|
|
- if (options.animate.isTrueOrUndefined()) {
|
|
469
|
+ if (topBarOptions.visible.isTrue()) {
|
|
470
|
+ if (topBarOptions.animate.isTrueOrUndefined()) {
|
463
|
471
|
topBar.showAnimate(animationsOptions.push.topBar);
|
464
|
472
|
} else {
|
465
|
473
|
topBar.show();
|
466
|
474
|
}
|
467
|
475
|
}
|
468
|
|
- if (options.drawBehind.isTrue()) {
|
|
476
|
+ if (topBarOptions.drawBehind.isTrue()) {
|
469
|
477
|
component.drawBehindTopBar();
|
470
|
478
|
}
|
471
|
|
- if (options.drawBehind.isFalse()) {
|
|
479
|
+ if (topBarOptions.drawBehind.isFalse()) {
|
472
|
480
|
component.drawBelowTopBar(topBar);
|
473
|
481
|
}
|
474
|
|
- if (options.hideOnScroll.isTrue() && component instanceof IReactView) {
|
|
482
|
+ if (topBarOptions.hideOnScroll.isTrue() && component instanceof IReactView) {
|
475
|
483
|
topBar.enableCollapse(((IReactView) component).getScrollEventListener());
|
476
|
484
|
}
|
477
|
|
- if (options.hideOnScroll.isFalse()) {
|
|
485
|
+ if (topBarOptions.hideOnScroll.isFalse()) {
|
478
|
486
|
topBar.disableCollapse();
|
479
|
487
|
}
|
480
|
488
|
}
|