Skip to content

Commit

Permalink
Fix duplicate screen names (#312)
Browse files Browse the repository at this point in the history
## 📜 Description

This is a very small PR to fix an issue with the native stack screen
names.

<img width="862" alt="Screenshot 2023-12-25 at 20 39 00"
src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/1902323/6098640f-cee9-4e35-a598-54a9b951eb46">

This also solves a missing key in the `ExamplesStackParamList` type.

## 💡 Motivation and Context

It prevents a warning when running the example app.

## 📢 Changelog

- Fix duplicate screen names in the native stack example
  • Loading branch information
zoontek authored Dec 25, 2023
1 parent a425e7c commit f95f249
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions FabricExample/src/constants/screenNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum ScreenNames {
INTERACTIVE_KEYBOARD = 'INTERACTIVE_KEYBOARD',
INTERACTIVE_KEYBOARD_IOS = 'INTERACTIVE_KEYBOARD_IOS',
NATIVE_STACK = 'NATIVE_STACK',
NATIVE = 'NATIVE',
KEYBOARD_AVOIDING_VIEW = 'KEYBOARD_AVOIDING_VIEW',
ENABLED_DISABLED = 'ENABLED_DISABLED',
CLOSE = 'CLOSE',
Expand Down
10 changes: 5 additions & 5 deletions FabricExample/src/navigation/NestedStack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ import { ScreenNames } from '../../constants/screenNames';
import KeyboardAnimation from '../../screens/Examples/KeyboardAnimation';

export type NativeStackParamList = {
[ScreenNames.NATIVE_STACK]: {};
[ScreenNames.NATIVE]: {};
};

const Stack = createNativeStackNavigator<NativeStackParamList>();

const options: Record<string, NativeStackNavigationOptions> = {
[ScreenNames.NATIVE_STACK]: {
[ScreenNames.NATIVE]: {
headerShown: false,
statusBarTranslucent: true,
},
};

const NativeStack = () => (
<Stack.Navigator initialRouteName={ScreenNames.NATIVE_STACK}>
<Stack.Navigator initialRouteName={ScreenNames.NATIVE}>
<Stack.Screen
name={ScreenNames.NATIVE_STACK}
name={ScreenNames.NATIVE}
component={KeyboardAnimation}
options={options[ScreenNames.NATIVE_STACK]}
options={options[ScreenNames.NATIVE]}
/>
</Stack.Navigator>
);
Expand Down
1 change: 1 addition & 0 deletions example/src/constants/screenNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum ScreenNames {
INTERACTIVE_KEYBOARD = 'INTERACTIVE_KEYBOARD',
INTERACTIVE_KEYBOARD_IOS = 'INTERACTIVE_KEYBOARD_IOS',
NATIVE_STACK = 'NATIVE_STACK',
NATIVE = 'NATIVE',
KEYBOARD_AVOIDING_VIEW = 'KEYBOARD_AVOIDING_VIEW',
ENABLED_DISABLED = 'ENABLED_DISABLED',
CLOSE = 'CLOSE',
Expand Down
1 change: 1 addition & 0 deletions example/src/navigation/ExamplesStack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import CloseScreen from '../../screens/Examples/Close';
export type ExamplesStackParamList = {
[ScreenNames.ANIMATED_EXAMPLE]: undefined;
[ScreenNames.REANIMATED_CHAT]: undefined;
[ScreenNames.REANIMATED_CHAT_FLATLIST]: undefined;
[ScreenNames.EVENTS]: undefined;
[ScreenNames.AWARE_SCROLL_VIEW]: undefined;
[ScreenNames.AWARE_SCROLL_VIEW_STICKY_FOOTER]: undefined;
Expand Down
10 changes: 5 additions & 5 deletions example/src/navigation/NestedStack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ import { ScreenNames } from '../../constants/screenNames';
import KeyboardAnimation from '../../screens/Examples/KeyboardAnimation';

export type NativeStackParamList = {
[ScreenNames.NATIVE_STACK]: {};
[ScreenNames.NATIVE]: {};
};

const Stack = createNativeStackNavigator<NativeStackParamList>();

const options: Record<string, NativeStackNavigationOptions> = {
[ScreenNames.NATIVE_STACK]: {
[ScreenNames.NATIVE]: {
headerShown: false,
statusBarTranslucent: true,
},
};

const NativeStack = () => (
<Stack.Navigator initialRouteName={ScreenNames.NATIVE_STACK}>
<Stack.Navigator initialRouteName={ScreenNames.NATIVE}>
<Stack.Screen
name={ScreenNames.NATIVE_STACK}
name={ScreenNames.NATIVE}
component={KeyboardAnimation}
options={options[ScreenNames.NATIVE_STACK]}
options={options[ScreenNames.NATIVE]}
/>
</Stack.Navigator>
);
Expand Down

0 comments on commit f95f249

Please sign in to comment.