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 layout issues on error screen for notch iPhones #201

Merged
merged 1 commit into from
Dec 30, 2020
Merged
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
24 changes: 13 additions & 11 deletions screens/ErrorScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
import React, { useState } from 'react';
import { Platform, RefreshControl, StyleSheet, View } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
import { SafeAreaView } from 'react-native-safe-area-context';
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import { useNavigation, useRoute } from '@react-navigation/native';
import Constants from 'expo-constants';

import ErrorView from '../components/ErrorView';
import Colors from '../constants/Colors';

const ErrorScreen = () =>{
const [isRefreshing, setIsRefreshing] = useState(false);

const insets = useSafeAreaInsets();

const navigation = useNavigation();
const route = useRoute();
const { icon, heading, message, details, buttonIcon, buttonTitle } = route.params;
Expand All @@ -26,14 +27,20 @@ const ErrorScreen = () =>{
}

return (
<SafeAreaView style={styles.container} edges={safeAreaEdges} >
<SafeAreaView style={styles.container} edges={safeAreaEdges} mode='margin' >
{Platform.OS === 'ios' && (
<View style={styles.statusBarSpacer} />
<View style={{
...styles.statusBarSpacer,
height: insets.top
}} />
)}
{/* We need to wrap the ErrorView in a ScrollView to enable the same pull to */}
{/* refresh behavior as the WebView since network errors render _inside_ the WebView */}
<ScrollView
style={styles.scrollView}
style={{
...StyleSheet.absoluteFill,
top: Platform.OS === 'ios' ? insets.top : 0
}}
contentContainerStyle={{ flex: 1 }}
refreshControl={
<RefreshControl
Expand Down Expand Up @@ -72,13 +79,8 @@ const styles = StyleSheet.create({
flex: 1,
backgroundColor: Colors.backgroundColor
},
scrollView: {
...StyleSheet.absoluteFill,
top: Platform.OS === 'ios' ? Constants.statusBarHeight : 0
},
statusBarSpacer: {
backgroundColor: Colors.headerBackgroundColor,
height: Constants.statusBarHeight
backgroundColor: Colors.headerBackgroundColor
}
});

Expand Down