Skip to content

Commit 8b29e5e

Browse files
committed
fix: bottom tab transitions duration
1 parent 9975b27 commit 8b29e5e

5 files changed

Lines changed: 19 additions & 23 deletions

File tree

patches/react-native-screens+3.34.0+004+ios-custom-animations-native-transitions.patch

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/node_modules/react-native-screens/ios/RNSScreenStackAnimator.mm b/node_modules/react-native-screens/ios/RNSScreenStackAnimator.mm
2-
index abb2cf6..fb81d52 100644
2+
index abb2cf6..c21b3e9 100644
33
--- a/node_modules/react-native-screens/ios/RNSScreenStackAnimator.mm
44
+++ b/node_modules/react-native-screens/ios/RNSScreenStackAnimator.mm
55
@@ -5,13 +5,14 @@
@@ -32,7 +32,7 @@ index abb2cf6..fb81d52 100644
3232
}
3333
@@ -129,6 +130,8 @@ - (void)animateSimplePushWithShadowEnabled:(BOOL)shadowEnabled
3434
}
35-
35+
3636
[UIView animateWithDuration:[self transitionDuration:transitionContext]
3737
+ delay:0
3838
+ options:UIViewAnimationOptionCurveDefaultTransition
@@ -66,25 +66,7 @@ index abb2cf6..fb81d52 100644
6666
animations:animationBlock
6767
completion:completionBlock];
6868
} else {
69-
@@ -251,6 +260,8 @@ - (void)animateFadeWithTransitionContext:(id<UIViewControllerContextTransitionin
70-
[[transitionContext containerView] addSubview:toViewController.view];
71-
toViewController.view.alpha = 0.0;
72-
[UIView animateWithDuration:[self transitionDuration:transitionContext]
73-
+ delay:0
74-
+ options:UIViewAnimationOptionCurveDefaultTransition
75-
animations:^{
76-
toViewController.view.alpha = 1.0;
77-
}
78-
@@ -262,6 +273,8 @@ - (void)animateFadeWithTransitionContext:(id<UIViewControllerContextTransitionin
79-
[[transitionContext containerView] insertSubview:toViewController.view belowSubview:fromViewController.view];
80-
81-
[UIView animateWithDuration:[self transitionDuration:transitionContext]
82-
+ delay:0
83-
+ options:UIViewAnimationOptionCurveDefaultTransition
84-
animations:^{
85-
fromViewController.view.alpha = 0.0;
86-
}
87-
@@ -284,6 +297,8 @@ - (void)animateSlideFromBottomWithTransitionContext:(id<UIViewControllerContextT
69+
@@ -284,6 +293,8 @@ - (void)animateSlideFromBottomWithTransitionContext:(id<UIViewControllerContextT
8870
toViewController.view.transform = topBottomTransform;
8971
[[transitionContext containerView] addSubview:toViewController.view];
9072
[UIView animateWithDuration:[self transitionDuration:transitionContext]
@@ -93,7 +75,7 @@ index abb2cf6..fb81d52 100644
9375
animations:^{
9476
fromViewController.view.transform = CGAffineTransformIdentity;
9577
toViewController.view.transform = CGAffineTransformIdentity;
96-
@@ -309,6 +324,8 @@ - (void)animateSlideFromBottomWithTransitionContext:(id<UIViewControllerContextT
78+
@@ -309,6 +320,8 @@ - (void)animateSlideFromBottomWithTransitionContext:(id<UIViewControllerContextT
9779

9880
if (!transitionContext.isInteractive) {
9981
[UIView animateWithDuration:[self transitionDuration:transitionContext]
@@ -153,4 +135,4 @@ index 4e39336..ab0b313 100644
153135
+ transitionDuration?: WithDefault<Int32, 500>;
154136
replaceAnimation?: WithDefault<ReplaceAnimation, 'pop'>;
155137
swipeDirection?: WithDefault<SwipeDirection, 'horizontal'>;
156-
hideKeyboardOnSwipe?: boolean;
138+
hideKeyboardOnSwipe?: boolean;

src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {useNavigationState} from '@react-navigation/native';
22
import React from 'react';
33
import createCustomBottomTabNavigator from '@libs/Navigation/AppNavigator/createCustomBottomTabNavigator';
44
import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRoute';
5+
import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation';
56
import type {PlatformStackNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types';
67
import type {BottomTabNavigatorParamList, CentralPaneName, NavigationPartialRoute, RootStackParamList} from '@libs/Navigation/types';
78
import SidebarScreen from '@pages/home/sidebar/SidebarScreen';
@@ -14,6 +15,7 @@ const loadInitialSettingsPage = () => require<ReactComponentModule>('../../../..
1415
const Tab = createCustomBottomTabNavigator<BottomTabNavigatorParamList>();
1516

1617
const screenOptions: PlatformStackNavigationOptions = {
18+
animation: Animations.FADE,
1719
headerShown: false,
1820
};
1921

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type {NativeStackNavigationOptions} from '@react-navigation/native-stack';
2+
import type {PlatformSpecificNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types';
3+
import Animations from '..';
4+
5+
const fade: PlatformSpecificNavigationOptions = {animation: Animations.FADE, animationDuration: 150} satisfies NativeStackNavigationOptions;
6+
7+
export default fade;

src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ const InternalPlatformAnimations = {
55
IOS_FROM_LEFT: 'ios_from_left',
66
IOS_FROM_RIGHT: 'ios_from_right',
77
SIMPLE_PUSH: 'simple_push',
8+
FADE: 'fade',
89
} as const;
910

1011
const Animations = {
1112
SLIDE_FROM_LEFT: 'slide_from_left',
1213
SLIDE_FROM_RIGHT: 'slide_from_right',
1314
MODAL: 'modal',
15+
FADE: 'fade',
1416
NONE: 'none',
1517
} as const;
1618

src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/withAnimation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type {NativeStackNavigationOptions} from '@react-navigation/native-stack';
22
import type {StackNavigationOptions} from '@react-navigation/stack';
33
import type {PlatformStackNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types';
4+
import fade from './fade';
45
import Animations from './index';
56
import none from './none';
67
import slideFromBottom from './slideFromBottom';
@@ -19,6 +20,8 @@ function withAnimation<PlatformSpecificNavigationOptions extends StackNavigation
1920
return slideFromBottom as PlatformSpecificNavigationOptions;
2021
case Animations.NONE:
2122
return none as PlatformSpecificNavigationOptions;
23+
case Animations.FADE:
24+
return fade as PlatformSpecificNavigationOptions;
2225
default:
2326
return {} as PlatformSpecificNavigationOptions;
2427
}

0 commit comments

Comments
 (0)