react-native-screens 4.12.0 → 4.13.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/RNScreens.podspec +29 -2
- package/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt +4 -0
- package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +9 -1
- package/android/src/main/java/com/swmansion/rnscreens/ScreenFragmentWrapper.kt +0 -1
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +4 -4
- package/android/src/main/java/com/swmansion/rnscreens/ScreensModule.kt +1 -1
- package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/DimmingView.kt +4 -4
- package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/DimmingViewManager.kt +8 -2
- package/android/src/main/java/com/swmansion/rnscreens/events/ScreenAnimationDelegate.kt +1 -2
- package/android/src/main/java/com/swmansion/rnscreens/events/ScreenEventEmitter.kt +16 -13
- package/android/src/main/java/com/swmansion/rnscreens/gamma/common/BaseEventEmitter.kt +22 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/common/FragmentProviding.kt +11 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/common/NamingAwareEventType.kt +13 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/helpers/EventHelpers.kt +6 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/helpers/FragmentManagerHelper.kt +76 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/helpers/SystemDrawable.kt +33 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabScreen.kt +101 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabScreenDelegate.kt +17 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabScreenEventEmitter.kt +46 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabScreenFragment.kt +37 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabScreenViewManager.kt +178 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabsHost.kt +433 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabsHostEventEmitter.kt +14 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabsHostViewManager.kt +177 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/event/TabScreenDidAppearEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/event/TabScreenDidDisappearEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/event/TabScreenWillAppearEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/event/TabScreenWillDisappearEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/event/TabsHostNativeFocusChangeEvent.kt +36 -0
- package/android/src/main/java/com/swmansion/rnscreens/stack/views/ChildDrawingOrderStrategyImpl.kt +0 -1
- package/android/src/main/java/com/swmansion/rnscreens/transition/ExternalBoundaryValuesEvaluator.kt +9 -2
- package/android/src/main/java/com/swmansion/rnscreens/utils/FragmentTransactionKt.kt +4 -1
- package/android/src/main/jni/rnscreens.h +1 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSBottomTabsManagerDelegate.java +76 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSBottomTabsManagerInterface.java +33 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSBottomTabsScreenManagerDelegate.java +97 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSBottomTabsScreenManagerInterface.java +40 -0
- package/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt +2 -2
- package/android/src/versioned/backgroundcolor/76/ViewBackgroundUtils.kt +0 -1
- package/android/src/versioned/backgroundcolor/latest/ViewBackgroundUtils.kt +0 -3
- package/android/src/versioned/pointerevents/77/com/swmansion/rnscreens/PointerEventsBoxNoneImpl.kt +1 -1
- package/android/src/versioned/pointerevents/latest/com/swmansion/rnscreens/PointerEventsBoxNoneImpl.kt +1 -1
- package/common/cpp/react/renderer/components/rnscreens/RNSBottomTabsComponentDescriptor.h +31 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSBottomTabsShadowNode.cpp +20 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSBottomTabsShadowNode.h +32 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSBottomTabsState.cpp +22 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSBottomTabsState.h +44 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +8 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSSplitViewScreenComponentDescriptor.h +40 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSSplitViewScreenShadowNode.cpp +13 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSSplitViewScreenShadowNode.h +36 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSSplitViewScreenState.h +32 -0
- package/cpp/RNScreensTurboModule.h +5 -0
- package/ios/RNSEnums.h +6 -0
- package/ios/RNSScreen.h +2 -1
- package/ios/RNSScreen.mm +48 -1
- package/ios/RNSScreenContainer.mm +6 -0
- package/ios/RNSScreenStack.h +3 -1
- package/ios/RNSScreenStack.mm +39 -2
- package/ios/RNSScreenStackHeaderConfig.mm +1 -1
- package/ios/RNSScrollViewBehaviorOverriding.h +24 -0
- package/ios/RNSScrollViewFinder.h +13 -0
- package/ios/RNSScrollViewFinder.mm +22 -0
- package/ios/RNSScrollViewHelper.h +10 -0
- package/ios/RNSScrollViewHelper.mm +15 -0
- package/ios/RNScreens-Bridging-Header.h +4 -0
- package/ios/UIScrollView+RNScreens.h +14 -0
- package/ios/UIScrollView+RNScreens.mm +15 -0
- package/ios/bottom-tabs/RCTConvert+RNSBottomTabs.h +18 -0
- package/ios/bottom-tabs/RCTConvert+RNSBottomTabs.mm +25 -0
- package/ios/bottom-tabs/RNSBottomTabsHostComponentView.h +80 -0
- package/ios/bottom-tabs/RNSBottomTabsHostComponentView.mm +486 -0
- package/ios/bottom-tabs/RNSBottomTabsHostComponentViewManager.h +11 -0
- package/ios/bottom-tabs/RNSBottomTabsHostComponentViewManager.mm +48 -0
- package/ios/bottom-tabs/RNSBottomTabsHostEventEmitter.h +53 -0
- package/ios/bottom-tabs/RNSBottomTabsHostEventEmitter.mm +57 -0
- package/ios/bottom-tabs/RNSBottomTabsScreenComponentView.h +95 -0
- package/ios/bottom-tabs/RNSBottomTabsScreenComponentView.mm +492 -0
- package/ios/bottom-tabs/RNSBottomTabsScreenComponentViewManager.h +9 -0
- package/ios/bottom-tabs/RNSBottomTabsScreenComponentViewManager.mm +55 -0
- package/ios/bottom-tabs/RNSBottomTabsScreenEventEmitter.h +53 -0
- package/ios/bottom-tabs/RNSBottomTabsScreenEventEmitter.mm +106 -0
- package/ios/bottom-tabs/RNSBottomTabsSpecialEffectsSupporting.h +17 -0
- package/ios/bottom-tabs/RNSTabBarAppearanceCoordinator.h +34 -0
- package/ios/bottom-tabs/RNSTabBarAppearanceCoordinator.mm +243 -0
- package/ios/bottom-tabs/RNSTabBarAppearanceProvider.h +23 -0
- package/ios/bottom-tabs/RNSTabBarController.h +132 -0
- package/ios/bottom-tabs/RNSTabBarController.mm +206 -0
- package/ios/bottom-tabs/RNSTabBarControllerDelegate.h +9 -0
- package/ios/bottom-tabs/RNSTabBarControllerDelegate.mm +63 -0
- package/ios/bottom-tabs/RNSTabsScreenViewController.h +42 -0
- package/ios/bottom-tabs/RNSTabsScreenViewController.mm +105 -0
- package/ios/bottom-tabs/extensions/RNSBottomTabsHostComponentView+RNSImageLoader.h +21 -0
- package/ios/bottom-tabs/extensions/RNSBottomTabsHostComponentView+RNSImageLoader.mm +22 -0
- package/ios/bridging/RNSReactBaseView.h +31 -0
- package/ios/bridging/RNSReactBaseView.mm +5 -0
- package/ios/bridging/Swift-Bridging.h +7 -0
- package/ios/conversion/RNSConversions-BottomTabs.mm +216 -0
- package/ios/conversion/RNSConversions-SplitView.mm +63 -0
- package/ios/conversion/RNSConversions.h +53 -0
- package/ios/gamma/ReactMountingTransactionObserving.swift +7 -0
- package/ios/gamma/split-view/RNSSplitViewHostComponentView.h +29 -0
- package/ios/gamma/split-view/RNSSplitViewHostComponentView.mm +209 -0
- package/ios/gamma/split-view/RNSSplitViewHostComponentViewManager.h +11 -0
- package/ios/gamma/split-view/RNSSplitViewHostComponentViewManager.mm +7 -0
- package/ios/gamma/split-view/RNSSplitViewHostController.swift +98 -0
- package/ios/gamma/split-view/RNSSplitViewNavigationController.swift +31 -0
- package/ios/gamma/split-view/RNSSplitViewScreenComponentView.h +24 -0
- package/ios/gamma/split-view/RNSSplitViewScreenComponentView.mm +106 -0
- package/ios/gamma/split-view/RNSSplitViewScreenComponentViewManager.h +11 -0
- package/ios/gamma/split-view/RNSSplitViewScreenComponentViewManager.mm +7 -0
- package/ios/gamma/split-view/RNSSplitViewScreenController.swift +86 -0
- package/ios/gamma/split-view/RNSSplitViewScreenShadowStateProxy.h +35 -0
- package/ios/gamma/split-view/RNSSplitViewScreenShadowStateProxy.mm +56 -0
- package/ios/gamma/stack/RNSScreenStackHostComponentView.h +16 -0
- package/ios/gamma/stack/RNSScreenStackHostComponentView.mm +143 -0
- package/ios/gamma/stack/RNSScreenStackHostComponentViewManager.h +11 -0
- package/ios/gamma/stack/RNSScreenStackHostComponentViewManager.mm +7 -0
- package/ios/gamma/stack/RNSStackController.swift +65 -0
- package/ios/gamma/stack/RNSStackScreenComponentEventEmitter.h +37 -0
- package/ios/gamma/stack/RNSStackScreenComponentEventEmitter.mm +60 -0
- package/ios/gamma/stack/RNSStackScreenComponentView.h +36 -0
- package/ios/gamma/stack/RNSStackScreenComponentView.mm +124 -0
- package/ios/gamma/stack/RNSStackScreenComponentViewManager.h +11 -0
- package/ios/gamma/stack/RNSStackScreenComponentViewManager.mm +7 -0
- package/ios/gamma/stack/RNSStackScreenController.swift +56 -0
- package/ios/utils/NSString+RNSUtility.h +17 -0
- package/ios/utils/NSString+RNSUtility.mm +37 -0
- package/lib/commonjs/components/BottomTabs.js +54 -0
- package/lib/commonjs/components/BottomTabs.js.map +1 -0
- package/lib/commonjs/components/BottomTabsScreen.js +149 -0
- package/lib/commonjs/components/BottomTabsScreen.js.map +1 -0
- package/lib/commonjs/components/gamma/ScreenStackHost.js +27 -0
- package/lib/commonjs/components/gamma/ScreenStackHost.js.map +1 -0
- package/lib/commonjs/components/gamma/SplitViewHost.js +57 -0
- package/lib/commonjs/components/gamma/SplitViewHost.js.map +1 -0
- package/lib/commonjs/components/gamma/SplitViewScreen.js +22 -0
- package/lib/commonjs/components/gamma/SplitViewScreen.js.map +1 -0
- package/lib/commonjs/components/gamma/StackScreen.js +51 -0
- package/lib/commonjs/components/gamma/StackScreen.js.map +1 -0
- package/lib/commonjs/fabric/BottomTabsNativeComponent.js +19 -0
- package/lib/commonjs/fabric/BottomTabsNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/BottomTabsScreenNativeComponent.js +14 -0
- package/lib/commonjs/fabric/BottomTabsScreenNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/gamma/ScreenStackHostNativeComponent.js +11 -0
- package/lib/commonjs/fabric/gamma/ScreenStackHostNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/gamma/SplitViewHostNativeComponent.js +11 -0
- package/lib/commonjs/fabric/gamma/SplitViewHostNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/gamma/SplitViewScreenNativeComponent.js +13 -0
- package/lib/commonjs/fabric/gamma/SplitViewScreenNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/gamma/StackScreenNativeComponent.js +12 -0
- package/lib/commonjs/fabric/gamma/StackScreenNativeComponent.js.map +1 -0
- package/lib/commonjs/flags.js +70 -0
- package/lib/commonjs/flags.js.map +1 -0
- package/lib/commonjs/index.js +66 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils.js +0 -28
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/components/BottomTabs.js +48 -0
- package/lib/module/components/BottomTabs.js.map +1 -0
- package/lib/module/components/BottomTabsScreen.js +144 -0
- package/lib/module/components/BottomTabsScreen.js.map +1 -0
- package/lib/module/components/gamma/ScreenStackHost.js +20 -0
- package/lib/module/components/gamma/ScreenStackHost.js.map +1 -0
- package/lib/module/components/gamma/SplitViewHost.js +50 -0
- package/lib/module/components/gamma/SplitViewHost.js.map +1 -0
- package/lib/module/components/gamma/SplitViewScreen.js +15 -0
- package/lib/module/components/gamma/SplitViewScreen.js.map +1 -0
- package/lib/module/components/gamma/StackScreen.js +44 -0
- package/lib/module/components/gamma/StackScreen.js.map +1 -0
- package/lib/module/fabric/BottomTabsNativeComponent.js +15 -0
- package/lib/module/fabric/BottomTabsNativeComponent.js.map +1 -0
- package/lib/module/fabric/BottomTabsScreenNativeComponent.js +12 -0
- package/lib/module/fabric/BottomTabsScreenNativeComponent.js.map +1 -0
- package/lib/module/fabric/gamma/ScreenStackHostNativeComponent.js +5 -0
- package/lib/module/fabric/gamma/ScreenStackHostNativeComponent.js.map +1 -0
- package/lib/module/fabric/gamma/SplitViewHostNativeComponent.js +5 -0
- package/lib/module/fabric/gamma/SplitViewHostNativeComponent.js.map +1 -0
- package/lib/module/fabric/gamma/SplitViewScreenNativeComponent.js +7 -0
- package/lib/module/fabric/gamma/SplitViewScreenNativeComponent.js.map +1 -0
- package/lib/module/fabric/gamma/StackScreenNativeComponent.js +8 -0
- package/lib/module/fabric/gamma/StackScreenNativeComponent.js.map +1 -0
- package/lib/module/flags.js +64 -0
- package/lib/module/flags.js.map +1 -0
- package/lib/module/index.js +16 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils.js +0 -27
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/components/BottomTabs.d.ts +30 -0
- package/lib/typescript/components/BottomTabs.d.ts.map +1 -0
- package/lib/typescript/components/BottomTabsScreen.d.ts +56 -0
- package/lib/typescript/components/BottomTabsScreen.d.ts.map +1 -0
- package/lib/typescript/components/gamma/ScreenStackHost.d.ts +13 -0
- package/lib/typescript/components/gamma/ScreenStackHost.d.ts.map +1 -0
- package/lib/typescript/components/gamma/SplitViewHost.d.ts +13 -0
- package/lib/typescript/components/gamma/SplitViewHost.d.ts.map +1 -0
- package/lib/typescript/components/gamma/SplitViewScreen.d.ts +13 -0
- package/lib/typescript/components/gamma/SplitViewScreen.d.ts.map +1 -0
- package/lib/typescript/components/gamma/StackScreen.d.ts +21 -0
- package/lib/typescript/components/gamma/StackScreen.d.ts.map +1 -0
- package/lib/typescript/fabric/BottomTabsNativeComponent.d.ts +31 -0
- package/lib/typescript/fabric/BottomTabsNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/BottomTabsScreenNativeComponent.d.ts +51 -0
- package/lib/typescript/fabric/BottomTabsScreenNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/gamma/ScreenStackHostNativeComponent.d.ts +7 -0
- package/lib/typescript/fabric/gamma/ScreenStackHostNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/gamma/SplitViewHostNativeComponent.d.ts +16 -0
- package/lib/typescript/fabric/gamma/SplitViewHostNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/gamma/SplitViewScreenNativeComponent.d.ts +7 -0
- package/lib/typescript/fabric/gamma/SplitViewScreenNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/gamma/StackScreenNativeComponent.d.ts +15 -0
- package/lib/typescript/fabric/gamma/StackScreenNativeComponent.d.ts.map +1 -0
- package/lib/typescript/flags.d.ts +45 -0
- package/lib/typescript/flags.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +14 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils.d.ts +0 -26
- package/lib/typescript/utils.d.ts.map +1 -1
- package/package.json +34 -6
- package/react-native.config.js +2 -1
- package/src/components/BottomTabs.tsx +115 -0
- package/src/components/BottomTabsScreen.tsx +291 -0
- package/src/components/gamma/ScreenStackHost.tsx +32 -0
- package/src/components/gamma/SplitViewHost.tsx +84 -0
- package/src/components/gamma/SplitViewScreen.tsx +26 -0
- package/src/components/gamma/StackScreen.tsx +64 -0
- package/src/fabric/BottomTabsNativeComponent.ts +82 -0
- package/src/fabric/BottomTabsScreenNativeComponent.ts +107 -0
- package/src/fabric/gamma/ScreenStackHostNativeComponent.ts +8 -0
- package/src/fabric/gamma/SplitViewHostNativeComponent.ts +39 -0
- package/src/fabric/gamma/SplitViewScreenNativeComponent.ts +10 -0
- package/src/fabric/gamma/StackScreenNativeComponent.ts +25 -0
- package/src/flags.ts +72 -0
- package/src/index.tsx +18 -1
- package/src/utils.ts +0 -28
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#import "UIScrollView+RNScreens.h"
|
|
2
|
+
|
|
3
|
+
@implementation UIScrollView (RNScreens)
|
|
4
|
+
|
|
5
|
+
- (BOOL)rnscreens_scrollToTop
|
|
6
|
+
{
|
|
7
|
+
if ([self contentOffset].y != -self.adjustedContentInset.top) {
|
|
8
|
+
[self setContentOffset:CGPointMake(0, -self.adjustedContentInset.top) animated:YES];
|
|
9
|
+
return YES;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return NO;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
#import <React/RCTConvert.h>
|
|
4
|
+
#import "RNSEnums.h"
|
|
5
|
+
|
|
6
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
7
|
+
|
|
8
|
+
@interface RCTConvert (RNSBottomTabs)
|
|
9
|
+
|
|
10
|
+
+ (UIOffset)UIOffset:(nonnull id)json;
|
|
11
|
+
|
|
12
|
+
+ (RNSBottomTabsIconType)RNSBottomTabsIconType:(nonnull id)json;
|
|
13
|
+
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
NS_ASSUME_NONNULL_END
|
|
17
|
+
|
|
18
|
+
#endif // !RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
2
|
+
#import "RCTConvert+RNSBottomTabs.h"
|
|
3
|
+
|
|
4
|
+
@implementation RCTConvert (RNSBottomTabs)
|
|
5
|
+
|
|
6
|
+
+ (UIOffset)UIOffset:(id)json;
|
|
7
|
+
{
|
|
8
|
+
json = [self NSDictionary:json];
|
|
9
|
+
return UIOffsetMake([json[@"horizontal"] floatValue], [json[@"vertical"] floatValue]);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
RCT_ENUM_CONVERTER(
|
|
13
|
+
RNSBottomTabsIconType,
|
|
14
|
+
(@{
|
|
15
|
+
@"image": @(RNSBottomTabsIconTypeImage),
|
|
16
|
+
@"template": @(RNSBottomTabsIconTypeTemplate),
|
|
17
|
+
@"sfSymbol": @(RNSBottomTabsIconTypeSfSymbol),
|
|
18
|
+
}),
|
|
19
|
+
RNSBottomTabsIconTypeSfSymbol,
|
|
20
|
+
integerValue
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
@end
|
|
24
|
+
|
|
25
|
+
#endif // !RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#import "RNSBottomTabsHostComponentViewManager.h"
|
|
2
|
+
#import "RNSBottomTabsHostEventEmitter.h"
|
|
3
|
+
#import "RNSEnums.h"
|
|
4
|
+
#import "RNSReactBaseView.h"
|
|
5
|
+
#import "RNSScreenContainer.h"
|
|
6
|
+
#import "RNSTabBarAppearanceProvider.h"
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
@class RNSBottomTabsScreenComponentView;
|
|
11
|
+
@class RCTImageLoader;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Component view. Lifecycle is managed by React Native.
|
|
15
|
+
*
|
|
16
|
+
* This component serves as:
|
|
17
|
+
* 1. host for UITabBarController
|
|
18
|
+
* 2. provider of React state & props for the tab bar controller
|
|
19
|
+
* 3. two way communication channel with React (commands & events)
|
|
20
|
+
*/
|
|
21
|
+
@interface RNSBottomTabsHostComponentView : RNSReactBaseView <RNSScreenContainerDelegate>
|
|
22
|
+
|
|
23
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
24
|
+
- (instancetype)initWithFrame:(CGRect)frame reactImageLoader:(RCTImageLoader *)imageLoader;
|
|
25
|
+
#endif // !RCT_NEW_ARCH_ENABLED
|
|
26
|
+
|
|
27
|
+
@end
|
|
28
|
+
|
|
29
|
+
#pragma mark - Props
|
|
30
|
+
|
|
31
|
+
@interface RNSBottomTabsHostComponentView () <RNSTabBarAppearanceProvider>
|
|
32
|
+
|
|
33
|
+
@property (nonatomic, strong, readonly, nullable) UIColor *tabBarBackgroundColor;
|
|
34
|
+
@property (nonatomic, strong, readonly, nullable) UIBlurEffect *tabBarBlurEffect;
|
|
35
|
+
@property (nonatomic, strong, readonly, nullable) UIColor *tabBarTintColor;
|
|
36
|
+
|
|
37
|
+
@property (nonatomic, strong, readonly, nullable) NSString *tabBarItemTitleFontFamily;
|
|
38
|
+
@property (nonatomic, strong, readonly, nullable) NSNumber *tabBarItemTitleFontSize;
|
|
39
|
+
@property (nonatomic, strong, readonly, nullable) NSString *tabBarItemTitleFontWeight;
|
|
40
|
+
@property (nonatomic, strong, readonly, nullable) NSString *tabBarItemTitleFontStyle;
|
|
41
|
+
@property (nonatomic, strong, readonly, nullable) UIColor *tabBarItemTitleFontColor;
|
|
42
|
+
@property (nonatomic, readonly) UIOffset tabBarItemTitlePositionAdjustment;
|
|
43
|
+
|
|
44
|
+
@property (nonatomic, strong, readonly, nullable) UIColor *tabBarItemIconColor;
|
|
45
|
+
|
|
46
|
+
@property (nonatomic, readonly, nullable) UIColor *tabBarItemBadgeBackgroundColor;
|
|
47
|
+
|
|
48
|
+
@property (nonatomic, readonly) BOOL experimental_controlNavigationStateInJS;
|
|
49
|
+
|
|
50
|
+
@end
|
|
51
|
+
|
|
52
|
+
#pragma mark - React Events
|
|
53
|
+
|
|
54
|
+
@interface RNSBottomTabsHostComponentView ()
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Use returned object to emit appropriate React Events to Element Tree.
|
|
58
|
+
*/
|
|
59
|
+
- (nonnull RNSBottomTabsHostEventEmitter *)reactEventEmitter;
|
|
60
|
+
|
|
61
|
+
- (BOOL)emitOnNativeFocusChangeRequestSelectedTabScreen:(nonnull RNSBottomTabsScreenComponentView *)tabScreen;
|
|
62
|
+
|
|
63
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
64
|
+
#pragma mark - LEGACY Event blocks
|
|
65
|
+
|
|
66
|
+
@property (nonatomic, copy) RCTDirectEventBlock onNativeFocusChange;
|
|
67
|
+
|
|
68
|
+
#endif
|
|
69
|
+
|
|
70
|
+
@end
|
|
71
|
+
|
|
72
|
+
#pragma mark - React Image Loader
|
|
73
|
+
|
|
74
|
+
@interface RNSBottomTabsHostComponentView ()
|
|
75
|
+
|
|
76
|
+
- (nullable RCTImageLoader *)reactImageLoader;
|
|
77
|
+
|
|
78
|
+
@end
|
|
79
|
+
|
|
80
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
#import "RNSBottomTabsHostComponentView.h"
|
|
2
|
+
|
|
3
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
4
|
+
#import <React/RCTConversions.h>
|
|
5
|
+
#import <React/RCTImageLoader.h>
|
|
6
|
+
#import <React/RCTMountingTransactionObserving.h>
|
|
7
|
+
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
|
|
8
|
+
#import <react/renderer/components/rnscreens/EventEmitters.h>
|
|
9
|
+
#import <react/renderer/components/rnscreens/Props.h>
|
|
10
|
+
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
|
|
11
|
+
#import <rnscreens/RNSBottomTabsComponentDescriptor.h>
|
|
12
|
+
#import "RNSBottomTabsHostComponentView+RNSImageLoader.h"
|
|
13
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
14
|
+
|
|
15
|
+
#import "RNSBottomTabsScreenComponentView.h"
|
|
16
|
+
#import "RNSConversions.h"
|
|
17
|
+
#import "RNSConvert.h"
|
|
18
|
+
#import "RNSDefines.h"
|
|
19
|
+
#import "RNSTabBarController.h"
|
|
20
|
+
#import "RNSTabBarControllerDelegate.h"
|
|
21
|
+
|
|
22
|
+
namespace react = facebook::react;
|
|
23
|
+
|
|
24
|
+
#pragma mark - View implementation
|
|
25
|
+
|
|
26
|
+
@interface RNSBottomTabsHostComponentView ()
|
|
27
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
28
|
+
<RCTMountingTransactionObserving>
|
|
29
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
30
|
+
@end
|
|
31
|
+
|
|
32
|
+
@implementation RNSBottomTabsHostComponentView {
|
|
33
|
+
RNSTabBarController *_controller;
|
|
34
|
+
RNSTabBarControllerDelegate *_controllerDelegate;
|
|
35
|
+
|
|
36
|
+
RNSBottomTabsHostEventEmitter *_Nonnull _reactEventEmitter;
|
|
37
|
+
|
|
38
|
+
RCTImageLoader *_Nullable _imageLoader;
|
|
39
|
+
|
|
40
|
+
// RCTViewComponentView does not expose this field, therefore we maintain
|
|
41
|
+
// it on our side.
|
|
42
|
+
NSMutableArray<RNSBottomTabsScreenComponentView *> *_reactSubviews;
|
|
43
|
+
BOOL _hasModifiedReactSubviewsInCurrentTransaction;
|
|
44
|
+
BOOL _needsTabBarAppearanceUpdate;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
48
|
+
{
|
|
49
|
+
if (self = [super initWithFrame:frame]) {
|
|
50
|
+
[self initState];
|
|
51
|
+
}
|
|
52
|
+
return self;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
56
|
+
- (instancetype)initWithFrame:(CGRect)frame reactImageLoader:(RCTImageLoader *)imageLoader
|
|
57
|
+
{
|
|
58
|
+
if (self = [self initWithFrame:frame]) {
|
|
59
|
+
_imageLoader = imageLoader;
|
|
60
|
+
}
|
|
61
|
+
return self;
|
|
62
|
+
}
|
|
63
|
+
#endif // !RCT_NEW_ARCH_ENABLED
|
|
64
|
+
|
|
65
|
+
- (void)initState
|
|
66
|
+
{
|
|
67
|
+
[self resetProps];
|
|
68
|
+
|
|
69
|
+
_controller = [[RNSTabBarController alloc] initWithTabsHostComponentView:self];
|
|
70
|
+
_controllerDelegate = [RNSTabBarControllerDelegate new];
|
|
71
|
+
_controller.delegate = _controllerDelegate;
|
|
72
|
+
|
|
73
|
+
_reactSubviews = [NSMutableArray new];
|
|
74
|
+
_reactEventEmitter = [RNSBottomTabsHostEventEmitter new];
|
|
75
|
+
|
|
76
|
+
_hasModifiedReactSubviewsInCurrentTransaction = NO;
|
|
77
|
+
_needsTabBarAppearanceUpdate = NO;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
- (void)resetProps
|
|
81
|
+
{
|
|
82
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
83
|
+
static const auto defaultProps = std::make_shared<const react::RNSBottomTabsProps>();
|
|
84
|
+
_props = defaultProps;
|
|
85
|
+
#endif
|
|
86
|
+
_tabBarBlurEffect = nil;
|
|
87
|
+
_tabBarBackgroundColor = nil;
|
|
88
|
+
_tabBarTintColor = nil;
|
|
89
|
+
|
|
90
|
+
_tabBarItemTitleFontFamily = nil;
|
|
91
|
+
_tabBarItemTitleFontSize = nil;
|
|
92
|
+
_tabBarItemTitleFontWeight = nil;
|
|
93
|
+
_tabBarItemTitleFontStyle = nil;
|
|
94
|
+
_tabBarItemTitleFontColor = nil;
|
|
95
|
+
_tabBarItemTitlePositionAdjustment = UIOffsetMake(0.0, 0.0);
|
|
96
|
+
|
|
97
|
+
_tabBarItemIconColor = nil;
|
|
98
|
+
|
|
99
|
+
_tabBarItemBadgeBackgroundColor = nil;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#pragma mark - UIView methods
|
|
103
|
+
|
|
104
|
+
- (void)didMoveToWindow
|
|
105
|
+
{
|
|
106
|
+
[self reactAddControllerToClosestParent:_controller];
|
|
107
|
+
|
|
108
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
109
|
+
// This is required on legacy architecture to prevent a bug with doubled size of UIViewControllerWrapperView.
|
|
110
|
+
_controller.view.frame = self.bounds;
|
|
111
|
+
#endif // !RCT_NEW_ARCH_ENABLED
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
- (void)reactAddControllerToClosestParent:(UIViewController *)controller
|
|
115
|
+
{
|
|
116
|
+
if (!controller.parentViewController) {
|
|
117
|
+
UIView *parentView = (UIView *)self.reactSuperview;
|
|
118
|
+
while (parentView) {
|
|
119
|
+
if (parentView.reactViewController) {
|
|
120
|
+
[parentView.reactViewController addChildViewController:controller];
|
|
121
|
+
[self addSubview:controller.view];
|
|
122
|
+
[controller didMoveToParentViewController:parentView.reactViewController];
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
parentView = (UIView *)parentView.reactSuperview;
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#pragma mark - RNSScreenContainerDelegate
|
|
132
|
+
|
|
133
|
+
- (void)updateContainer
|
|
134
|
+
{
|
|
135
|
+
NSMutableArray<RNSTabsScreenViewController *> *tabControllers =
|
|
136
|
+
[[NSMutableArray alloc] initWithCapacity:_reactSubviews.count];
|
|
137
|
+
for (RNSBottomTabsScreenComponentView *childView in _reactSubviews) {
|
|
138
|
+
[tabControllers addObject:childView.controller];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
NSLog(@"updateContainer: tabControllers: %@", tabControllers);
|
|
142
|
+
|
|
143
|
+
[_controller childViewControllersHaveChangedTo:tabControllers];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
- (void)markChildUpdated
|
|
147
|
+
{
|
|
148
|
+
[self updateContainer];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#pragma mark - React events
|
|
152
|
+
|
|
153
|
+
- (nonnull RNSBottomTabsHostEventEmitter *)reactEventEmitter
|
|
154
|
+
{
|
|
155
|
+
RCTAssert(_reactEventEmitter != nil, @"[RNScreens] Attempt to access uninitialized _reactEventEmitter");
|
|
156
|
+
return _reactEventEmitter;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
- (BOOL)emitOnNativeFocusChangeRequestSelectedTabScreen:(RNSBottomTabsScreenComponentView *)tabScreen
|
|
160
|
+
{
|
|
161
|
+
return [_reactEventEmitter emitOnNativeFocusChange:OnNativeFocusChangePayload{.tabKey = tabScreen.tabKey}];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#pragma mark - RCTViewComponentViewProtocol
|
|
165
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
166
|
+
|
|
167
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
168
|
+
{
|
|
169
|
+
RCTAssert(
|
|
170
|
+
[childComponentView isKindOfClass:RNSBottomTabsScreenComponentView.class],
|
|
171
|
+
@"BottomTabsView only accepts children of type BottomTabScreen. Attempted to mount %@",
|
|
172
|
+
childComponentView);
|
|
173
|
+
|
|
174
|
+
auto *childScreen = static_cast<RNSBottomTabsScreenComponentView *>(childComponentView);
|
|
175
|
+
childScreen.reactSuperview = self;
|
|
176
|
+
|
|
177
|
+
[_reactSubviews insertObject:childScreen atIndex:index];
|
|
178
|
+
_hasModifiedReactSubviewsInCurrentTransaction = YES;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
182
|
+
{
|
|
183
|
+
RCTAssert(
|
|
184
|
+
[childComponentView isKindOfClass:RNSBottomTabsScreenComponentView.class],
|
|
185
|
+
@"BottomTabsView only accepts children of type BottomTabScreen. Attempted to unmount %@",
|
|
186
|
+
childComponentView);
|
|
187
|
+
|
|
188
|
+
auto *childScreen = static_cast<RNSBottomTabsScreenComponentView *>(childComponentView);
|
|
189
|
+
childScreen.reactSuperview = nil;
|
|
190
|
+
|
|
191
|
+
[_reactSubviews removeObject:childScreen];
|
|
192
|
+
_hasModifiedReactSubviewsInCurrentTransaction = YES;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
- (void)updateProps:(const facebook::react::Props::Shared &)props
|
|
196
|
+
oldProps:(const facebook::react::Props::Shared &)oldProps
|
|
197
|
+
{
|
|
198
|
+
const auto &oldComponentProps = *std::static_pointer_cast<const react::RNSBottomTabsProps>(_props);
|
|
199
|
+
const auto &newComponentProps = *std::static_pointer_cast<const react::RNSBottomTabsProps>(props);
|
|
200
|
+
|
|
201
|
+
if (newComponentProps.controlNavigationStateInJS != oldComponentProps.controlNavigationStateInJS) {
|
|
202
|
+
_experimental_controlNavigationStateInJS = newComponentProps.controlNavigationStateInJS;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (newComponentProps.tabBarBackgroundColor != oldComponentProps.tabBarBackgroundColor) {
|
|
206
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
207
|
+
_tabBarBackgroundColor = RCTUIColorFromSharedColor(newComponentProps.tabBarBackgroundColor);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (newComponentProps.tabBarBlurEffect != oldComponentProps.tabBarBlurEffect) {
|
|
211
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
212
|
+
_tabBarBlurEffect =
|
|
213
|
+
rnscreens::conversion::RNSUIBlurEffectFromRNSBottomTabsTabBarBlurEffect(newComponentProps.tabBarBlurEffect);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (newComponentProps.tabBarTintColor != oldComponentProps.tabBarTintColor) {
|
|
217
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
218
|
+
_tabBarTintColor = RCTUIColorFromSharedColor(newComponentProps.tabBarTintColor);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (newComponentProps.tabBarItemTitleFontFamily != oldComponentProps.tabBarItemTitleFontFamily) {
|
|
222
|
+
_tabBarItemTitleFontFamily = RCTNSStringFromStringNilIfEmpty(newComponentProps.tabBarItemTitleFontFamily);
|
|
223
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (newComponentProps.tabBarItemTitleFontSize != oldComponentProps.tabBarItemTitleFontSize) {
|
|
227
|
+
_tabBarItemTitleFontSize = [NSNumber numberWithFloat:newComponentProps.tabBarItemTitleFontSize];
|
|
228
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (newComponentProps.tabBarItemTitleFontWeight != oldComponentProps.tabBarItemTitleFontWeight) {
|
|
232
|
+
_tabBarItemTitleFontWeight = RCTNSStringFromStringNilIfEmpty(newComponentProps.tabBarItemTitleFontWeight);
|
|
233
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (newComponentProps.tabBarItemTitleFontStyle != oldComponentProps.tabBarItemTitleFontStyle) {
|
|
237
|
+
_tabBarItemTitleFontStyle = RCTNSStringFromStringNilIfEmpty(newComponentProps.tabBarItemTitleFontStyle);
|
|
238
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (newComponentProps.tabBarItemTitleFontColor != oldComponentProps.tabBarItemTitleFontColor) {
|
|
242
|
+
_tabBarItemTitleFontColor = RCTUIColorFromSharedColor(newComponentProps.tabBarItemTitleFontColor);
|
|
243
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (newComponentProps.tabBarItemIconColor != oldComponentProps.tabBarItemIconColor) {
|
|
247
|
+
_tabBarItemIconColor = RCTUIColorFromSharedColor(newComponentProps.tabBarItemIconColor);
|
|
248
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (newComponentProps.tabBarItemBadgeBackgroundColor != oldComponentProps.tabBarItemBadgeBackgroundColor) {
|
|
252
|
+
_tabBarItemBadgeBackgroundColor = RCTUIColorFromSharedColor(newComponentProps.tabBarItemBadgeBackgroundColor);
|
|
253
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (newComponentProps.tabBarItemTitlePositionAdjustment.horizontal !=
|
|
257
|
+
oldComponentProps.tabBarItemTitlePositionAdjustment.horizontal ||
|
|
258
|
+
newComponentProps.tabBarItemTitlePositionAdjustment.vertical !=
|
|
259
|
+
oldComponentProps.tabBarItemTitlePositionAdjustment.vertical) {
|
|
260
|
+
_tabBarItemTitlePositionAdjustment = rnscreens::conversion::RNSBottomTabsTabBarItemTitlePositionAdjustmentStruct(
|
|
261
|
+
newComponentProps.tabBarItemTitlePositionAdjustment);
|
|
262
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Super call updates _props pointer. We should NOT update it before calling super.
|
|
266
|
+
[super updateProps:props oldProps:oldProps];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
- (void)updateState:(const facebook::react::State::Shared &)state
|
|
270
|
+
oldState:(const facebook::react::State::Shared &)oldState
|
|
271
|
+
{
|
|
272
|
+
react::RNSBottomTabsShadowNode::ConcreteState::Shared receivedState =
|
|
273
|
+
std::static_pointer_cast<const react::RNSBottomTabsShadowNode::ConcreteState>(state);
|
|
274
|
+
|
|
275
|
+
_imageLoader = [self retrieveImageLoaderFromState:receivedState];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
- (void)updateEventEmitter:(const facebook::react::EventEmitter::Shared &)eventEmitter
|
|
279
|
+
{
|
|
280
|
+
[super updateEventEmitter:eventEmitter];
|
|
281
|
+
|
|
282
|
+
const auto &castedEventEmitter = std::static_pointer_cast<const react::RNSBottomTabsEventEmitter>(eventEmitter);
|
|
283
|
+
[_reactEventEmitter updateEventEmitter:castedEventEmitter];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask
|
|
287
|
+
{
|
|
288
|
+
if (_needsTabBarAppearanceUpdate) {
|
|
289
|
+
_needsTabBarAppearanceUpdate = NO;
|
|
290
|
+
[_controller setNeedsUpdateOfTabBarAppearance:true];
|
|
291
|
+
}
|
|
292
|
+
[super finalizeUpdates:updateMask];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
+ (react::ComponentDescriptorProvider)componentDescriptorProvider
|
|
296
|
+
{
|
|
297
|
+
return react::concreteComponentDescriptorProvider<react::RNSBottomTabsComponentDescriptor>();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
+ (BOOL)shouldBeRecycled
|
|
301
|
+
{
|
|
302
|
+
// There won't be tens of instances of this component usually & it's easier for now.
|
|
303
|
+
// We could consider enabling it someday though.
|
|
304
|
+
return NO;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
#pragma mark - RCTMountingTransactionObserving
|
|
308
|
+
|
|
309
|
+
- (void)mountingTransactionWillMount:(const facebook::react::MountingTransaction &)transaction
|
|
310
|
+
withSurfaceTelemetry:(const facebook::react::SurfaceTelemetry &)surfaceTelemetry
|
|
311
|
+
{
|
|
312
|
+
_hasModifiedReactSubviewsInCurrentTransaction = NO;
|
|
313
|
+
[_controller reactMountingTransactionWillMount];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
- (void)mountingTransactionDidMount:(const facebook::react::MountingTransaction &)transaction
|
|
317
|
+
withSurfaceTelemetry:(const facebook::react::SurfaceTelemetry &)surfaceTelemetry
|
|
318
|
+
{
|
|
319
|
+
if (_hasModifiedReactSubviewsInCurrentTransaction) {
|
|
320
|
+
[self updateContainer];
|
|
321
|
+
}
|
|
322
|
+
[_controller reactMountingTransactionDidMount];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
#else
|
|
326
|
+
#pragma mark - LEGACY architecture implementation
|
|
327
|
+
|
|
328
|
+
#pragma mark - LEGACY RCTComponent protocol
|
|
329
|
+
|
|
330
|
+
RNS_IGNORE_SUPER_CALL_BEGIN
|
|
331
|
+
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)index
|
|
332
|
+
{
|
|
333
|
+
RCTAssert(
|
|
334
|
+
[subview isKindOfClass:RNSBottomTabsScreenComponentView.class],
|
|
335
|
+
@"BottomTabsView only accepts children of type BottomTabScreen. Attempted to mount %@",
|
|
336
|
+
subview);
|
|
337
|
+
|
|
338
|
+
auto *childScreen = static_cast<RNSBottomTabsScreenComponentView *>(subview);
|
|
339
|
+
childScreen.reactSuperview = self;
|
|
340
|
+
|
|
341
|
+
[_reactSubviews insertObject:childScreen atIndex:index];
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
- (void)removeReactSubview:(UIView *)subview
|
|
345
|
+
{
|
|
346
|
+
RCTAssert(
|
|
347
|
+
[subview isKindOfClass:RNSBottomTabsScreenComponentView.class],
|
|
348
|
+
@"BottomTabsView only accepts children of type BottomTabScreen. Attempted to unmount %@",
|
|
349
|
+
subview);
|
|
350
|
+
|
|
351
|
+
auto *childScreen = static_cast<RNSBottomTabsScreenComponentView *>(subview);
|
|
352
|
+
childScreen.reactSuperview = nil;
|
|
353
|
+
|
|
354
|
+
[_reactSubviews removeObject:childScreen];
|
|
355
|
+
}
|
|
356
|
+
RNS_IGNORE_SUPER_CALL_END
|
|
357
|
+
|
|
358
|
+
- (void)didUpdateReactSubviews
|
|
359
|
+
{
|
|
360
|
+
[super didUpdateReactSubviews];
|
|
361
|
+
_hasModifiedReactSubviewsInCurrentTransaction = YES;
|
|
362
|
+
[self invalidateFlagsOnControllerIfNeeded];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
- (void)didSetProps:(NSArray<NSString *> *)changedProps
|
|
366
|
+
{
|
|
367
|
+
[super didSetProps:changedProps];
|
|
368
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
369
|
+
[self invalidateFlagsOnControllerIfNeeded];
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
#pragma mark - LEGACY update methods
|
|
373
|
+
|
|
374
|
+
- (void)invalidateFlagsOnControllerIfNeeded
|
|
375
|
+
{
|
|
376
|
+
if (_needsTabBarAppearanceUpdate) {
|
|
377
|
+
_needsTabBarAppearanceUpdate = NO;
|
|
378
|
+
[_controller setNeedsUpdateOfTabBarAppearance:true];
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (_hasModifiedReactSubviewsInCurrentTransaction) {
|
|
382
|
+
_hasModifiedReactSubviewsInCurrentTransaction = NO;
|
|
383
|
+
[self updateContainer];
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
- (void)invalidateTabBarAppearance
|
|
388
|
+
{
|
|
389
|
+
_needsTabBarAppearanceUpdate = YES;
|
|
390
|
+
[self invalidateFlagsOnControllerIfNeeded];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
#pragma mark - LEGACY prop setters
|
|
394
|
+
|
|
395
|
+
// Paper will call property setters
|
|
396
|
+
|
|
397
|
+
- (void)setTabBarBackgroundColor:(UIColor *_Nullable)tabBarBackgroundColor
|
|
398
|
+
{
|
|
399
|
+
_tabBarBackgroundColor = tabBarBackgroundColor;
|
|
400
|
+
[self invalidateTabBarAppearance];
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
- (void)setTabBarBlurEffect:(UIBlurEffect *_Nullable)tabBarBlurEffect
|
|
404
|
+
{
|
|
405
|
+
_tabBarBlurEffect = tabBarBlurEffect;
|
|
406
|
+
[self invalidateTabBarAppearance];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
- (void)setTabBarTintColor:(UIColor *_Nullable)tabBarTintColor
|
|
410
|
+
{
|
|
411
|
+
_tabBarTintColor = tabBarTintColor;
|
|
412
|
+
[self invalidateTabBarAppearance];
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
- (void)setTabBarItemTitleFontFamily:(NSString *_Nullable)tabBarItemTitleFontFamily
|
|
416
|
+
{
|
|
417
|
+
_tabBarItemTitleFontFamily = tabBarItemTitleFontFamily;
|
|
418
|
+
[self invalidateTabBarAppearance];
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
- (void)setTabBarItemTitleFontSize:(NSNumber *_Nullable)tabBarItemTitleFontSize
|
|
422
|
+
{
|
|
423
|
+
_tabBarItemTitleFontSize = tabBarItemTitleFontSize;
|
|
424
|
+
[self invalidateTabBarAppearance];
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
- (void)setTabBarItemTitleFontWeight:(NSString *_Nullable)tabBarItemTitleFontWeight
|
|
428
|
+
{
|
|
429
|
+
_tabBarItemTitleFontWeight = tabBarItemTitleFontWeight;
|
|
430
|
+
[self invalidateTabBarAppearance];
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
- (void)setTabBarItemTitleFontStyle:(NSString *_Nullable)tabBarItemTitleFontStyle
|
|
434
|
+
{
|
|
435
|
+
_tabBarItemTitleFontStyle = tabBarItemTitleFontStyle;
|
|
436
|
+
[self invalidateTabBarAppearance];
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
- (void)setTabBarItemTitleFontColor:(UIColor *_Nullable)tabBarItemTitleFontColor
|
|
440
|
+
{
|
|
441
|
+
_tabBarItemTitleFontColor = tabBarItemTitleFontColor;
|
|
442
|
+
[self invalidateTabBarAppearance];
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
- (void)setTabBarItemIconColor:(UIColor *_Nullable)tabBarItemIconColor
|
|
446
|
+
{
|
|
447
|
+
_tabBarItemIconColor = tabBarItemIconColor;
|
|
448
|
+
[self invalidateTabBarAppearance];
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
- (void)setTabBarItemBadgeBackgroundColor:(UIColor *_Nullable)tabBarItemBadgeBackgroundColor
|
|
452
|
+
{
|
|
453
|
+
_tabBarItemBadgeBackgroundColor = tabBarItemBadgeBackgroundColor;
|
|
454
|
+
[self invalidateTabBarAppearance];
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
- (void)setTabBarItemTitlePositionAdjustment:(UIOffset)tabBarItemTitlePositionAdjustment
|
|
458
|
+
{
|
|
459
|
+
_tabBarItemTitlePositionAdjustment = tabBarItemTitlePositionAdjustment;
|
|
460
|
+
[self invalidateTabBarAppearance];
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
- (void)setOnNativeFocusChange:(RCTDirectEventBlock)onNativeFocusChange
|
|
464
|
+
{
|
|
465
|
+
[self.reactEventEmitter setOnNativeFocusChange:onNativeFocusChange];
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
469
|
+
|
|
470
|
+
#pragma mark - React Image Loader
|
|
471
|
+
|
|
472
|
+
- (nullable RCTImageLoader *)reactImageLoader
|
|
473
|
+
{
|
|
474
|
+
return _imageLoader;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
@end
|
|
478
|
+
|
|
479
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
480
|
+
#pragma mark - View class exposure
|
|
481
|
+
|
|
482
|
+
Class<RCTComponentViewProtocol> RNSBottomTabsCls(void)
|
|
483
|
+
{
|
|
484
|
+
return RNSBottomTabsHostComponentView.class;
|
|
485
|
+
}
|
|
486
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#import "RNSBottomTabsHostComponentViewManager.h"
|
|
2
|
+
|
|
3
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
4
|
+
#import "RNSBottomTabsHostComponentView.h"
|
|
5
|
+
#import <React/RCTImageLoader.h>
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
@implementation RNSBottomTabsHostComponentViewManager
|
|
9
|
+
|
|
10
|
+
// TODO: This seems to be legacy arch only - test & remove when no longer needed
|
|
11
|
+
|
|
12
|
+
RCT_EXPORT_MODULE(RNSBottomTabsManager)
|
|
13
|
+
|
|
14
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
15
|
+
|
|
16
|
+
- (UIView *)view
|
|
17
|
+
{
|
|
18
|
+
// For Paper, we need to initialize TabsHost with RCTImageLoader from bridge
|
|
19
|
+
return [[RNSBottomTabsHostComponentView alloc] initWithFrame:CGRectZero
|
|
20
|
+
reactImageLoader:[self.bridge moduleForClass:[RCTImageLoader class]]];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#pragma mark - LEGACY Props
|
|
24
|
+
|
|
25
|
+
RCT_EXPORT_VIEW_PROPERTY(tabBarBackgroundColor, UIColor);
|
|
26
|
+
RCT_EXPORT_VIEW_PROPERTY(tabBarBlurEffect, UIBlurEffect);
|
|
27
|
+
RCT_EXPORT_VIEW_PROPERTY(tabBarTintColor, UIColor);
|
|
28
|
+
RCT_EXPORT_VIEW_PROPERTY(tabBarItemTitleFontFamily, NSString);
|
|
29
|
+
RCT_EXPORT_VIEW_PROPERTY(tabBarItemTitleFontSize, NSNumber);
|
|
30
|
+
RCT_EXPORT_VIEW_PROPERTY(tabBarItemTitleFontWeight, NSString);
|
|
31
|
+
RCT_EXPORT_VIEW_PROPERTY(tabBarItemTitleFontStyle, NSString);
|
|
32
|
+
RCT_EXPORT_VIEW_PROPERTY(tabBarItemTitleFontColor, UIColor);
|
|
33
|
+
|
|
34
|
+
RCT_EXPORT_VIEW_PROPERTY(tabBarItemIconColor, UIColor);
|
|
35
|
+
RCT_EXPORT_VIEW_PROPERTY(tabBarItemBadgeBackgroundColor, UIColor);
|
|
36
|
+
|
|
37
|
+
RCT_EXPORT_VIEW_PROPERTY(tabBarItemTitlePositionAdjustment, UIOffset);
|
|
38
|
+
|
|
39
|
+
// TODO: Missing prop
|
|
40
|
+
//@property (nonatomic, readonly) BOOL experimental_controlNavigationStateInJS;
|
|
41
|
+
|
|
42
|
+
#pragma mark - LEGACY Events
|
|
43
|
+
|
|
44
|
+
RCT_EXPORT_VIEW_PROPERTY(onNativeFocusChange, RCTDirectEventBlock);
|
|
45
|
+
|
|
46
|
+
#endif
|
|
47
|
+
|
|
48
|
+
@end
|