react-native-navigation 7.23.1 → 7.24.0
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/.buildkite/pipeline.yml +51 -11
- package/.nvmrc +1 -0
- package/Mock.d.ts +1 -0
- package/Mock.js +4 -0
- package/Mock.ts +1 -1
- package/README.md +0 -1
- package/jest.config.js +40 -0
- package/lib/{src/Mock → Mock}/Application.tsx +0 -0
- package/lib/{src/Mock → Mock}/ComponentProps.tsx +0 -0
- package/lib/{src/Mock → Mock}/Components/BottomTabs.tsx +0 -0
- package/lib/{src/Mock → Mock}/Components/ComponentScreen.tsx +13 -2
- package/lib/{src/Mock → Mock}/Components/LayoutComponent.tsx +0 -0
- package/lib/{src/Mock → Mock}/Components/Modals.tsx +0 -0
- package/lib/{src/Mock → Mock}/Components/NavigationButton.tsx +1 -1
- package/lib/{src/Mock → Mock}/Components/Overlays.tsx +0 -0
- package/lib/{src/Mock → Mock}/Components/Stack.tsx +0 -0
- package/lib/{src/Mock → Mock}/Components/TopBar.tsx +2 -2
- package/lib/{src/Mock → Mock}/Layouts/BottomTabsNode.ts +1 -1
- package/lib/{src/Mock → Mock}/Layouts/ComponentNode.ts +1 -1
- package/lib/{src/Mock → Mock}/Layouts/LayoutNodeFactory.ts +0 -0
- package/lib/{src/Mock → Mock}/Layouts/Node.ts +1 -1
- package/lib/{src/Mock → Mock}/Layouts/ParentNode.ts +2 -2
- package/lib/{src/Mock → Mock}/Layouts/StackNode.ts +0 -0
- package/lib/{src/Mock → Mock}/Stores/EventsStore.ts +10 -2
- package/lib/{src/Mock → Mock}/Stores/LayoutStore.ts +3 -2
- package/lib/{src/Mock → Mock}/connect.ts +0 -0
- package/lib/Mock/constants.d.ts +2 -0
- package/lib/Mock/constants.js +5 -0
- package/lib/{src/Mock → Mock}/constants.ts +0 -0
- package/lib/Mock/index.d.ts +3 -0
- package/lib/Mock/index.js +14 -0
- package/lib/{src/Mock → Mock}/index.ts +0 -0
- package/lib/{src/Mock → Mock}/mocks/AppRegistryService.ts +0 -0
- package/lib/{src/Mock → Mock}/mocks/NativeCommandsSender.tsx +1 -1
- package/lib/{src/Mock → Mock}/mocks/NativeEventsReceiver.ts +7 -4
- package/lib/android/app/build.gradle +23 -21
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/FontOptions.kt +2 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/HardwareBackButtonOptions.kt +35 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/LayoutFactory.java +32 -17
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/Options.java +1 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/parsers/TypefaceLoader.kt +16 -10
- package/lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java +5 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/react/modal/ModalFrameLayout.kt +3 -3
- package/lib/android/app/src/main/java/com/reactnativenavigation/react/modal/ModalViewManager.kt +11 -8
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/SystemUiUtils.kt +168 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenter.java +5 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java +42 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildController.java +12 -16
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +19 -11
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/externalcomponent/ExternalComponentViewController.java +2 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenter.java +6 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManager.kt +8 -3
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java +15 -7
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenter.java +127 -138
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/TopBarController.kt +183 -22
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonController.kt +25 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonPresenter.kt +9 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonSpan.kt +1 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java +52 -71
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/component/ComponentLayout.java +2 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/element/animators/ReactImageMatrixAnimator.kt +2 -3
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/TopBar.java +1 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/ButtonBar.kt +7 -12
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleAndButtonsContainer.kt +0 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleSubTitleLayout.kt +0 -7
- package/lib/android/app/src/reactNative51/java/com/reactnativenavigation/react/NavigationReactNativeHost.java +2 -1
- package/lib/android/app/src/test/java/com/reactnativenavigation/BaseTest.java +7 -6
- package/lib/android/app/src/test/java/com/reactnativenavigation/TestActivity.java +5 -0
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/ImageLoaderMock.kt +5 -4
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/Mocks.kt +3 -2
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TypefaceLoaderMock.kt +5 -1
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/TransitionAnimationOptionsTest.kt +2 -3
- package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/PresenterTest.java +25 -10
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/LayoutFactoryTest.java +25 -2
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/MotionEventTest.kt +1 -1
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/{TitleAndButtonsMeasurer.kt → TitleAndButtonsMeasurerTest.kt} +2 -2
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiThreadTest.java +2 -2
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiUtilsTest.java +1 -1
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.kt +572 -0
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsPresenterTest.kt +1 -1
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllerTest.java +2 -1
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewControllerTest.java +5 -5
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/fakes/FakeParentController.kt +1 -1
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorTest.kt +1 -1
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenterTest.java +7 -3
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java +17 -4
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/NavigatorTest.java +2 -2
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/RootPresenterTest.kt +5 -5
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManagerTest.java +1 -0
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/parent/ParentControllerTest.java +4 -0
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuControllerTest.java +6 -2
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackAnimatorTest.kt +1 -1
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.kt +13 -8
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenterTest.kt +58 -51
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarControllerTest.kt +219 -41
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewControllerTest.java +4 -1
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/TitleAndButtonsContainerTest.kt +2 -2
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/BaseViewAnimatorTest.kt +4 -4
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsContainerTest.kt +1 -1
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsTest.kt +4 -4
- package/lib/dist/Mock/Application.js +2 -2
- package/lib/dist/Mock/Components/BottomTabs.js +2 -2
- package/lib/dist/Mock/Components/ComponentScreen.js +15 -5
- package/lib/dist/Mock/Components/LayoutComponent.js +3 -2
- package/lib/dist/Mock/Components/Modals.js +2 -2
- package/lib/dist/Mock/Components/NavigationButton.d.ts +1 -1
- package/lib/dist/Mock/Components/NavigationButton.js +8 -10
- package/lib/dist/Mock/Components/Overlays.js +2 -2
- package/lib/dist/Mock/Components/Stack.js +2 -2
- package/lib/dist/Mock/Components/TopBar.d.ts +2 -2
- package/lib/dist/Mock/Components/TopBar.js +7 -6
- package/lib/dist/Mock/Layouts/BottomTabsNode.d.ts +1 -1
- package/lib/dist/Mock/Layouts/BottomTabsNode.js +3 -3
- package/lib/dist/Mock/Layouts/ComponentNode.d.ts +1 -1
- package/lib/dist/Mock/Layouts/ComponentNode.js +4 -4
- package/lib/dist/Mock/Layouts/LayoutNodeFactory.js +3 -3
- package/lib/dist/Mock/Layouts/Node.d.ts +1 -1
- package/lib/dist/Mock/Layouts/Node.js +5 -0
- package/lib/dist/Mock/Layouts/ParentNode.d.ts +2 -2
- package/lib/dist/Mock/Layouts/ParentNode.js +4 -3
- package/lib/dist/Mock/Layouts/StackNode.js +1 -1
- package/lib/dist/Mock/Stores/EventsStore.d.ts +5 -2
- package/lib/dist/Mock/Stores/EventsStore.js +7 -0
- package/lib/dist/Mock/Stores/LayoutStore.js +6 -3
- package/lib/dist/Mock/connect.js +1 -1
- package/lib/dist/Mock/index.js +1 -1
- package/lib/dist/Mock/mocks/NativeCommandsSender.d.ts +1 -1
- package/lib/dist/Mock/mocks/NativeCommandsSender.js +2 -2
- package/lib/dist/Mock/mocks/NativeEventsReceiver.d.ts +3 -3
- package/lib/dist/Mock/mocks/NativeEventsReceiver.js +6 -3
- package/lib/dist/{Navigation.d.ts → src/Navigation.d.ts} +0 -0
- package/lib/dist/{Navigation.js → src/Navigation.js} +19 -3
- package/lib/dist/{NavigationDelegate.d.ts → src/NavigationDelegate.d.ts} +0 -0
- package/lib/dist/{NavigationDelegate.js → src/NavigationDelegate.js} +1 -0
- package/lib/dist/{adapters → src/adapters}/AppRegistryService.d.ts +0 -0
- package/lib/dist/{adapters → src/adapters}/AppRegistryService.js +0 -0
- package/lib/dist/{adapters → src/adapters}/AssetResolver.d.ts +0 -0
- package/lib/dist/{adapters → src/adapters}/AssetResolver.js +0 -0
- package/lib/dist/src/adapters/ColorService.d.ts +3 -0
- package/lib/dist/{adapters → src/adapters}/ColorService.js +1 -1
- package/lib/dist/{adapters → src/adapters}/Constants.d.ts +0 -0
- package/lib/dist/{adapters → src/adapters}/Constants.js +10 -6
- package/lib/dist/{adapters → src/adapters}/NativeCommandsSender.d.ts +0 -0
- package/lib/dist/{adapters → src/adapters}/NativeCommandsSender.js +1 -0
- package/lib/dist/{adapters → src/adapters}/NativeEventsReceiver.d.ts +0 -0
- package/lib/dist/{adapters → src/adapters}/NativeEventsReceiver.js +1 -0
- package/lib/dist/{adapters → src/adapters}/NativeEventsReceiver.mock.d.ts +0 -0
- package/lib/dist/{adapters → src/adapters}/NativeEventsReceiver.mock.js +0 -0
- package/lib/dist/{adapters → src/adapters}/TouchablePreview.d.ts +0 -0
- package/lib/dist/src/adapters/TouchablePreview.js +89 -0
- package/lib/dist/{adapters → src/adapters}/UniqueIdProvider.d.ts +0 -0
- package/lib/dist/{adapters → src/adapters}/UniqueIdProvider.js +2 -2
- package/lib/dist/{commands → src/commands}/Commands.d.ts +0 -0
- package/lib/dist/{commands → src/commands}/Commands.js +24 -10
- package/lib/dist/{commands → src/commands}/Deprecations.d.ts +0 -0
- package/lib/dist/src/commands/Deprecations.js +80 -0
- package/lib/dist/{commands → src/commands}/LayoutTreeCrawler.d.ts +0 -0
- package/lib/dist/{commands → src/commands}/LayoutTreeCrawler.js +4 -2
- package/lib/dist/{commands → src/commands}/LayoutTreeParser.d.ts +0 -0
- package/lib/dist/{commands → src/commands}/LayoutTreeParser.js +1 -0
- package/lib/dist/{commands → src/commands}/LayoutType.d.ts +0 -0
- package/lib/dist/{commands → src/commands}/LayoutType.js +0 -0
- package/lib/dist/{commands → src/commands}/OptionsCrawler.d.ts +0 -0
- package/lib/dist/{commands → src/commands}/OptionsCrawler.js +6 -4
- package/lib/dist/{commands → src/commands}/OptionsProcessor.d.ts +1 -1
- package/lib/dist/{commands → src/commands}/OptionsProcessor.js +50 -42
- package/lib/dist/{components → src/components}/ComponentRegistry.d.ts +0 -0
- package/lib/dist/{components → src/components}/ComponentRegistry.js +4 -0
- package/lib/dist/{components → src/components}/ComponentWrapper.d.ts +0 -0
- package/lib/dist/{components → src/components}/ComponentWrapper.js +17 -17
- package/lib/dist/{components → src/components}/Modal.d.ts +0 -0
- package/lib/dist/{components → src/components}/Modal.js +8 -8
- package/lib/dist/{components → src/components}/Store.d.ts +2 -0
- package/lib/dist/{components → src/components}/Store.js +13 -6
- package/lib/dist/{events → src/events}/CommandsObserver.d.ts +0 -0
- package/lib/dist/{events → src/events}/CommandsObserver.js +2 -1
- package/lib/dist/{events → src/events}/ComponentEventsObserver.d.ts +4 -2
- package/lib/dist/{events → src/events}/ComponentEventsObserver.js +16 -14
- package/lib/dist/{events → src/events}/EventsRegistry.d.ts +2 -2
- package/lib/dist/{events → src/events}/EventsRegistry.js +3 -0
- package/lib/dist/{index.d.ts → src/index.d.ts} +0 -0
- package/lib/dist/src/index.js +22 -0
- package/lib/dist/{interfaces → src/interfaces}/CommandName.d.ts +0 -0
- package/lib/dist/{interfaces → src/interfaces}/CommandName.js +0 -0
- package/lib/dist/{interfaces → src/interfaces}/ComponentEvents.d.ts +0 -0
- package/lib/dist/{interfaces → src/interfaces}/ComponentEvents.js +0 -0
- package/lib/dist/{interfaces → src/interfaces}/EventSubscription.d.ts +0 -0
- package/lib/dist/{interfaces → src/interfaces}/EventSubscription.js +0 -0
- package/lib/dist/{interfaces → src/interfaces}/Events.d.ts +0 -0
- package/lib/dist/{interfaces → src/interfaces}/Events.js +0 -0
- package/lib/dist/{interfaces → src/interfaces}/Layout.d.ts +0 -0
- package/lib/dist/{interfaces → src/interfaces}/Layout.js +0 -0
- package/lib/dist/{interfaces → src/interfaces}/NavigationComponent.d.ts +0 -0
- package/lib/dist/{interfaces → src/interfaces}/NavigationComponent.js +8 -1
- package/lib/dist/{interfaces → src/interfaces}/NavigationComponentListener.d.ts +0 -0
- package/lib/dist/{interfaces → src/interfaces}/NavigationComponentListener.js +0 -0
- package/lib/dist/{interfaces → src/interfaces}/NavigationComponentProps.d.ts +0 -0
- package/lib/dist/{interfaces → src/interfaces}/NavigationComponentProps.js +0 -0
- package/lib/dist/{interfaces → src/interfaces}/NavigationFunctionComponent.d.ts +0 -0
- package/lib/dist/{interfaces → src/interfaces}/NavigationFunctionComponent.js +0 -0
- package/lib/dist/{interfaces → src/interfaces}/Options.d.ts +9 -0
- package/lib/dist/{interfaces → src/interfaces}/Options.js +0 -0
- package/lib/dist/{interfaces → src/interfaces}/ProcessorSubscription.d.ts +0 -0
- package/lib/dist/{interfaces → src/interfaces}/ProcessorSubscription.js +0 -0
- package/lib/dist/{interfaces → src/interfaces}/Processors.d.ts +0 -0
- package/lib/dist/{interfaces → src/interfaces}/Processors.js +0 -0
- package/lib/dist/{processors → src/processors}/LayoutProcessor.d.ts +0 -0
- package/lib/dist/{processors → src/processors}/LayoutProcessor.js +1 -0
- package/lib/dist/{processors → src/processors}/LayoutProcessorsStore.d.ts +0 -0
- package/lib/dist/{processors → src/processors}/LayoutProcessorsStore.js +1 -3
- package/lib/dist/{processors → src/processors}/OptionProcessorsStore.d.ts +0 -0
- package/lib/dist/{processors → src/processors}/OptionProcessorsStore.js +1 -3
- package/lib/dist/{types.d.ts → src/types.d.ts} +0 -0
- package/lib/dist/{types.js → src/types.js} +0 -0
- package/lib/ios/AnimationObserver.h +17 -0
- package/lib/ios/AnimationObserver.m +41 -0
- package/lib/ios/BottomTabPresenter.h +0 -3
- package/lib/ios/BottomTabPresenter.m +0 -8
- package/lib/ios/RNNAssert.h +2 -2
- package/lib/ios/RNNBasePresenter.h +0 -4
- package/lib/ios/RNNBasePresenter.m +0 -12
- package/lib/ios/RNNBottomTabOptions.m +2 -1
- package/lib/ios/RNNBottomTabsController.m +8 -8
- package/lib/ios/RNNBridgeManager.mm +0 -1
- package/lib/ios/RNNButtonBuilder.m +2 -0
- package/lib/ios/RNNButtonOptions.h +1 -0
- package/lib/ios/RNNButtonOptions.m +4 -0
- package/lib/ios/RNNCommandsHandler.m +15 -8
- package/lib/ios/RNNComponentPresenter.m +0 -4
- package/lib/ios/RNNComponentViewController.m +2 -4
- package/lib/ios/RNNDotIndicatorPresenter.m +2 -1
- package/lib/ios/RNNExternalViewController.m +2 -4
- package/lib/ios/RNNModalManager.h +2 -1
- package/lib/ios/RNNModalManager.m +12 -21
- package/lib/ios/RNNSegmentedControl.h +1 -1
- package/lib/ios/RNNSideMenuChildVC.m +0 -4
- package/lib/ios/RNNSideMenuController.m +0 -4
- package/lib/ios/RNNSplitViewController.m +0 -4
- package/lib/ios/RNNStackController.m +0 -4
- package/lib/ios/RNNStackPresenter.m +3 -0
- package/lib/ios/RNNSwizzles.m +20 -0
- package/lib/ios/RNNTabBarItemCreator.m +3 -2
- package/lib/ios/RNNUIBarButtonItem.h +2 -0
- package/lib/ios/RNNUIBarButtonItem.m +17 -0
- package/lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj +8 -0
- package/lib/ios/TopBarPresenter.m +8 -4
- package/lib/ios/UIViewController+RNNOptions.m +1 -1
- package/lib/src/commands/Commands.ts +6 -1
- package/lib/src/commands/LayoutTreeCrawler.ts +2 -2
- package/lib/src/commands/OptionsCrawler.ts +2 -1
- package/lib/src/commands/OptionsProcessor.ts +15 -13
- package/lib/src/components/Store.ts +9 -0
- package/lib/src/events/ComponentEventsObserver.ts +5 -1
- package/lib/src/events/EventsRegistry.ts +2 -1
- package/lib/src/interfaces/Options.ts +10 -0
- package/package.json +19 -60
- package/tsconfig.mocks.json +7 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/StatusBarUtils.java +0 -41
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.java +0 -511
- package/lib/dist/adapters/ColorService.d.ts +0 -3
- package/lib/dist/adapters/TouchablePreview.js +0 -91
- package/lib/dist/commands/Deprecations.js +0 -82
- package/lib/dist/index.js +0 -22
|
@@ -2,13 +2,16 @@ package com.reactnativenavigation.viewcontrollers.stack.topbar
|
|
|
2
2
|
|
|
3
3
|
import android.animation.Animator
|
|
4
4
|
import android.content.Context
|
|
5
|
+
import android.graphics.Color
|
|
5
6
|
import android.view.MenuItem
|
|
6
7
|
import android.view.View
|
|
8
|
+
import androidx.transition.AutoTransition
|
|
9
|
+
import androidx.transition.TransitionManager
|
|
7
10
|
import androidx.viewpager.widget.ViewPager
|
|
8
11
|
import com.reactnativenavigation.options.Alignment
|
|
9
12
|
import com.reactnativenavigation.options.AnimationOptions
|
|
13
|
+
import com.reactnativenavigation.options.ButtonOptions
|
|
10
14
|
import com.reactnativenavigation.options.Options
|
|
11
|
-
import com.reactnativenavigation.utils.CollectionUtils.forEachIndexed
|
|
12
15
|
import com.reactnativenavigation.utils.ViewUtils
|
|
13
16
|
import com.reactnativenavigation.utils.resetViewProperties
|
|
14
17
|
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController
|
|
@@ -17,12 +20,13 @@ import com.reactnativenavigation.views.stack.StackLayout
|
|
|
17
20
|
import com.reactnativenavigation.views.stack.topbar.TopBar
|
|
18
21
|
import com.reactnativenavigation.views.stack.topbar.titlebar.ButtonBar
|
|
19
22
|
|
|
23
|
+
const val DEFAULT_BORDER_COLOR = Color.BLACK
|
|
20
24
|
|
|
21
25
|
open class TopBarController(private val animator: TopBarAnimator = TopBarAnimator()) {
|
|
22
26
|
lateinit var view: TopBar
|
|
23
27
|
private lateinit var leftButtonBar: ButtonBar
|
|
24
28
|
private lateinit var rightButtonBar: ButtonBar
|
|
25
|
-
|
|
29
|
+
private val buttonsTransition = AutoTransition()
|
|
26
30
|
|
|
27
31
|
val height: Int
|
|
28
32
|
get() = view.height
|
|
@@ -54,26 +58,26 @@ open class TopBarController(private val animator: TopBarAnimator = TopBarAnimato
|
|
|
54
58
|
fun getPushAnimation(appearingOptions: Options, additionalDy: Float = 0f): Animator? {
|
|
55
59
|
if (appearingOptions.topBar.animate.isFalse) return null
|
|
56
60
|
return animator.getPushAnimation(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
appearingOptions.animations.push.topBar,
|
|
62
|
+
appearingOptions.topBar.visible,
|
|
63
|
+
additionalDy
|
|
60
64
|
)
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
fun getPopAnimation(appearingOptions: Options, disappearingOptions: Options): Animator? {
|
|
64
68
|
if (appearingOptions.topBar.animate.isFalse) return null
|
|
65
69
|
return animator.getPopAnimation(
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
disappearingOptions.animations.pop.topBar,
|
|
71
|
+
appearingOptions.topBar.visible
|
|
68
72
|
)
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
fun getSetStackRootAnimation(appearingOptions: Options, additionalDy: Float = 0f): Animator? {
|
|
72
76
|
if (appearingOptions.topBar.animate.isFalse) return null
|
|
73
77
|
return animator.getSetStackRootAnimation(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
appearingOptions.animations.setStackRoot.topBar,
|
|
79
|
+
appearingOptions.topBar.visible,
|
|
80
|
+
additionalDy
|
|
77
81
|
)
|
|
78
82
|
}
|
|
79
83
|
|
|
@@ -105,25 +109,182 @@ open class TopBarController(private val animator: TopBarAnimator = TopBarAnimato
|
|
|
105
109
|
view.alignTitleComponent(alignment)
|
|
106
110
|
}
|
|
107
111
|
|
|
108
|
-
fun
|
|
112
|
+
fun clearRightButtons() {
|
|
109
113
|
view.clearRightButtons()
|
|
110
|
-
toAdd.reversed().forEachIndexed { i, b -> b.addToMenu(rightButtonBar, i * 10) }
|
|
111
114
|
}
|
|
112
115
|
|
|
113
|
-
fun
|
|
114
|
-
|
|
115
|
-
toAdd.reversed().forEachIndexed { i, b -> b.addToMenu(rightButtonBar, i * 10) }
|
|
116
|
+
fun clearLeftButtons() {
|
|
117
|
+
view.clearLeftButtons()
|
|
116
118
|
}
|
|
117
119
|
|
|
118
|
-
|
|
120
|
+
fun clearBackButton() {
|
|
119
121
|
view.clearBackButton()
|
|
120
|
-
view.clearLeftButtons()
|
|
121
|
-
forEachIndexed(toAdd) { b: ButtonController, i: Int -> b.addToMenu(leftButtonBar, i * 10) }
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
view.
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
fun setBackButton(backButton: ButtonController?) {
|
|
125
|
+
backButton?.let { view.setBackButton(it) }
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
fun animateRightButtons(shouldAnimate: Boolean) {
|
|
129
|
+
view.animateRightButtons(shouldAnimate)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
fun animateLeftButtons(shouldAnimate: Boolean) {
|
|
133
|
+
view.animateLeftButtons(shouldAnimate)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
fun mergeRightButtonsOptions(
|
|
137
|
+
btnControllers: MutableMap<String, ButtonController>,
|
|
138
|
+
rightButtons: List<ButtonOptions>,
|
|
139
|
+
controllerCreator: (ButtonOptions) -> ButtonController
|
|
140
|
+
) {
|
|
141
|
+
mergeButtonOptions(btnControllers, rightButtons.reversed(), controllerCreator, rightButtonBar)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
fun mergeLeftButtonsOptions(
|
|
145
|
+
btnControllers: MutableMap<String, ButtonController>,
|
|
146
|
+
leftButtons: List<ButtonOptions>,
|
|
147
|
+
controllerCreator: (ButtonOptions) -> ButtonController
|
|
148
|
+
) {
|
|
149
|
+
clearBackButton()
|
|
150
|
+
mergeButtonOptions(btnControllers, leftButtons, controllerCreator, leftButtonBar)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
fun applyRightButtonsOptions(
|
|
154
|
+
btnControllers: MutableMap<String, ButtonController>,
|
|
155
|
+
rightButtons: List<ButtonOptions>,
|
|
156
|
+
controllerCreator: (ButtonOptions) -> ButtonController
|
|
157
|
+
) {
|
|
158
|
+
applyButtonsOptions(
|
|
159
|
+
btnControllers,
|
|
160
|
+
rightButtons.reversed(),
|
|
161
|
+
controllerCreator,
|
|
162
|
+
rightButtonBar
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
fun applyLeftButtonsOptions(
|
|
167
|
+
btnControllers: MutableMap<String, ButtonController>,
|
|
168
|
+
leftButtons: List<ButtonOptions>,
|
|
169
|
+
controllerCreator: (ButtonOptions) -> ButtonController
|
|
170
|
+
) {
|
|
171
|
+
applyButtonsOptions(btnControllers, leftButtons, controllerCreator, leftButtonBar)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private fun applyButtonsOptions(
|
|
175
|
+
btnControllers: MutableMap<String, ButtonController>,
|
|
176
|
+
buttons: List<ButtonOptions>,
|
|
177
|
+
controllerCreator: (ButtonOptions) -> ButtonController,
|
|
178
|
+
buttonBar: ButtonBar
|
|
179
|
+
) {
|
|
180
|
+
if (buttonBar.shouldAnimate)
|
|
181
|
+
TransitionManager.beginDelayedTransition(buttonBar, buttonsTransition)
|
|
182
|
+
|
|
183
|
+
buttonBar.clearButtons()
|
|
184
|
+
buttons.forEachIndexed { index, it ->
|
|
185
|
+
val order = index * 10
|
|
186
|
+
val newController = if (btnControllers.containsKey(it.id)) {
|
|
187
|
+
btnControllers.remove(it.id)
|
|
188
|
+
} else {
|
|
189
|
+
controllerCreator(it)
|
|
190
|
+
}!!
|
|
191
|
+
|
|
192
|
+
newController.addToMenu(buttonBar, order)
|
|
193
|
+
btnControllers[it.id] = newController
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
private fun mergeButtonOptions(
|
|
199
|
+
btnControllers: MutableMap<String, ButtonController>,
|
|
200
|
+
buttons: List<ButtonOptions>,
|
|
201
|
+
controllerCreator: (ButtonOptions) -> ButtonController,
|
|
202
|
+
buttonBar: ButtonBar
|
|
203
|
+
) {
|
|
204
|
+
fun hasChangedOrder(): Boolean {
|
|
205
|
+
val values = btnControllers.values
|
|
206
|
+
return buttons.filterIndexed { index, buttonOptions ->
|
|
207
|
+
val buttonController = btnControllers[buttonOptions.id]
|
|
208
|
+
values.indexOf(buttonController) == index
|
|
209
|
+
}.size != buttons.size
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
fun sameIdDifferentCompId(
|
|
213
|
+
toUpdate: MutableMap<String, Int>,
|
|
214
|
+
ctrl: Map.Entry<String, ButtonController>,
|
|
215
|
+
buttons: List<ButtonOptions>
|
|
216
|
+
) = if (toUpdate.containsKey(ctrl.key)
|
|
217
|
+
&& ctrl.value.button.hasComponent()
|
|
218
|
+
&& buttons[toUpdate[ctrl.key]!!].component.componentId != ctrl.value.button.component.componentId
|
|
219
|
+
) {
|
|
220
|
+
toUpdate.remove(ctrl.key)
|
|
221
|
+
true
|
|
222
|
+
} else false
|
|
223
|
+
|
|
224
|
+
val requestedButtons = buttons.mapIndexed { index, buttonOptions -> buttonOptions.id to index }.toMap()
|
|
225
|
+
var toUpdate = requestedButtons.filter {
|
|
226
|
+
btnControllers[it.key]?.areButtonOptionsChanged(buttons[it.value]) ?: false
|
|
227
|
+
}.toMutableMap()
|
|
228
|
+
var toAdd = requestedButtons.filter { !btnControllers.containsKey(it.key) }
|
|
229
|
+
var toRemove = btnControllers.filter { ctrl -> !requestedButtons.containsKey(ctrl.key) }
|
|
230
|
+
val toDestroy = btnControllers.filter { ctrl -> sameIdDifferentCompId(toUpdate, ctrl, buttons) }
|
|
231
|
+
.toMutableMap().apply { this.putAll(toRemove) }
|
|
232
|
+
|
|
233
|
+
fun needsRebuild(): Boolean {
|
|
234
|
+
return if (toUpdate.size == buttons.size) {
|
|
235
|
+
hasChangedOrder()
|
|
236
|
+
} else toAdd.isNotEmpty() || toRemove.isNotEmpty()
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (needsRebuild()) {
|
|
240
|
+
toUpdate = mutableMapOf()
|
|
241
|
+
toAdd = requestedButtons
|
|
242
|
+
toRemove = btnControllers.toMap()
|
|
243
|
+
if (buttonBar.shouldAnimate)
|
|
244
|
+
TransitionManager.beginDelayedTransition(buttonBar, buttonsTransition)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
toUpdate.forEach {
|
|
248
|
+
val button = buttons[it.value]
|
|
249
|
+
btnControllers[button.id]?.mergeButtonOptions(button, buttonBar)
|
|
250
|
+
}
|
|
251
|
+
toRemove.forEach {
|
|
252
|
+
buttonBar.removeButton(it.value.buttonIntId)
|
|
253
|
+
}
|
|
254
|
+
toDestroy.values.forEach {
|
|
255
|
+
btnControllers.remove(it.id)
|
|
256
|
+
it.destroy()
|
|
257
|
+
}
|
|
258
|
+
toAdd.forEach {
|
|
259
|
+
val button = buttons[it.value]
|
|
260
|
+
val order = it.value * 10
|
|
261
|
+
val newController = btnControllers[button.id] ?: controllerCreator(button)
|
|
262
|
+
newController.addToMenu(buttonBar, order)
|
|
263
|
+
btnControllers[button.id] = newController
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
fun onConfigurationChanged(
|
|
269
|
+
options: Options,
|
|
270
|
+
leftBtnControllers: MutableMap<String, ButtonController>?,
|
|
271
|
+
rightBtnControllers: MutableMap<String, ButtonController>?
|
|
272
|
+
) {
|
|
273
|
+
leftBtnControllers?.values?.forEach {
|
|
274
|
+
it.onConfigurationChanged(leftButtonBar)
|
|
275
|
+
}
|
|
276
|
+
rightBtnControllers?.values?.forEach {
|
|
277
|
+
it.onConfigurationChanged(rightButtonBar)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
view.setOverflowButtonColor(options.topBar.rightButtonColor.get(Color.BLACK)!!)
|
|
281
|
+
view.applyTopTabsColors(
|
|
282
|
+
options.topTabs.selectedTabColor,
|
|
283
|
+
options.topTabs.unselectedTabColor
|
|
284
|
+
)
|
|
285
|
+
view.setBorderColor(options.topBar.borderColor.get(DEFAULT_BORDER_COLOR)!!)
|
|
286
|
+
view.setBackgroundColor(options.topBar.background.color.get(Color.WHITE)!!)
|
|
287
|
+
view.setTitleTextColor(options.topBar.title.color.get(TopBar.DEFAULT_TITLE_COLOR)!!)
|
|
288
|
+
view.setSubtitleColor(options.topBar.subtitle.color.get(TopBar.DEFAULT_TITLE_COLOR)!!)
|
|
128
289
|
}
|
|
129
290
|
}
|
|
@@ -71,6 +71,10 @@ open class ButtonController(activity: Activity,
|
|
|
71
71
|
return if (other.id != id) false else button.equals(other.button)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
fun areButtonOptionsChanged(otherOptions:ButtonOptions):Boolean{
|
|
75
|
+
return otherOptions.id == id && !button.equals(otherOptions)
|
|
76
|
+
}
|
|
77
|
+
|
|
74
78
|
fun applyNavigationIcon(toolbar: Toolbar) {
|
|
75
79
|
presenter.applyNavigationIcon(toolbar) {
|
|
76
80
|
onPressListener.onPress(it)
|
|
@@ -83,13 +87,30 @@ open class ButtonController(activity: Activity,
|
|
|
83
87
|
|
|
84
88
|
fun addToMenu(buttonBar: ButtonBar, order: Int) {
|
|
85
89
|
if (button.component.hasValue() && buttonBar.containsButton(menuItem, order)) return
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
buttonBar.menu.removeItem(button.intId)
|
|
91
|
+
menuItem = buttonBar.addButton(Menu.NONE,
|
|
88
92
|
button.intId,
|
|
89
93
|
order,
|
|
90
94
|
presenter.styledText)?.also { menuItem ->
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
menuItem.setOnMenuItemClickListener(this@ButtonController)
|
|
96
|
+
presenter.applyOptions(buttonBar, menuItem, this@ButtonController::getView)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
fun mergeButtonOptions(optionsToMerge: ButtonOptions,buttonBar: ButtonBar) {
|
|
101
|
+
button.mergeWith(optionsToMerge)
|
|
102
|
+
presenter.button = this.button
|
|
103
|
+
buttonBar.getButtonById(button.intId)?.let {
|
|
104
|
+
menuItem->
|
|
105
|
+
presenter.applyOptions(buttonBar,menuItem,this::getView)
|
|
93
106
|
}
|
|
94
107
|
}
|
|
108
|
+
|
|
109
|
+
fun onConfigurationChanged(buttonBar: ButtonBar) {
|
|
110
|
+
buttonBar.getButtonById(button.intId)?.let {
|
|
111
|
+
menuItem->
|
|
112
|
+
presenter.applyOptions(buttonBar,menuItem,this::getView)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
95
116
|
}
|
|
@@ -25,7 +25,8 @@ import com.reactnativenavigation.utils.ViewUtils
|
|
|
25
25
|
import com.reactnativenavigation.views.stack.topbar.titlebar.IconBackgroundDrawable
|
|
26
26
|
import kotlin.math.max
|
|
27
27
|
|
|
28
|
-
open class ButtonPresenter(private val context: Context,
|
|
28
|
+
open class ButtonPresenter(private val context: Context,var button: ButtonOptions, private val iconResolver:
|
|
29
|
+
IconResolver) {
|
|
29
30
|
companion object {
|
|
30
31
|
const val DISABLED_COLOR = Color.LTGRAY
|
|
31
32
|
}
|
|
@@ -47,6 +48,8 @@ open class ButtonPresenter(private val context: Context, private val button: But
|
|
|
47
48
|
applyComponent(menuItem, viewCreator)
|
|
48
49
|
applyAccessibilityLabel(menuItem)
|
|
49
50
|
applyIcon(menuItem)
|
|
51
|
+
applyText(menuItem)
|
|
52
|
+
|
|
50
53
|
|
|
51
54
|
applyOptionsDirectlyOnView(toolbar, menuItem) {
|
|
52
55
|
applyTestId(it)
|
|
@@ -55,6 +58,11 @@ open class ButtonPresenter(private val context: Context, private val button: But
|
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
|
|
61
|
+
private fun applyText(menuItem: MenuItem) {
|
|
62
|
+
if (button.text.hasValue())
|
|
63
|
+
menuItem.title = button.text.get()
|
|
64
|
+
}
|
|
65
|
+
|
|
58
66
|
fun applyColor(toolbar: Toolbar, menuItem: MenuItem, color: ThemeColour) {
|
|
59
67
|
button.color = color
|
|
60
68
|
applyIcon(menuItem)
|
|
@@ -25,7 +25,7 @@ class ButtonSpan(
|
|
|
25
25
|
|
|
26
26
|
fun apply(paint: Paint) {
|
|
27
27
|
with(button.font) {
|
|
28
|
-
val typeface = getTypeface(typefaceLoader,
|
|
28
|
+
val typeface = getTypeface(typefaceLoader, paint.typeface)
|
|
29
29
|
val fakeStyle = (paint.typeface?.style ?: 0) and (typeface?.style?.inv() ?: 1)
|
|
30
30
|
if (fakeStyle and Typeface.BOLD != 0) paint.isFakeBoldText = true
|
|
31
31
|
if (fakeStyle and Typeface.ITALIC != 0) paint.textSkewX = -0.25f
|
|
@@ -10,47 +10,52 @@ import android.view.View;
|
|
|
10
10
|
import android.view.ViewGroup.MarginLayoutParams;
|
|
11
11
|
import android.view.Window;
|
|
12
12
|
|
|
13
|
+
import androidx.core.content.ContextCompat;
|
|
14
|
+
|
|
13
15
|
import com.reactnativenavigation.options.NavigationBarOptions;
|
|
14
16
|
import com.reactnativenavigation.options.Options;
|
|
15
17
|
import com.reactnativenavigation.options.OrientationOptions;
|
|
16
18
|
import com.reactnativenavigation.options.StatusBarOptions;
|
|
17
19
|
import com.reactnativenavigation.options.StatusBarOptions.TextColorScheme;
|
|
18
20
|
import com.reactnativenavigation.options.params.Bool;
|
|
19
|
-
import com.reactnativenavigation.utils.
|
|
21
|
+
import com.reactnativenavigation.utils.SystemUiUtils;
|
|
20
22
|
import com.reactnativenavigation.viewcontrollers.parent.ParentController;
|
|
21
23
|
import com.reactnativenavigation.viewcontrollers.navigator.Navigator;
|
|
22
24
|
|
|
23
|
-
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
|
|
24
|
-
|
|
25
25
|
public class Presenter {
|
|
26
26
|
private final Activity activity;
|
|
27
27
|
private Options defaultOptions;
|
|
28
|
-
|
|
29
28
|
public Presenter(Activity activity, Options defaultOptions) {
|
|
30
29
|
this.activity = activity;
|
|
31
30
|
this.defaultOptions = defaultOptions;
|
|
31
|
+
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
public void setDefaultOptions(Options defaultOptions) {
|
|
35
35
|
this.defaultOptions = defaultOptions;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
public
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
public Options getDefaultOptions() {
|
|
39
|
+
return defaultOptions;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public void mergeOptions(ViewController<?> viewController, Options options) {
|
|
43
|
+
final Options withDefaults = viewController.resolveCurrentOptions().copy().mergeWith(options).withDefaultOptions(defaultOptions);
|
|
44
|
+
mergeStatusBarOptions(viewController.getView(), withDefaults.statusBar);
|
|
45
|
+
mergeNavigationBarOptions(withDefaults.navigationBar);
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
public void applyOptions(ViewController view, Options options) {
|
|
44
49
|
Options withDefaultOptions = options.copy().withDefaultOptions(defaultOptions);
|
|
45
50
|
applyOrientation(withDefaultOptions.layout.orientation);
|
|
46
51
|
applyViewOptions(view, withDefaultOptions);
|
|
47
|
-
applyStatusBarOptions(withDefaultOptions);
|
|
52
|
+
applyStatusBarOptions(view, withDefaultOptions);
|
|
48
53
|
applyNavigationBarOptions(withDefaultOptions.navigationBar);
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
public void onViewBroughtToFront(Options options) {
|
|
56
|
+
public void onViewBroughtToFront(ViewController<?> viewController, Options options) {
|
|
52
57
|
Options withDefaultOptions = options.copy().withDefaultOptions(defaultOptions);
|
|
53
|
-
applyStatusBarOptions(withDefaultOptions);
|
|
58
|
+
applyStatusBarOptions(viewController, withDefaultOptions);
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
private void applyOrientation(OrientationOptions options) {
|
|
@@ -73,7 +78,7 @@ public class Presenter {
|
|
|
73
78
|
if (view instanceof Navigator) return;
|
|
74
79
|
|
|
75
80
|
LayerDrawable ld = new LayerDrawable(new Drawable[]{new ColorDrawable(options.layout.backgroundColor.get())});
|
|
76
|
-
int top = view.resolveCurrentOptions().statusBar.drawBehind.isTrue() ? 0 :
|
|
81
|
+
int top = view.resolveCurrentOptions().statusBar.drawBehind.isTrue() ? 0 : SystemUiUtils.getStatusBarHeight(view.getActivity());
|
|
77
82
|
if (!(view instanceof ParentController)) {
|
|
78
83
|
MarginLayoutParams lp = (MarginLayoutParams) view.getView().getLayoutParams();
|
|
79
84
|
if (lp.topMargin != 0) top = 0;
|
|
@@ -83,37 +88,37 @@ public class Presenter {
|
|
|
83
88
|
}
|
|
84
89
|
}
|
|
85
90
|
|
|
86
|
-
private void applyStatusBarOptions(Options options) {
|
|
91
|
+
private void applyStatusBarOptions(ViewController viewController, Options options) {
|
|
87
92
|
StatusBarOptions statusBar = options.copy().withDefaultOptions(defaultOptions).statusBar;
|
|
88
93
|
setStatusBarBackgroundColor(statusBar);
|
|
89
94
|
setTextColorScheme(statusBar);
|
|
90
95
|
setTranslucent(statusBar);
|
|
91
|
-
setStatusBarVisible(statusBar.visible);
|
|
96
|
+
setStatusBarVisible(viewController, statusBar.visible);
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
private void setTranslucent(StatusBarOptions options) {
|
|
95
100
|
Window window = activity.getWindow();
|
|
96
101
|
if (options.translucent.isTrue()) {
|
|
97
|
-
|
|
98
|
-
} else if (
|
|
99
|
-
|
|
102
|
+
SystemUiUtils.setStatusBarTranslucent(window);
|
|
103
|
+
} else if (SystemUiUtils.isTranslucent(window)) {
|
|
104
|
+
SystemUiUtils.clearStatusBarTranslucency(window);
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
private void setStatusBarVisible(Bool visible) {
|
|
104
|
-
View
|
|
105
|
-
int flags = decorView.getSystemUiVisibility();
|
|
108
|
+
private void setStatusBarVisible(ViewController viewController, Bool visible) {
|
|
109
|
+
final View view = viewController.view != null ? viewController.view : activity.getWindow().getDecorView();
|
|
106
110
|
if (visible.isFalse()) {
|
|
107
|
-
|
|
111
|
+
SystemUiUtils.hideStatusBar(activity.getWindow(), view);
|
|
108
112
|
} else {
|
|
109
|
-
|
|
113
|
+
SystemUiUtils.showStatusBar(activity.getWindow(), view);
|
|
110
114
|
}
|
|
111
|
-
decorView.setSystemUiVisibility(flags);
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
private void setStatusBarBackgroundColor(StatusBarOptions statusBar) {
|
|
115
|
-
if (
|
|
116
|
-
|
|
118
|
+
if (statusBar.backgroundColor.canApplyValue()) {
|
|
119
|
+
final int statusBarBackgroundColor = getStatusBarBackgroundColor(statusBar);
|
|
120
|
+
SystemUiUtils.setStatusBarColor(activity.getWindow(), statusBarBackgroundColor,
|
|
121
|
+
statusBar.translucent.isTrue());
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
|
|
@@ -133,20 +138,11 @@ public class Presenter {
|
|
|
133
138
|
}
|
|
134
139
|
|
|
135
140
|
private void setTextColorScheme(StatusBarOptions statusBar) {
|
|
136
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return;
|
|
137
|
-
|
|
138
141
|
final View view = activity.getWindow().getDecorView();
|
|
139
142
|
//View.post is a Workaround, added to solve internal Samsung
|
|
140
143
|
//Android 9 issues. For more info see https://github.com/wix/react-native-navigation/pull/7231
|
|
141
|
-
view.post(()->{
|
|
142
|
-
|
|
143
|
-
if (isDarkTextColorScheme(statusBar)) {
|
|
144
|
-
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
|
145
|
-
} else {
|
|
146
|
-
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
view.setSystemUiVisibility(flags);
|
|
144
|
+
view.post(() -> {
|
|
145
|
+
SystemUiUtils.setStatusBarColorScheme(activity.getWindow(), view, isDarkTextColorScheme(statusBar));
|
|
150
146
|
});
|
|
151
147
|
}
|
|
152
148
|
|
|
@@ -154,12 +150,14 @@ public class Presenter {
|
|
|
154
150
|
mergeStatusBarBackgroundColor(statusBar);
|
|
155
151
|
mergeTextColorScheme(statusBar);
|
|
156
152
|
mergeTranslucent(statusBar);
|
|
157
|
-
mergeStatusBarVisible(view, statusBar.visible
|
|
153
|
+
mergeStatusBarVisible(view, statusBar.visible);
|
|
158
154
|
}
|
|
159
155
|
|
|
160
156
|
private void mergeStatusBarBackgroundColor(StatusBarOptions statusBar) {
|
|
161
|
-
if (
|
|
162
|
-
|
|
157
|
+
if (statusBar.backgroundColor.hasValue()) {
|
|
158
|
+
final int statusBarBackgroundColor = getStatusBarBackgroundColor(statusBar);
|
|
159
|
+
SystemUiUtils.setStatusBarColor(activity.getWindow(), statusBarBackgroundColor,
|
|
160
|
+
statusBar.translucent.isTrue());
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
|
|
@@ -171,22 +169,19 @@ public class Presenter {
|
|
|
171
169
|
private void mergeTranslucent(StatusBarOptions options) {
|
|
172
170
|
Window window = activity.getWindow();
|
|
173
171
|
if (options.translucent.isTrue()) {
|
|
174
|
-
|
|
175
|
-
} else if (options.translucent.isFalse() &&
|
|
176
|
-
|
|
172
|
+
SystemUiUtils.setStatusBarTranslucent(window);
|
|
173
|
+
} else if (options.translucent.isFalse() && SystemUiUtils.isTranslucent(window)) {
|
|
174
|
+
SystemUiUtils.clearStatusBarTranslucency(window);
|
|
177
175
|
}
|
|
178
176
|
}
|
|
179
177
|
|
|
180
|
-
private void mergeStatusBarVisible(View view, Bool visible
|
|
178
|
+
private void mergeStatusBarVisible(View view, Bool visible) {
|
|
181
179
|
if (visible.hasValue()) {
|
|
182
|
-
int flags = view.getSystemUiVisibility();
|
|
183
180
|
if (visible.isTrue()) {
|
|
184
|
-
|
|
181
|
+
SystemUiUtils.showStatusBar(activity.getWindow(), view);
|
|
185
182
|
} else {
|
|
186
|
-
|
|
183
|
+
SystemUiUtils.hideStatusBar(activity.getWindow(), view);
|
|
187
184
|
}
|
|
188
|
-
if (flags != view.getSystemUiVisibility()) view.requestLayout();
|
|
189
|
-
view.setSystemUiVisibility(flags);
|
|
190
185
|
}
|
|
191
186
|
}
|
|
192
187
|
|
|
@@ -206,36 +201,22 @@ public class Presenter {
|
|
|
206
201
|
|
|
207
202
|
private void applyNavigationBarVisibility(NavigationBarOptions options) {
|
|
208
203
|
View decorView = activity.getWindow().getDecorView();
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
int hideNavigationBarFlags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
|
212
|
-
if (options.isVisible.get(defaultVisibility)) {
|
|
213
|
-
flags &= ~hideNavigationBarFlags;
|
|
204
|
+
if (options.isVisible.isTrueOrUndefined()) {
|
|
205
|
+
SystemUiUtils.showNavigationBar(activity.getWindow(), decorView);
|
|
214
206
|
} else {
|
|
215
|
-
|
|
207
|
+
SystemUiUtils.hideNavigationBar(activity.getWindow(), decorView);
|
|
216
208
|
}
|
|
217
|
-
decorView.setSystemUiVisibility(flags);
|
|
218
209
|
}
|
|
219
210
|
|
|
220
211
|
private void setNavigationBarBackgroundColor(NavigationBarOptions navigationBar) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
212
|
+
int navigationBarDefaultColor = SystemUiUtils.INSTANCE.getNavigationBarDefaultColor();
|
|
213
|
+
navigationBarDefaultColor = navigationBarDefaultColor==-1?Color.BLACK:navigationBarDefaultColor;
|
|
214
|
+
if (navigationBar.backgroundColor.canApplyValue()) {
|
|
215
|
+
int color = navigationBar.backgroundColor.get(navigationBarDefaultColor);
|
|
216
|
+
SystemUiUtils.setNavigationBarBackgroundColor(activity.getWindow(), color, isColorLight(color));
|
|
217
|
+
}else{
|
|
218
|
+
SystemUiUtils.setNavigationBarBackgroundColor(activity.getWindow(), navigationBarDefaultColor, isColorLight(navigationBarDefaultColor));
|
|
228
219
|
|
|
229
|
-
private void setNavigationBarButtonsColor(int color) {
|
|
230
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
231
|
-
View decorView = activity.getWindow().getDecorView();
|
|
232
|
-
int flags = decorView.getSystemUiVisibility();
|
|
233
|
-
if (isColorLight(color)) {
|
|
234
|
-
flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
|
235
|
-
} else {
|
|
236
|
-
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
|
237
|
-
}
|
|
238
|
-
decorView.setSystemUiVisibility(flags);
|
|
239
220
|
}
|
|
240
221
|
}
|
|
241
222
|
|
package/lib/android/app/src/main/java/com/reactnativenavigation/views/component/ComponentLayout.java
CHANGED
|
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
import android.view.MotionEvent;
|
|
6
6
|
import android.view.ViewGroup;
|
|
7
|
+
import android.view.WindowInsets;
|
|
7
8
|
|
|
8
9
|
import com.reactnativenavigation.options.ButtonOptions;
|
|
9
10
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
|
|
@@ -99,6 +100,7 @@ public class ComponentLayout extends CoordinatorLayout implements ReactComponent
|
|
|
99
100
|
reactView.sendOnNavigationButtonPressed(button.id);
|
|
100
101
|
}
|
|
101
102
|
|
|
103
|
+
|
|
102
104
|
@Override
|
|
103
105
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
|
104
106
|
return touchDelegate.onInterceptTouchEvent(ev);
|
|
@@ -13,7 +13,6 @@ import com.reactnativenavigation.options.SharedElementTransitionOptions
|
|
|
13
13
|
import com.reactnativenavigation.utils.ViewUtils
|
|
14
14
|
import kotlin.math.max
|
|
15
15
|
import kotlin.math.roundToInt
|
|
16
|
-
import android.animation.TypeEvaluator
|
|
17
16
|
|
|
18
17
|
class ReactImageMatrixAnimator(from: View, to: View) : PropertyAnimatorCreator<ReactImageView>(from, to) {
|
|
19
18
|
override fun shouldAnimateProperty(fromChild: ReactImageView, toChild: ReactImageView): Boolean {
|
|
@@ -39,7 +38,7 @@ class ReactImageMatrixAnimator(from: View, to: View) : PropertyAnimatorCreator<R
|
|
|
39
38
|
|
|
40
39
|
to.layoutParams.width = max(from.width, to.width)
|
|
41
40
|
to.layoutParams.height = max(from.height, to.height)
|
|
42
|
-
return ObjectAnimator.ofObject(
|
|
41
|
+
return ObjectAnimator.ofObject({ fraction: Float, _: Any, _: Any ->
|
|
43
42
|
hierarchy.actualImageScaleType?.let {
|
|
44
43
|
(hierarchy.actualImageScaleType as? InterpolatingScaleType)?.let {
|
|
45
44
|
it.value = fraction
|
|
@@ -47,7 +46,7 @@ class ReactImageMatrixAnimator(from: View, to: View) : PropertyAnimatorCreator<R
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
null
|
|
50
|
-
},
|
|
49
|
+
}, 0f, 1f)
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
|
package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/TopBar.java
CHANGED
|
@@ -47,7 +47,7 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
|
|
47
47
|
|
|
48
48
|
@SuppressLint("ViewConstructor")
|
|
49
49
|
public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAwareView {
|
|
50
|
-
public final static int
|
|
50
|
+
public final static int DEFAULT_TITLE_COLOR = Color.BLACK;
|
|
51
51
|
public final static int DEFAULT_SUBTITLE_COLOR = Color.GRAY;
|
|
52
52
|
|
|
53
53
|
private final TopBarCollapseBehavior collapsingBehavior;
|
|
@@ -75,7 +75,6 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
|
|
75
75
|
|
|
76
76
|
private void createLayout() {
|
|
77
77
|
setId(CompatUtils.generateViewId());
|
|
78
|
-
setFitsSystemWindows(true);
|
|
79
78
|
topTabs = createTopTabs();
|
|
80
79
|
border = createBorder();
|
|
81
80
|
LinearLayout content = createContentLayout();
|