From 707e20771e82d55a18d627610b61af8f32bf055d Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Wed, 9 Oct 2024 17:56:08 +0200 Subject: [PATCH] fix: refactor types --- .../navigationOptions/animation/none/index.native.ts | 3 ++- .../navigationOptions/animation/none/index.ts | 3 ++- .../navigationOptions/animation/none/types.ts | 5 +++++ .../animation/slideFromBottom/index.native.ts | 3 ++- .../navigationOptions/animation/slideFromBottom/index.ts | 3 ++- .../navigationOptions/animation/slideFromBottom/types.ts | 5 +++++ .../animation/slideFromLeft/index.android.ts | 3 ++- .../navigationOptions/animation/slideFromLeft/index.ios.ts | 3 ++- .../navigationOptions/animation/slideFromLeft/index.ts | 3 ++- .../navigationOptions/animation/slideFromLeft/types.ts | 5 +++++ .../animation/slideFromRight/index.android.ts | 3 ++- .../navigationOptions/animation/slideFromRight/index.ios.ts | 3 ++- .../navigationOptions/animation/slideFromRight/index.ts | 3 ++- .../navigationOptions/animation/slideFromRight/types.ts | 5 +++++ 14 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/types.ts create mode 100644 src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/types.ts create mode 100644 src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/types.ts create mode 100644 src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/types.ts diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/index.native.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/index.native.ts index 2f63a212a50b..dc704d5ed6e5 100644 --- a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/index.native.ts +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/index.native.ts @@ -1,6 +1,7 @@ import type {NativeStackNavigationOptions} from '@react-navigation/native-stack'; import Animations from '..'; +import type NoneTransitionNavigationOptions from './types'; -const none: NativeStackNavigationOptions = {animation: Animations.NONE, gestureEnabled: false}; +const none: NoneTransitionNavigationOptions = {animation: Animations.NONE, gestureEnabled: false} satisfies NativeStackNavigationOptions; export default none; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/index.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/index.ts index c1724f9cfeef..6c02ce74119a 100644 --- a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/index.ts +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/index.ts @@ -1,5 +1,6 @@ import type {StackNavigationOptions} from '@react-navigation/stack'; +import type NoneTransitionNavigationOptions from './types'; -const none: StackNavigationOptions = {animationEnabled: false, gestureEnabled: false}; +const none: NoneTransitionNavigationOptions = {animationEnabled: false, gestureEnabled: false} satisfies StackNavigationOptions; export default none; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/types.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/types.ts new file mode 100644 index 000000000000..0fbc091927eb --- /dev/null +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/none/types.ts @@ -0,0 +1,5 @@ +import type {PlatformSpecificNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types'; + +type NoneTransitionNavigationOptions = PlatformSpecificNavigationOptions; + +export default NoneTransitionNavigationOptions; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/index.native.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/index.native.ts index 93bba8046f6d..c38bca7b520b 100644 --- a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/index.native.ts +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/index.native.ts @@ -1,6 +1,7 @@ import type {NativeStackNavigationOptions} from '@react-navigation/native-stack'; import Animations from '..'; +import type SlideFromBottomTransitionNavigationOptions from './types'; -const slideFromBottom: NativeStackNavigationOptions = {animation: Animations.SLIDE_FROM_BOTTOM}; +const slideFromBottom: SlideFromBottomTransitionNavigationOptions = {animation: Animations.SLIDE_FROM_BOTTOM} satisfies NativeStackNavigationOptions; export default slideFromBottom; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/index.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/index.ts index d30d338fed6a..ab0ea51081a1 100644 --- a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/index.ts +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/index.ts @@ -1,6 +1,7 @@ import type {StackNavigationOptions} from '@react-navigation/stack'; import GestureDirection from '@libs/Navigation/PlatformStackNavigation/navigationOptions/gestureDirection'; +import type SlideFromBottomTransitionNavigationOptions from './types'; -const slideFromBottom: StackNavigationOptions = {animationEnabled: true, gestureDirection: GestureDirection.VERTICAL}; +const slideFromBottom: SlideFromBottomTransitionNavigationOptions = {animationEnabled: true, gestureDirection: GestureDirection.VERTICAL} satisfies StackNavigationOptions; export default slideFromBottom; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/types.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/types.ts new file mode 100644 index 000000000000..7e76f03db881 --- /dev/null +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromBottom/types.ts @@ -0,0 +1,5 @@ +import type {PlatformSpecificNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types'; + +type SlideFromBottomTransitionNavigationOptions = PlatformSpecificNavigationOptions; + +export default SlideFromBottomTransitionNavigationOptions; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.android.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.android.ts index 928a821f0de1..bc00eabd828a 100644 --- a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.android.ts +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.android.ts @@ -1,7 +1,8 @@ import type {NativeStackNavigationOptions} from '@react-navigation/native-stack'; import Animations from '..'; +import type SlideFromLeftTransitionNavigationOptions from './types'; // `slide_from_right` is resolved to `default` transition on iOS, but this transition causes issues on iOS -const slideFromLeft: NativeStackNavigationOptions = {animation: Animations.IOS_FROM_LEFT}; +const slideFromLeft: SlideFromLeftTransitionNavigationOptions = {animation: Animations.IOS_FROM_LEFT} satisfies NativeStackNavigationOptions; export default slideFromLeft; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.ios.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.ios.ts index 251bb2cd9e52..3969719ca6b1 100644 --- a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.ios.ts +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.ios.ts @@ -1,8 +1,9 @@ import type {NativeStackNavigationOptions} from '@react-navigation/native-stack'; import Animations from '..'; +import type SlideFromLeftTransitionNavigationOptions from './types'; // default transition is causing weird keyboard appearance: - https://github.com/Expensify/App/issues/37257 // so we are using `slide_from_left` which is similar to default and not causing keyboard transition issues -const slideFromLeft: NativeStackNavigationOptions = {animation: Animations.SLIDE_FROM_LEFT}; +const slideFromLeft: SlideFromLeftTransitionNavigationOptions = {animation: Animations.SLIDE_FROM_LEFT} satisfies NativeStackNavigationOptions; export default slideFromLeft; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.ts index dd71933e6203..05faefd0be0a 100644 --- a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.ts +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/index.ts @@ -1,6 +1,7 @@ import type {StackNavigationOptions} from '@react-navigation/stack'; import GestureDirection from '@libs/Navigation/PlatformStackNavigation/navigationOptions/gestureDirection'; +import type SlideFromLeftTransitionNavigationOptions from './types'; -const slideFromLeft: StackNavigationOptions = {animationEnabled: true, gestureDirection: GestureDirection.HORIZONTAL_INVERTED}; +const slideFromLeft: SlideFromLeftTransitionNavigationOptions = {animationEnabled: true, gestureDirection: GestureDirection.HORIZONTAL_INVERTED} satisfies StackNavigationOptions; export default slideFromLeft; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/types.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/types.ts new file mode 100644 index 000000000000..f170562c3b7a --- /dev/null +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromLeft/types.ts @@ -0,0 +1,5 @@ +import type {PlatformSpecificNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types'; + +type SlideFromLeftTransitionNavigationOptions = PlatformSpecificNavigationOptions; + +export default SlideFromLeftTransitionNavigationOptions; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.android.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.android.ts index b94b4764bcdc..da58d4d964a5 100644 --- a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.android.ts +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.android.ts @@ -1,6 +1,7 @@ import type {NativeStackNavigationOptions} from '@react-navigation/native-stack'; import Animations from '..'; +import type SlideFromRightTransitionNavigationOptions from './types'; -const transition: NativeStackNavigationOptions = {animation: Animations.IOS_FROM_RIGHT}; +const transition: SlideFromRightTransitionNavigationOptions = {animation: Animations.IOS_FROM_RIGHT} satisfies NativeStackNavigationOptions; export default transition; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.ios.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.ios.ts index 936396548abb..7b4677b2bf2f 100644 --- a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.ios.ts +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.ios.ts @@ -1,8 +1,9 @@ import type {NativeStackNavigationOptions} from '@react-navigation/native-stack'; import Animations from '..'; +import type SlideFromRightTransitionNavigationOptions from './types'; // default transition is causing weird keyboard appearance: - https://github.com/Expensify/App/issues/37257 // so we are using `simple_push` which is similar to default and not causing keyboard transition issues -const transition: NativeStackNavigationOptions = {animation: Animations.SIMPLE_PUSH}; +const transition: SlideFromRightTransitionNavigationOptions = {animation: Animations.SIMPLE_PUSH} satisfies NativeStackNavigationOptions; export default transition; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.ts index b6b6c8c74e48..2bc6b96b944f 100644 --- a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.ts +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/index.ts @@ -1,5 +1,6 @@ import type {StackNavigationOptions} from '@react-navigation/stack'; +import type SlideFromRightTransitionNavigationOptions from './types'; -const slideFromRight: StackNavigationOptions = {animationEnabled: true, gestureDirection: 'horizontal'}; +const slideFromRight: SlideFromRightTransitionNavigationOptions = {animationEnabled: true, gestureDirection: 'horizontal'} satisfies StackNavigationOptions; export default slideFromRight; diff --git a/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/types.ts b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/types.ts new file mode 100644 index 000000000000..d1afa32d0dcf --- /dev/null +++ b/src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/slideFromRight/types.ts @@ -0,0 +1,5 @@ +import type {PlatformSpecificNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types'; + +type SlideFromRightTransitionNavigationOptions = PlatformSpecificNavigationOptions; + +export default SlideFromRightTransitionNavigationOptions;