Skip to content

Commit 5d0cfa3

Browse files
committed
paper support
1 parent b4c4979 commit 5d0cfa3

File tree

5 files changed

+44
-10
lines changed

5 files changed

+44
-10
lines changed

ios/bottom-tabs/RCTConvert+RNSBottomTabs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
1111

1212
+ (RNSBottomTabsIconType)RNSBottomTabsIconType:(nonnull id)json;
1313

14+
+ (RNSOrientation)RNSOrientation:(nonnull id)json;
15+
1416
@end
1517

1618
NS_ASSUME_NONNULL_END

ios/bottom-tabs/RCTConvert+RNSBottomTabs.mm

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,27 @@ + (UIOffset)UIOffset:(id)json;
1212
RCT_ENUM_CONVERTER(
1313
RNSBottomTabsIconType,
1414
(@{
15-
@"image": @(RNSBottomTabsIconTypeImage),
16-
@"template": @(RNSBottomTabsIconTypeTemplate),
17-
@"sfSymbol": @(RNSBottomTabsIconTypeSfSymbol),
15+
@"image" : @(RNSBottomTabsIconTypeImage),
16+
@"template" : @(RNSBottomTabsIconTypeTemplate),
17+
@"sfSymbol" : @(RNSBottomTabsIconTypeSfSymbol),
1818
}),
1919
RNSBottomTabsIconTypeSfSymbol,
20-
integerValue
21-
)
20+
integerValue)
21+
22+
RCT_ENUM_CONVERTER(
23+
RNSOrientation,
24+
(@{
25+
@"inherit" : @(RNSOrientationInherit),
26+
@"all" : @(RNSOrientationAll),
27+
@"allButUpsideDown" : @(RNSOrientationAllButUpsideDown),
28+
@"portrait" : @(RNSOrientationPortrait),
29+
@"portraitUpsideDown" : @(RNSOrientationPortraitUpsideDown),
30+
@"landscape" : @(RNSOrientationLandscape),
31+
@"landscapeLeft" : @(RNSOrientationLandscapeLeft),
32+
@"landscapeRight" : @(RNSOrientationLandscapeRight),
33+
}),
34+
RNSOrientationInherit,
35+
integerValue)
2236

2337
@end
2438

ios/bottom-tabs/RNSBottomTabsScreenComponentView.mm

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ @implementation RNSBottomTabsScreenComponentView {
3030
BOOL _isOverrideScrollViewContentInsetAdjustmentBehaviorSet;
3131
#if !RCT_NEW_ARCH_ENABLED
3232
BOOL _tabItemNeedsAppearanceUpdate;
33+
BOOL _tabScreenOrientationNeedsUpdate;
3334
#endif // !RCT_NEW_ARCH_ENABLED
3435
}
3536

@@ -56,6 +57,7 @@ - (void)initState
5657

5758
#if !RCT_NEW_ARCH_ENABLED
5859
_tabItemNeedsAppearanceUpdate = NO;
60+
_tabScreenOrientationNeedsUpdate = NO;
5961
#endif
6062
[self resetProps];
6163
}
@@ -85,7 +87,7 @@ - (void)resetProps
8587

8688
_overrideScrollViewContentInsetAdjustmentBehavior = YES;
8789
_isOverrideScrollViewContentInsetAdjustmentBehaviorSet = NO;
88-
90+
8991
_iconType = RNSBottomTabsIconTypeSfSymbol;
9092

9193
_iconImageSource = nil;
@@ -145,7 +147,7 @@ - (void)updateProps:(const facebook::react::Props::Shared &)props
145147
_title = RCTNSStringFromStringNilIfEmpty(newComponentProps.title);
146148
_controller.title = _title;
147149
}
148-
150+
149151
if (newComponentProps.orientation != oldComponentProps.orientation) {
150152
_orientation = rnscreens::conversion::RNSOrientationFromRNSBottomTabsScreenOrientation(newComponentProps.orientation);
151153
tabScreenOrientationNeedsUpdate = YES;
@@ -235,7 +237,7 @@ - (void)updateProps:(const facebook::react::Props::Shared &)props
235237
rnscreens::conversion::RCTImageSourceFromImageSourceAndIconType(&newComponentProps.iconImageSource, _iconType);
236238
tabItemNeedsAppearanceUpdate = YES;
237239
}
238-
240+
239241
if (newComponentProps.iconSfSymbolName != oldComponentProps.iconSfSymbolName) {
240242
_iconSfSymbolName = RCTNSStringFromStringNilIfEmpty(newComponentProps.iconSfSymbolName);
241243
tabItemNeedsAppearanceUpdate = YES;
@@ -246,7 +248,7 @@ - (void)updateProps:(const facebook::react::Props::Shared &)props
246248
rnscreens::conversion::RCTImageSourceFromImageSourceAndIconType(&newComponentProps.selectedIconImageSource, _iconType);
247249
tabItemNeedsAppearanceUpdate = YES;
248250
}
249-
251+
250252
if (newComponentProps.selectedIconSfSymbolName != oldComponentProps.selectedIconSfSymbolName) {
251253
_selectedIconSfSymbolName = RCTNSStringFromStringNilIfEmpty(newComponentProps.selectedIconSfSymbolName);
252254
tabItemNeedsAppearanceUpdate = YES;
@@ -283,7 +285,7 @@ - (void)updateProps:(const facebook::react::Props::Shared &)props
283285
if (tabItemNeedsAppearanceUpdate) {
284286
[_controller tabItemAppearanceHasChanged];
285287
}
286-
288+
287289
if (tabScreenOrientationNeedsUpdate) {
288290
[_controller tabScreenOrientationHasChanged];
289291
}
@@ -342,6 +344,11 @@ - (void)didSetProps:(NSArray<NSString *> *)changedProps
342344
[_controller tabItemAppearanceHasChanged];
343345
_tabItemNeedsAppearanceUpdate = NO;
344346
}
347+
348+
if (_tabScreenOrientationNeedsUpdate) {
349+
[_controller tabScreenOrientationHasChanged];
350+
_tabScreenOrientationNeedsUpdate = NO;
351+
}
345352
}
346353

347354
#pragma mark - LEGACY prop setters
@@ -455,6 +462,12 @@ - (void)setSelectedIconSfSymbolName:(NSString *)selectedIconSfSymbolName
455462
_tabItemNeedsAppearanceUpdate = YES;
456463
}
457464

465+
- (void)setOrientation:(RNSOrientation)orientation
466+
{
467+
_orientation = orientation;
468+
_tabScreenOrientationNeedsUpdate = YES;
469+
}
470+
458471
- (void)setOnWillAppear:(RCTDirectEventBlock)onWillAppear
459472
{
460473
[self.reactEventEmitter setOnWillAppear:onWillAppear];

ios/bottom-tabs/RNSBottomTabsScreenComponentViewManager.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ - (UIView *)view
2121

2222
RCT_REMAP_VIEW_PROPERTY(isFocused, isSelectedScreen, BOOL);
2323
RCT_EXPORT_VIEW_PROPERTY(title, NSString);
24+
RCT_EXPORT_VIEW_PROPERTY(orientation, RNSOrientation);
2425
RCT_EXPORT_VIEW_PROPERTY(badgeValue, NSString);
2526
RCT_EXPORT_VIEW_PROPERTY(tabBarBackgroundColor, UIColor);
2627
RCT_EXPORT_VIEW_PROPERTY(tabBarBlurEffect, UIBlurEffect); // needs custom conversion, cause it has `none`

ios/bottom-tabs/RNSTabBarController.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ - (void)setNeedsUpdateOfTabBarAppearance:(bool)needsUpdateOfTabBarAppearance
7474
- (void)setNeedsOrientationUpdate:(bool)needsOrientationUpdate
7575
{
7676
_needsOrientationUpdate = needsOrientationUpdate;
77+
#if !RCT_NEW_ARCH_ENABLED
78+
[self scheduleControllerUpdateIfNeeded];
79+
#endif // !RCT_NEW_ARCH_ENABLED
80+
7781
}
7882

7983
#pragma mark-- RNSReactTransactionObserving

0 commit comments

Comments
 (0)