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: HeaderConfig impacts layout of Screen's contents #2395

Merged
merged 4 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions apps/src/tests/Test2395.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import * as React from 'react';
import { FlatList, Pressable, StyleSheet, Text, View } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';

const Stack = createNativeStackNavigator();

export default function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Title"
component={Screen}
options={{
headerRight: () => (
<View
style={{
backgroundColor: 'lightblue',
padding: 3,
height: 200,
}}>
<Text>Right</Text>
</View>
),
headerLeft: () => (
<View
style={{
backgroundColor: 'goldenrod',
padding: 8,
}}>
<Text>Left</Text>
</View>
),
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
}

function Screen() {
return (
<FlatList
style={styles.container}
data={Array.from({ length: 20 }).fill(0) as number[]}
renderItem={({ index }) => (
<Pressable
key={index}
style={({ pressed }) => (pressed ? styles.pressed : undefined)}>
<Text style={styles.text}>List item {index + 1}</Text>
</Pressable>
)}
/>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'mediumseagreen',
},
text: {
fontSize: 24,
color: 'black',
padding: 10,
},
pressed: {
backgroundColor: 'seagreen',
},
});
1 change: 1 addition & 0 deletions apps/src/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export { default as Test2271 } from './Test2271';
export { default as Test2282 } from './Test2282';
export { default as Test2317 } from './Test2317';
export { default as Test2332 } from './Test2332';
export { default as Test2395 } from './Test2395';
export { default as TestScreenAnimation } from './TestScreenAnimation';
export { default as TestHeader } from './TestHeader';
export { default as TestHeaderTitle } from './TestHeaderTitle';
Expand Down
6 changes: 5 additions & 1 deletion src/components/ScreenStackHeaderConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

export const ScreenStackHeaderSubview: React.ComponentType<
React.PropsWithChildren<ViewProps & { type?: HeaderSubviewTypes }>
> = ScreenStackHeaderSubviewNativeComponent as any;

Check warning on line 17 in src/components/ScreenStackHeaderConfig.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

Unexpected any. Specify a different type

export function ScreenStackHeaderConfig(
props: ScreenStackHeaderConfigProps,
Expand All @@ -23,6 +23,7 @@
<ScreenStackHeaderConfigNativeComponent
{...props}
style={styles.headerConfig}
pointerEvents="box-none"
/>
);
}
Expand Down Expand Up @@ -100,8 +101,11 @@
flexShrink: 1,
},
headerConfig: {
flexDirection: 'row',
position: 'absolute',
top: '-100%',
width: '100%',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
});
Loading