From e9d28f19f3090da020685d5c52b2a92686812a96 Mon Sep 17 00:00:00 2001 From: Wojciech Lewicki Date: Wed, 10 Feb 2021 16:46:26 +0100 Subject: [PATCH] feat: change modal logic (#798) PR introducing 3 changes. - disabled the ability to modify the status bar appearance in non-fullScreen modals since it destroys the animation (see gifs in #767) and introduces the necessity to control the color of status bar in every modal, which does not work well e.g. with phones with iOS <13 since there are only fullScreen modals there. The system seems to pretty well deal with all the cases where this change could be problematic, so I think it is worth to do this. - extended an if clause in RNSScreenStackHeaderConfig.m to fix the bug when trying to change options via navigation.setOptions while being in fullScreenModal. Till now, when the code reached the changed line, if did not go into if due to nav being nil for fullScreenModal, which resolved to nextVC also being nil. We now check if nav is nil, which should mean that we are in fullScreenModal, and if vc is not nil at the same time, we want to update the screen. - Removed running tsc --noEmit in TestsExample project since it made the CI fail for some reason with .tsx files. --- TestsExample/ios/Podfile.lock | 4 +- TestsExample/package.json | 4 +- TestsExample/src/{Test642.js => Test642.tsx} | 61 +++++++++++++------- TestsExample/tsconfig.json | 5 ++ ios/RNSScreen.m | 23 ++++---- ios/RNSScreenStackHeaderConfig.m | 3 +- package.json | 2 +- tsconfig.json | 3 +- 8 files changed, 66 insertions(+), 39 deletions(-) rename TestsExample/src/{Test642.js => Test642.tsx} (59%) create mode 100644 TestsExample/tsconfig.json diff --git a/TestsExample/ios/Podfile.lock b/TestsExample/ios/Podfile.lock index 66f2bd164..58ade1119 100644 --- a/TestsExample/ios/Podfile.lock +++ b/TestsExample/ios/Podfile.lock @@ -308,7 +308,7 @@ PODS: - React - RNReanimated (1.13.1): - React - - RNScreens (2.17.0): + - RNScreens (2.17.1): - React-Core - RNSearchBar (3.5.1): - React @@ -506,7 +506,7 @@ SPEC CHECKSUMS: RNCMaskedView: 5a8ec07677aa885546a0d98da336457e2bea557f RNGestureHandler: 7a5833d0f788dbd107fbb913e09aa0c1ff333c39 RNReanimated: dd8c286ab5dd4ba36d3a7fef8bff7e08711b5476 - RNScreens: 23c1fbf7797261321f6db93fdcbd9913573535e4 + RNScreens: b6c9607e6fe47c1b6e2f1910d2acd46dd7ecea3a RNSearchBar: 9860431356b7d12a8449d2fddb2b5f3c78d1e99f RNVectorIcons: bc69e6a278b14842063605de32bec61f0b251a59 Yoga: 7d13633d129fd179e01b8953d38d47be90db185a diff --git a/TestsExample/package.json b/TestsExample/package.json index 3de6e2182..e965d7f5f 100644 --- a/TestsExample/package.json +++ b/TestsExample/package.json @@ -6,7 +6,9 @@ "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", - "test": "jest" + "test": "jest", + "lint": "eslint --ext '.js,.ts,.tsx' --fix src && yarn check-types", + "check-types": "tsc --noEmit" }, "dependencies": { "@react-native-community/masked-view": "^0.1.10", diff --git a/TestsExample/src/Test642.js b/TestsExample/src/Test642.tsx similarity index 59% rename from TestsExample/src/Test642.js rename to TestsExample/src/Test642.tsx index 39307288f..a808a031f 100644 --- a/TestsExample/src/Test642.js +++ b/TestsExample/src/Test642.tsx @@ -1,24 +1,28 @@ // connected PRs: #679, #675 -import {NavigationContainer} from '@react-navigation/native'; import React from 'react'; -import {ScrollView, StyleSheet, View, Button} from 'react-native'; -import {createNativeStackNavigator} from 'react-native-screens/native-stack'; +import {NavigationContainer, ParamListBase} from '@react-navigation/native'; +import {ScrollView, View, Button} from 'react-native'; +import {createNativeStackNavigator, NativeStackNavigationProp} from 'react-native-screens/native-stack'; import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'; +type Props = { + navigation: NativeStackNavigationProp; +} + const Stack = createNativeStackNavigator(); -export default function NativeNavigation() { +export default function App(): JSX.Element { return ( + ); @@ -35,8 +47,8 @@ export default function NativeNavigation() { const Tab = createBottomTabNavigator(); -const TabNavigator = (props) => ( - +const TabNavigator = () => ( + @@ -45,7 +57,7 @@ const TabNavigator = (props) => ( const InnerStack = createNativeStackNavigator(); -const Inner = (props) => ( +const Inner = () => ( ( ); -function Home({navigation}) { +function Home({navigation}: Props) { const [yes, setYes] = React.useState(true); return ( - +