Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iOS): Fix updating bounds while changing interface orientation #1970

Merged
merged 10 commits into from
May 8, 2024
1 change: 1 addition & 0 deletions FabricTestExample/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import Test1802 from './src/Test1802';
import Test1829 from './src/Test1829';
import Test1844 from './src/Test1844';
import Test1864 from './src/Test1864';
import Test1970 from './src/Test1970';
import TestScreenAnimation from './src/TestScreenAnimation';
import Test1981 from './src/Test1981';
import Test2008 from './src/Test2008';
Expand Down
73 changes: 73 additions & 0 deletions FabricTestExample/src/Test1970.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { NavigationContainer, useNavigation } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { Button, StyleSheet, Text } from 'react-native';

const Stack = createNativeStackNavigator();

const Home = () => {
const navigation = useNavigation();

return (
<>
<Text>Home Screen - Portrait</Text>
<Button title="Next" onPress={() => navigation.navigate('Landscape')} />
</>
);
};

const Landscape = () => {
const navigation = useNavigation();

return (
<>
<Text>Landscape Screen</Text>
<Button title="Back" onPress={() => navigation.goBack()} />
</>
);
};

export default function App() {
return (
<NavigationContainer>
<Stack.Navigator
initialRouteName="Home"
screenOptions={{ animation: 'none', headerShown: false }}>
<Stack.Screen
name="Home"
component={Home}
options={{
orientation: 'portrait',
contentStyle: {
flex: 1,
backgroundColor: '#abc',
justifyContent: 'center',
alignItems: 'center',
},
}}
/>
<Stack.Screen
name="Landscape"
component={Landscape}
options={{
orientation: 'landscape',
contentStyle: {
flex: 1,
backgroundColor: '#cba',
justifyContent: 'center',
alignItems: 'center',
},
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
1 change: 1 addition & 0 deletions TestsExample/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import Test1802 from './src/Test1802';
import Test1829 from './src/Test1829';
import Test1844 from './src/Test1844';
import Test1864 from './src/Test1864';
import Test1970 from './src/Test1970';
import Test1981 from './src/Test1981';
import Test2008 from './src/Test2008';
import Test2048 from './src/Test2048';
Expand Down
73 changes: 73 additions & 0 deletions TestsExample/src/Test1970.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { NavigationContainer, useNavigation } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { Button, StyleSheet, Text } from 'react-native';

const Stack = createNativeStackNavigator();

const Home = () => {
const navigation = useNavigation();

return (
<>
<Text>Home Screen - Portrait</Text>
<Button title="Next" onPress={() => navigation.navigate('Landscape')} />
</>
);
};

const Landscape = () => {
const navigation = useNavigation();

return (
<>
<Text>Landscape Screen</Text>
<Button title="Back" onPress={() => navigation.goBack()} />
</>
);
};

export default function App() {
return (
<NavigationContainer>
<Stack.Navigator
initialRouteName="Home"
screenOptions={{ animation: 'none', headerShown: false }}>
<Stack.Screen
name="Home"
component={Home}
options={{
orientation: 'portrait',
contentStyle: {
flex: 1,
backgroundColor: '#abc',
justifyContent: 'center',
alignItems: 'center',
},
}}
/>
<Stack.Screen
name="Landscape"
component={Landscape}
options={{
orientation: 'landscape',
contentStyle: {
flex: 1,
backgroundColor: '#cba',
justifyContent: 'center',
alignItems: 'center',
},
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
1 change: 1 addition & 0 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ - (void)navigationController:(UINavigationController *)navigationController
{
[self emitOnFinishTransitioningEvent];
[RNSScreenWindowTraits updateWindowTraits];
[_controller.view setNeedsLayout];
tboba marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One single note, let's leave a comment above this line why do we trigger layout here (e.g. link to this PR).

}
#endif

Expand Down
Loading