Skip to content

Commit

Permalink
Properly revert changes from 1649
Browse files Browse the repository at this point in the history
  • Loading branch information
kkafar committed Feb 12, 2023
1 parent d83f1f9 commit b729f5c
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 181 deletions.
10 changes: 0 additions & 10 deletions android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,6 @@ class ScreenViewManager : ViewGroupManager<Screen>(), RNSScreenManagerInterface<

override fun setSwipeDirection(view: Screen?, value: String?) = Unit

override fun setSheetAllowedDetents(view: Screen, value: String?) = Unit

override fun setSheetLargestUndimmedDetent(view: Screen, value: String?) = Unit

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

override fun setSheetCornerRadius(view: Screen?, value: Float) = Unit

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

override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
return MapBuilder.of(
ScreenDismissedEvent.EVENT_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,6 @@ public RNSScreenManagerDelegate(U viewManager) {
@Override
public void setProperty(T view, String propName, @Nullable Object value) {
switch (propName) {
case "sheetAllowedDetents":
mViewManager.setSheetAllowedDetents(view, (String) value);
break;
case "sheetLargestUndimmedDetent":
mViewManager.setSheetLargestUndimmedDetent(view, (String) value);
break;
case "sheetGrabberVisible":
mViewManager.setSheetGrabberVisible(view, value == null ? false : (boolean) value);
break;
case "sheetCornerRadius":
mViewManager.setSheetCornerRadius(view, value == null ? -1f : ((Double) value).floatValue());
break;
case "sheetExpandsWhenScrolledToEdge":
mViewManager.setSheetExpandsWhenScrolledToEdge(view, value == null ? false : (boolean) value);
break;
case "customAnimationOnSwipe":
mViewManager.setCustomAnimationOnSwipe(view, value == null ? false : (boolean) value);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
import com.facebook.react.bridge.ReadableMap;

public interface RNSScreenManagerInterface<T extends View> {
void setSheetAllowedDetents(T view, @Nullable String value);
void setSheetLargestUndimmedDetent(T view, @Nullable String value);
void setSheetGrabberVisible(T view, boolean value);
void setSheetCornerRadius(T view, float value);
void setSheetExpandsWhenScrolledToEdge(T view, boolean value);
void setCustomAnimationOnSwipe(T view, boolean value);
void setFullScreenSwipeEnabled(T view, boolean value);
void setHomeIndicatorHidden(T view, boolean value);
Expand Down
6 changes: 0 additions & 6 deletions ios/RNSConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
+ (RNSScreenSwipeDirection)RNSScreenSwipeDirectionFromCppEquivalent:
(facebook::react::RNSScreenSwipeDirection)swipeDirection;

+ (RNSScreenDetentType)RNSScreenDetentTypeFromAllowedDetents:
(facebook::react::RNSScreenSheetAllowedDetents)allowedDetents;

+ (RNSScreenDetentType)RNSScreenDetentTypeFromLargestUndimmedDetent:
(facebook::react::RNSScreenSheetLargestUndimmedDetent)detent;

+ (NSDictionary *)gestureResponseDistanceDictFromCppStruct:
(const facebook::react::RNSScreenGestureResponseDistanceStruct &)gestureResponseDistance;

Expand Down
26 changes: 0 additions & 26 deletions ios/RNSConvert.mm
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,6 @@ + (RNSScreenSwipeDirection)RNSScreenSwipeDirectionFromCppEquivalent:
}
}

+ (RNSScreenDetentType)RNSScreenDetentTypeFromAllowedDetents:
(facebook::react::RNSScreenSheetAllowedDetents)allowedDetents
{
switch (allowedDetents) {
case facebook::react::RNSScreenSheetAllowedDetents::All:
return RNSScreenDetentTypeAll;
case facebook::react::RNSScreenSheetAllowedDetents::Large:
return RNSScreenDetentTypeLarge;
case facebook::react::RNSScreenSheetAllowedDetents::Medium:
return RNSScreenDetentTypeMedium;
}
}

+ (RNSScreenDetentType)RNSScreenDetentTypeFromLargestUndimmedDetent:
(facebook::react::RNSScreenSheetLargestUndimmedDetent)detent
{
switch (detent) {
case facebook::react::RNSScreenSheetLargestUndimmedDetent::All:
return RNSScreenDetentTypeAll;
case facebook::react::RNSScreenSheetLargestUndimmedDetent::Large:
return RNSScreenDetentTypeLarge;
case facebook::react::RNSScreenSheetLargestUndimmedDetent::Medium:
return RNSScreenDetentTypeMedium;
}
}

+ (NSDictionary *)gestureResponseDistanceDictFromCppStruct:
(const facebook::react::RNSScreenGestureResponseDistanceStruct &)gestureResponseDistance
{
Expand Down
6 changes: 0 additions & 6 deletions ios/RNSEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,3 @@ typedef NS_ENUM(NSInteger, RNSScreenStackHeaderSubviewType) {
RNSScreenStackHeaderSubviewTypeCenter,
RNSScreenStackHeaderSubviewTypeSearchBar,
};

typedef NS_ENUM(NSInteger, RNSScreenDetentType) {
RNSScreenDetentTypeMedium,
RNSScreenDetentTypeLarge,
RNSScreenDetentTypeAll,
};
7 changes: 0 additions & 7 deletions ios/RNSScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) UIInterfaceOrientationMask screenOrientation;
@property (nonatomic) BOOL statusBarHidden;
@property (nonatomic) BOOL homeIndicatorHidden;

// Props controlling UISheetPresentationController
@property (nonatomic) RNSScreenDetentType sheetAllowedDetents;
@property (nonatomic) RNSScreenDetentType sheetLargestUndimmedDetent;
@property (nonatomic) BOOL sheetGrabberVisible;
@property (nonatomic) CGFloat sheetCornerRadius;
@property (nonatomic) BOOL sheetExpandsWhenScrolledToEdge;
#endif // !TARGET_OS_TV

#ifdef RN_FABRIC_ENABLED
Expand Down
99 changes: 0 additions & 99 deletions ios/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ - (void)initCommonProps
_hasStatusBarHiddenSet = NO;
_hasOrientationSet = NO;
_hasHomeIndicatorHiddenSet = NO;
#if !TARGET_OS_TV
_sheetExpandsWhenScrolledToEdge = YES;
#endif // !TARGET_OS_TV
}

- (UIViewController *)reactViewController
Expand Down Expand Up @@ -517,60 +514,6 @@ - (BOOL)isModal
return self.stackPresentation != RNSScreenStackPresentationPush;
}

#if !TARGET_OS_TV
/**
* Updates settings for sheet presentation controller.
* Note that this method should not be called inside `stackPresentation` setter, because on Paper we don't have
* guarantee that values of all related props had been updated earlier.
*/
- (void)updatePresentationStyle
{
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_15_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_15_0
if (@available(iOS 15.0, *)) {
UISheetPresentationController *sheet = _controller.sheetPresentationController;
if (_stackPresentation == RNSScreenStackPresentationFormSheet && sheet != nil) {
sheet.prefersScrollingExpandsWhenScrolledToEdge = _sheetExpandsWhenScrolledToEdge;
sheet.prefersGrabberVisible = _sheetGrabberVisible;
sheet.preferredCornerRadius =
_sheetCornerRadius < 0 ? UISheetPresentationControllerAutomaticDimension : _sheetCornerRadius;

if (_sheetLargestUndimmedDetent == RNSScreenDetentTypeMedium) {
sheet.largestUndimmedDetentIdentifier = UISheetPresentationControllerDetentIdentifierMedium;
} else if (_sheetLargestUndimmedDetent == RNSScreenDetentTypeLarge) {
sheet.largestUndimmedDetentIdentifier = UISheetPresentationControllerDetentIdentifierLarge;
} else if (_sheetLargestUndimmedDetent == RNSScreenDetentTypeAll) {
sheet.largestUndimmedDetentIdentifier = nil;
} else {
RCTLogError(@"Unhandled value of sheetLargestUndimmedDetent passed");
}

if (_sheetAllowedDetents == RNSScreenDetentTypeMedium) {
sheet.detents = @[ UISheetPresentationControllerDetent.mediumDetent ];
if (sheet.selectedDetentIdentifier != UISheetPresentationControllerDetentIdentifierMedium) {
[sheet animateChanges:^{
sheet.selectedDetentIdentifier = UISheetPresentationControllerDetentIdentifierMedium;
}];
}
} else if (_sheetAllowedDetents == RNSScreenDetentTypeLarge) {
sheet.detents = @[ UISheetPresentationControllerDetent.largeDetent ];
if (sheet.selectedDetentIdentifier != UISheetPresentationControllerDetentIdentifierLarge) {
[sheet animateChanges:^{
sheet.selectedDetentIdentifier = UISheetPresentationControllerDetentIdentifierLarge;
}];
}
} else if (_sheetAllowedDetents == RNSScreenDetentTypeAll) {
sheet.detents =
@[ UISheetPresentationControllerDetent.mediumDetent, UISheetPresentationControllerDetent.largeDetent ];
} else {
RCTLogError(@"Unhandled value of sheetAllowedDetents passed");
}
}
}
#endif // Check for max allowed iOS version
}
#endif // !TARGET_OS_TV

#pragma mark - Fabric specific
#ifdef RN_FABRIC_ENABLED

Expand Down Expand Up @@ -670,19 +613,6 @@ - (void)updateProps:(facebook::react::Props::Shared const &)props
if (newScreenProps.homeIndicatorHidden != oldScreenProps.homeIndicatorHidden) {
[self setHomeIndicatorHidden:newScreenProps.homeIndicatorHidden];
}

[self setSheetGrabberVisible:newScreenProps.sheetGrabberVisible];
[self setSheetCornerRadius:newScreenProps.sheetCornerRadius];
[self setSheetExpandsWhenScrolledToEdge:newScreenProps.sheetExpandsWhenScrolledToEdge];

if (newScreenProps.sheetAllowedDetents != oldScreenProps.sheetAllowedDetents) {
[self setSheetAllowedDetents:[RNSConvert RNSScreenDetentTypeFromAllowedDetents:newScreenProps.sheetAllowedDetents]];
}

if (newScreenProps.sheetLargestUndimmedDetent != oldScreenProps.sheetLargestUndimmedDetent) {
[self setSheetLargestUndimmedDetent:
[RNSConvert RNSScreenDetentTypeFromLargestUndimmedDetent:newScreenProps.sheetLargestUndimmedDetent]];
}
#endif // !TARGET_OS_TV

// Notice that we compare against _stackPresentation, not oldScreenProps.stackPresentation.
Expand All @@ -693,11 +623,6 @@ - (void)updateProps:(facebook::react::Props::Shared const &)props
[self setStackPresentation:newStackPresentation];
}

#if !TARGET_OS_TV
// This must be called after setter for stackPresentation
[self updatePresentationStyle];
#endif // !TARGET_OS_TV

if (newScreenProps.stackAnimation != oldScreenProps.stackAnimation) {
[self setStackAnimation:[RNSConvert RNSScreenStackAnimationFromCppEquivalent:newScreenProps.stackAnimation]];
}
Expand Down Expand Up @@ -736,14 +661,6 @@ - (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetric
#pragma mark - Paper specific
#else

- (void)didSetProps:(NSArray<NSString *> *)changedProps
{
[super didSetProps:changedProps];
#if !TARGET_OS_TV
[self updatePresentationStyle];
#endif // !TARGET_OS_TV
}

- (void)setPointerEvents:(RCTPointerEvents)pointerEvents
{
// pointer events settings are managed by the parent screen container, we ignore
Expand Down Expand Up @@ -1280,12 +1197,6 @@ @implementation RNSScreenManager
RCT_EXPORT_VIEW_PROPERTY(statusBarHidden, BOOL)
RCT_EXPORT_VIEW_PROPERTY(statusBarStyle, RNSStatusBarStyle)
RCT_EXPORT_VIEW_PROPERTY(homeIndicatorHidden, BOOL)

RCT_EXPORT_VIEW_PROPERTY(sheetAllowedDetents, RNSScreenDetentType);
RCT_EXPORT_VIEW_PROPERTY(sheetLargestUndimmedDetent, RNSScreenDetentType);
RCT_EXPORT_VIEW_PROPERTY(sheetGrabberVisible, BOOL);
RCT_EXPORT_VIEW_PROPERTY(sheetCornerRadius, CGFloat);
RCT_EXPORT_VIEW_PROPERTY(sheetExpandsWhenScrolledToEdge, BOOL);
#endif

#if !TARGET_OS_TV
Expand Down Expand Up @@ -1398,16 +1309,6 @@ @implementation RCTConvert (RNSScreen)
RNSStatusBarStyleAuto,
integerValue)

RCT_ENUM_CONVERTER(
RNSScreenDetentType,
(@{
@"large" : @(RNSScreenDetentTypeLarge),
@"medium" : @(RNSScreenDetentTypeMedium),
@"all" : @(RNSScreenDetentTypeAll),
}),
RNSScreenDetentTypeAll,
integerValue)

+ (UIInterfaceOrientationMask)UIInterfaceOrientationMask:(id)json
{
json = [self NSString:json];
Expand Down
7 changes: 0 additions & 7 deletions src/fabric/ScreenNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ type SwipeDirection = 'vertical' | 'horizontal';

type ReplaceAnimation = 'pop' | 'push';

type SheetDetentTypes = 'large' | 'medium' | 'all';

export type NativeProps = $ReadOnly<{|
...ViewProps,
onAppear?: ?BubblingEventHandler<ScreenEvent>,
Expand All @@ -67,11 +65,6 @@ export type NativeProps = $ReadOnly<{|
onWillAppear?: ?BubblingEventHandler<ScreenEvent>,
onWillDisappear?: ?BubblingEventHandler<ScreenEvent>,
onTransitionProgress?: ?BubblingEventHandler<TransitionProgressEvent>,
sheetAllowedDetents?: WithDefault<SheetDetentTypes, 'large'>,
sheetLargestUndimmedDetent?: WithDefault<SheetDetentTypes, 'all'>,
sheetGrabberVisible?: WithDefault<boolean, false>,
sheetCornerRadius?: WithDefault<Float, -1.0>,
sheetExpandsWhenScrolledToEdge?: WithDefault<boolean, false>,
customAnimationOnSwipe?: boolean,
fullScreenSwipeEnabled?: boolean,
homeIndicatorHidden?: boolean,
Expand Down

0 comments on commit b729f5c

Please sign in to comment.