<View> overlaps after navigation

流过昼夜 提交于 2021-01-28 22:43:48

问题


My react-native screen looks somewhat like this:

export const JourneyResultScreen: React.FunctionComponent = () => {
  return (
    <SafeAreaView style={styles.safeAreaViewContainer}>
      <View style={styles.container}>
        <Text>HELO</Text>
      </View>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  safeAreaViewContainer: { flex: 1, backgroundColor: 'red'},
  container: {  flex: 1, backgroundColor: 'pink'},
});

The SafeAreaView (red coloured) works well on all screens except this one, even though I am using the same styling everywhere. It is supposed to be shown at the top and bottom both. Here it is only shown at the bottom and not at the top. In this case, it is being hidden by the View (in pink).

I am afraid this could be because of how I navigate to this screen from the previous one. The navigation looks like:

App.tsx:

                <NavigationStack.Screen
                  name="Journey"
                  component={JourneyScreenNavigation}
                  options={{
                    headerShown: false,
                    ...TransitionPresets.FadeFromBottomAndroid,
                  }}
                />
export const JourneyScreenNavigation: React.FC = () => {
  return (
    <NavigationStack.Navigator initialRouteName="Journey" mode="modal">
      <NavigationStack.Screen
        name="Journey"
        component={JourneySearchScreen}
        options={{ headerShown: false }}
      />
      <NavigationStack.Screen
        name="JourneyMap"
        component={JourneyResultScreen}
        options={{
          headerShown: false,
          gestureEnabled: false,
          cardStyleInterpolator:
            CardStyleInterpolators.forFadeFromBottomAndroid,
        }}
      />
      <NavigationStack.Screen
        name="TripsNavigation"
        component={AvailableTripsNavigation}
        options={{
          gestureEnabled: false,
          headerShown: false,
          cardStyleInterpolator:
            CardStyleInterpolators.forFadeFromBottomAndroid,
        }}
      />
    </NavigationStack.Navigator>
  );
};

How can I fix the SafeAreaView at the top? Why is it being overlapped by the View?

来源:https://stackoverflow.com/questions/63437068/view-overlaps-after-navigation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!