Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ open class ScreenViewManager :
value: Boolean,
) = Unit

override fun setSheetPrefersHorizontalBars(
view: Screen?,
value: Boolean,
) = Unit

// END mark: iOS-only

override fun setAndroidResetScreenShadowStateOnOrientationChangeEnabled(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ class FormSheetHostViewManager :
view.prefersGrabberVisible = value
}

override fun setPrefersHorizontalBars(
view: FormSheetHost,
value: Boolean,
) = Unit // iOS-only bar placement preference.

override fun setPreferredCornerRadius(
view: FormSheetHost,
value: Float,
Expand Down
1 change: 1 addition & 0 deletions ios/legacy/RNSScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) NSArray<NSNumber *> *sheetAllowedDetents;
@property (nonatomic) NSNumber *sheetLargestUndimmedDetent;
@property (nonatomic) BOOL sheetGrabberVisible;
@property (nonatomic) BOOL sheetPrefersHorizontalBars;
@property (nonatomic) CGFloat sheetCornerRadius;
@property (nonatomic) NSInteger sheetInitialDetent;
@property (nonatomic) BOOL sheetExpandsWhenScrolledToEdge;
Expand Down
26 changes: 26 additions & 0 deletions ios/legacy/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ - (void)initCommonProps
_shouldUpdateScrollEdgeEffects = NO;
#if !TARGET_OS_TV
_sheetExpandsWhenScrolledToEdge = YES;
_sheetPrefersHorizontalBars = NO;
#endif // !TARGET_OS_TV
_sheetsScrollView = nil;
_sheetsScrollViewTag = 0;
Expand Down Expand Up @@ -1313,6 +1314,14 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::
}

[self setSheetGrabberVisible:newScreenProps.sheetGrabberVisible];
if (_sheetPrefersHorizontalBars != newScreenProps.sheetPrefersHorizontalBars) {
_sheetPrefersHorizontalBars = newScreenProps.sheetPrefersHorizontalBars;
#if RNS_IPHONE_OS_VERSION_AVAILABLE(27_1) && !TARGET_OS_VISION
if (@available(iOS 27.1, *)) {
[_controller setNeedsUpdateOfVerticalBarConfiguration];
}
#endif
}
[self setSheetCornerRadius:newScreenProps.sheetCornerRadius];
[self setSheetExpandsWhenScrolledToEdge:newScreenProps.sheetExpandsWhenScrolledToEdge];

Expand Down Expand Up @@ -1450,6 +1459,23 @@ @implementation RNSScreen {

#pragma mark - Common

#if RNS_IPHONE_OS_VERSION_AVAILABLE(27_1) && !TARGET_OS_TV && !TARGET_OS_VISION
- (UIVerticalBarBehavior)preferredVerticalBarBehavior API_AVAILABLE(ios(27.1))
{
if (!self.screenView.sheetPrefersHorizontalBars) {
return [super preferredVerticalBarBehavior];
}
switch (self.screenView.stackPresentation) {
case RNSScreenStackPresentationModal:
case RNSScreenStackPresentationPageSheet:
case RNSScreenStackPresentationFormSheet:
return UIVerticalBarBehaviorDisabled;
default:
return [super preferredVerticalBarBehavior];
}
}
#endif

- (instancetype)initWithView:(UIView *)view
{
if (self = [super init]) {
Expand Down
11 changes: 11 additions & 0 deletions ios/modals/form-sheet/RNSFormSheetContentController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "RNSFormSheetUpdateCoordinator.h"
#import "RNSFormSheetUpdateFlags.h"
#import "RNSPresentationSourceProvider.h"
#import "RNSDefines.h"

#import <React/RCTAssert.h>
#import <React/RCTLog.h>
Expand Down Expand Up @@ -43,6 +44,16 @@ - (RNSFormSheetContentView *)contentView
return static_cast<RNSFormSheetContentView *>(self.view);
}

#if RNS_IPHONE_OS_VERSION_AVAILABLE(27_1) && !TARGET_OS_TV && !TARGET_OS_VISION
- (UIVerticalBarBehavior)preferredVerticalBarBehavior API_AVAILABLE(ios(27.1))
{
if (self.appearanceProvider.prefersHorizontalBars) {
return UIVerticalBarBehaviorDisabled;
}
return [super preferredVerticalBarBehavior];
}
#endif

#pragma mark - UIKit callbacks

- (void)loadView
Expand Down
1 change: 1 addition & 0 deletions ios/modals/form-sheet/RNSFormSheetHostComponentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, readonly) BOOL isOpen;
@property (nonatomic, readonly) BOOL prefersGrabberVisible;
@property (nonatomic, readonly) BOOL prefersHorizontalBars;
@property (nonatomic, readonly) CGFloat preferredCornerRadius;
@property (nonatomic, readonly) NSInteger largestUndimmedDetentIndex;
@property (nonatomic, readonly) NSInteger initialDetentIndex;
Expand Down
12 changes: 12 additions & 0 deletions ios/modals/form-sheet/RNSFormSheetHostComponentView.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "RNSFormSheetHostComponentView.h"
#import "RNSDefines.h"
#import "RNSFormSheetContentController.h"
#import "RNSFormSheetContentView.h"
#import "RNSFormSheetContentWrapperComponentView.h"
Expand Down Expand Up @@ -36,6 +37,7 @@ @implementation RNSFormSheetHostComponentView {
BOOL _isOpen;
std::vector<double> _detents;
BOOL _prefersGrabberVisible;
BOOL _prefersHorizontalBars;
CGFloat _preferredCornerRadius;
NSInteger _largestUndimmedDetentIndex;
NSInteger _initialDetentIndex;
Expand Down Expand Up @@ -71,6 +73,7 @@ - (void)resetProps
_isOpen = NO;
_detents = {};
_prefersGrabberVisible = NO;
_prefersHorizontalBars = NO;
_preferredCornerRadius = -1.0;
_largestUndimmedDetentIndex = kRNSFormSheetAlwaysDimmed;
_initialDetentIndex = 0;
Expand Down Expand Up @@ -274,6 +277,15 @@ - (void)updateProps:(const facebook::react::Props::Shared &)props
[_controller setNeedsAppearanceUpdate];
}

if (oldComponentProps.prefersHorizontalBars != newComponentProps.prefersHorizontalBars) {
_prefersHorizontalBars = newComponentProps.prefersHorizontalBars;
#if RNS_IPHONE_OS_VERSION_AVAILABLE(27_1) && !TARGET_OS_TV && !TARGET_OS_VISION
if (@available(iOS 27.1, *)) {
[_controller setNeedsUpdateOfVerticalBarConfiguration];
}
#endif
}

if (oldComponentProps.preferredCornerRadius != newComponentProps.preferredCornerRadius) {
_preferredCornerRadius = newComponentProps.preferredCornerRadius;
[_controller setNeedsAppearanceUpdate];
Expand Down
1 change: 1 addition & 0 deletions ios/modals/form-sheet/RNSFormSheetProviders.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol RNSFormSheetAppearanceProvider <NSObject>

- (BOOL)prefersGrabberVisible;
- (BOOL)prefersHorizontalBars;
- (CGFloat)preferredCornerRadius;
- (NSInteger)largestUndimmedDetentIndex;
- (nullable UIColor *)nativeContainerBackgroundColor;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-screens",
"version": "5.0.0-t3.27",
"version": "5.0.0-t3.29",
"description": "Native navigation primitives for your React Native app.",
"scripts": {
"submodules": "git submodule update --init --recursive && (cd react-navigation && yarn && yarn build && cd ../)",
Expand Down
10 changes: 10 additions & 0 deletions src/components/modals/form-sheet/FormSheet.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ export interface FormSheetProps {
*/
prefersGrabberVisible?: boolean | undefined;

/**
* Requests horizontal bars instead of the vertical bar on iPhone Duo.
* Leave unset to let UIKit place native controls in the vertical bar.
*
* @default false
* @platform ios
* @supported iOS 27.1 or higher
*/
prefersHorizontalBars?: boolean | undefined;

/**
* @summary The corner radius that the sheet will attempt to present with.
*
Expand Down
1 change: 1 addition & 0 deletions src/fabric/legacy/ModalScreenNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export interface NativeProps extends ViewProps {
sheetAllowedDetents?: number[] | undefined;
sheetLargestUndimmedDetent?: CT.WithDefault<CT.Int32, -1>;
sheetGrabberVisible?: CT.WithDefault<boolean, false>;
sheetPrefersHorizontalBars?: CT.WithDefault<boolean, false>;
sheetCornerRadius?: CT.WithDefault<CT.Float, -1.0>;
sheetExpandsWhenScrolledToEdge?: CT.WithDefault<boolean, false>;
sheetInitialDetent?: CT.WithDefault<CT.Int32, 0>;
Expand Down
1 change: 1 addition & 0 deletions src/fabric/legacy/ScreenNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export interface NativeProps extends ViewProps {
sheetAllowedDetents?: number[] | undefined;
sheetLargestUndimmedDetent?: CT.WithDefault<CT.Int32, -1>;
sheetGrabberVisible?: CT.WithDefault<boolean, false>;
sheetPrefersHorizontalBars?: CT.WithDefault<boolean, false>;
sheetCornerRadius?: CT.WithDefault<CT.Float, -1.0>;
sheetExpandsWhenScrolledToEdge?: CT.WithDefault<boolean, false>;
sheetInitialDetent?: CT.WithDefault<CT.Int32, 0>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface NativeProps extends ViewProps {
isOpen?: CT.WithDefault<boolean, false>;
detents?: CT.Double[] | undefined;
prefersGrabberVisible?: CT.WithDefault<boolean, false>;
prefersHorizontalBars?: CT.WithDefault<boolean, false>;
preferredCornerRadius?: CT.WithDefault<CT.Float, -1.0>;
largestUndimmedDetentIndex?: CT.WithDefault<CT.Int32, -1>;
initialDetentIndex?: CT.WithDefault<CT.Int32, 0>;
Expand Down
9 changes: 9 additions & 0 deletions src/legacy/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,15 @@ export interface ScreenProps extends ViewProps {
* @platform ios
*/
sheetGrabberVisible?: boolean | undefined;
/**
* Requests horizontal bars instead of the vertical bar for modal, page-sheet,
* and form-sheet presentations on iPhone Duo. Defaults to `false`, preserving
* UIKit's automatic bar placement.
*
* @platform ios
* @supported iOS 27.1 or higher
*/
sheetPrefersHorizontalBars?: boolean | undefined;
/**
* The largest sheet detent for which a view underneath won't be dimmed.
* Works only when `stackPresentation` is set to `formSheet`.
Expand Down