Skip to content

Commit

Permalink
feat(iOS)!: change default of fullScreenSwipeShadowEnabled to true (#…
Browse files Browse the repository at this point in the history
…2481)

## Description

This PR changes default value for `fullScreenSwipeShadowEnabled` prop to
`true` - meaning that the shadow will be present by default
in `simple_push` animation on iOS (this is the platform default).

> [!important]
> When changing this value I've noticed that the
`fullScreenSwipeShadowEnabled` does something different
> than it suggests in type documentation & our
GUIDE_FOR_LIBRARY_AUTHORS. Namely, it does effect `simple_push`
animation
> in every scenario, not only in full screen swipe gesture interactive
transition. I think we should change the name
> of the prop eventually. 

## Changes

Updated all the docs & code.

## Test code and steps to reproduce

I've played around with `Test1072`. Just set stack animation to simple
push.

## Checklist

- [x] Included code example that can be used to test this change
- [x] Updated TS types
- [x] Updated documentation: <!-- For adding new props to native-stack
-->
- [x]
https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
- [x]
https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md
- [x]
https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx
- [x]
https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx
- [ ] Ensured that CI passes
  • Loading branch information
kkafar authored Nov 6, 2024
1 parent dffcc5f commit 46c843e
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void setProperty(T view, String propName, @Nullable Object value) {
mViewManager.setFullScreenSwipeEnabled(view, value == null ? false : (boolean) value);
break;
case "fullScreenSwipeShadowEnabled":
mViewManager.setFullScreenSwipeShadowEnabled(view, value == null ? false : (boolean) value);
mViewManager.setFullScreenSwipeShadowEnabled(view, value == null ? true : (boolean) value);
break;
case "homeIndicatorHidden":
mViewManager.setHomeIndicatorHidden(view, value == null ? false : (boolean) value);
Expand Down
4 changes: 2 additions & 2 deletions guides/GUIDE_FOR_LIBRARY_AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Boolean indicating whether the swipe gesture should work on whole screen. Swipin

Boolean indicating whether the full screen dismiss gesture has shadow under view during transition. The gesture uses custom transition and thus
doesn't have a shadow by default. When enabled, a custom shadow view is added during the transition which tries to mimic the
default iOS shadow. Defaults to `false`.
default iOS shadow. Defaults to `true`.

### `gestureEnabled` (iOS only)

Expand Down Expand Up @@ -223,7 +223,7 @@ Allows for the customization of how the given screen should appear/disappear whe
- `"fade"` – fades screen in or out
- `fade_from_bottom` – performs a fade from bottom animation
- `"flip"` – flips the screen, requires `stackPresentation: "modal"` (iOS only)
- `"simple_push"` – performs a default animation, but without shadow and native header transition (iOS only)
- `"simple_push"` – performs a default animation, but without native header transition (iOS only)
- `"slide_from_bottom"` - slide in the new screen from bottom to top
- `"slide_from_right"` - slide in the new screen from right to left (Android only, resolves to default transition on iOS)
- `"slide_from_left"` - slide in the new screen from left to right
Expand Down
1 change: 1 addition & 0 deletions ios/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ - (void)initCommonProps
_hasOrientationSet = NO;
_hasHomeIndicatorHiddenSet = NO;
_activityState = RNSActivityStateUndefined;
_fullScreenSwipeShadowEnabled = YES;
#if !TARGET_OS_TV
_sheetExpandsWhenScrolledToEdge = YES;
#endif // !TARGET_OS_TV
Expand Down
4 changes: 2 additions & 2 deletions native-stack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Boolean indicating whether the swipe gesture should work on whole screen. Swipin

Boolean indicating whether the full screen dismiss gesture has shadow under view during transition. The gesture uses custom transition and thus
doesn't have a shadow by default. When enabled, a custom shadow view is added during the transition which tries to mimic the
default iOS shadow. Defaults to `false`.
default iOS shadow. Defaults to `true`.

#### `gestureEnabled` (iOS only)

Expand Down Expand Up @@ -325,7 +325,7 @@ How the given screen should appear/disappear when pushed or popped at the top of
- `fade` - fades screen in or out.
- `fade_from_bottom` – performs a fade from bottom animation
- `flip` – flips the screen, requires stackPresentation: `modal` (iOS only)
- `simple_push` – performs a default animation, but without shadow and native header transition (iOS only)
- `simple_push` – performs a default animation, but without native header transition (iOS only)
- `slide_from_bottom` – performs a slide from bottom animation
- `slide_from_right` - slide in the new screen from right to left (Android only, resolves to default transition on iOS)
- `slide_from_left` - slide in the new screen from left to right
Expand Down
2 changes: 1 addition & 1 deletion src/fabric/ModalScreenNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface NativeProps extends ViewProps {
sheetElevation?: WithDefault<Int32, 24>;
customAnimationOnSwipe?: boolean;
fullScreenSwipeEnabled?: boolean;
fullScreenSwipeShadowEnabled?: boolean;
fullScreenSwipeShadowEnabled?: WithDefault<boolean, true>;
homeIndicatorHidden?: boolean;
preventNativeDismiss?: boolean;
gestureEnabled?: WithDefault<boolean, true>;
Expand Down
2 changes: 1 addition & 1 deletion src/fabric/ScreenNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface NativeProps extends ViewProps {
sheetElevation?: WithDefault<Int32, 24>;
customAnimationOnSwipe?: boolean;
fullScreenSwipeEnabled?: boolean;
fullScreenSwipeShadowEnabled?: boolean;
fullScreenSwipeShadowEnabled?: WithDefault<boolean, true>;
homeIndicatorHidden?: boolean;
preventNativeDismiss?: boolean;
gestureEnabled?: WithDefault<boolean, true>;
Expand Down
4 changes: 2 additions & 2 deletions src/native-stack/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export type NativeStackNavigationOptions = {
/**
* Whether the full screen dismiss gesture has shadow under view during transition. The gesture uses custom transition and thus
* doesn't have a shadow by default. When enabled, a custom shadow view is added during the transition which tries to mimic the
* default iOS shadow. Defaults to `false`.
* default iOS shadow. Defaults to `true`.
*
* This does not affect the behavior of transitions that don't use gestures, enabled by `fullScreenGestureEnabled` prop.
*
Expand Down Expand Up @@ -456,7 +456,7 @@ export type NativeStackNavigationOptions = {
* - "fade" – fades screen in or out
* - "fade_from_bottom" – performs a fade from bottom animation
* - "flip" – flips the screen, requires stackPresentation: "modal" (iOS only)
* - "simple_push" – performs a default animation, but without shadow and native header transition (iOS only)
* - "simple_push" – performs a default animation, but without native header transition (iOS only)
* - "slide_from_bottom" – performs a slide from bottom animation
* - "slide_from_right" - slide in the new screen from right to left (Android only, resolves to default transition on iOS)
* - "slide_from_left" - slide in the new screen from left to right
Expand Down
2 changes: 1 addition & 1 deletion src/native-stack/views/NativeStackView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const RouteView = ({
const { options, render: renderScene } = descriptors[route.key];

const {
fullScreenSwipeShadowEnabled = false,
fullScreenSwipeShadowEnabled = true,
gestureEnabled,
headerShown,
hideKeyboardOnSwipe,
Expand Down
8 changes: 4 additions & 4 deletions src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ export interface ScreenProps extends ViewProps {
*/
fullScreenSwipeEnabled?: boolean;
/**
* Whether the full screen dismiss gesture has shadow under view during transition. The gesture uses custom transition and thus
* doesn't have a shadow by default. When enabled, a custom shadow view is added during the transition which tries to mimic the
* default iOS shadow. Defaults to `false`.
* Whether the full screen dismiss gesture has shadow under view during transition.
* When enabled, a custom shadow view is added during the transition which tries to mimic the
* default iOS shadow. Defaults to `true`.
*
* This does not affect the behavior of transitions that don't use gestures, enabled by `fullScreenGestureEnabled` prop.
*
Expand Down Expand Up @@ -392,7 +392,7 @@ export interface ScreenProps extends ViewProps {
* - "fade" – fades screen in or out
* - "fade_from_bottom" – performs a fade from bottom animation
* - "flip" – flips the screen, requires stackPresentation: "modal" (iOS only)
* - "simple_push" – performs a default animation, but without shadow and native header transition (iOS only)
* - "simple_push" – performs a default animation, but without native header transition (iOS only)
* - `slide_from_bottom` – performs a slide from bottom animation
* - "slide_from_right" - slide in the new screen from right to left (Android only, resolves to default transition on iOS)
* - "slide_from_left" - slide in the new screen from left to right
Expand Down

0 comments on commit 46c843e

Please sign in to comment.