/** * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { useNavigation, useRoute } from '@react-navigation/native'; import React, { useContext, useState } from 'react'; import { Platform, RefreshControl, StyleSheet, View } from 'react-native'; import { ThemeContext } from 'react-native-elements'; import { ScrollView } from 'react-native-gesture-handler'; import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'; import ErrorView from '../components/ErrorView'; import Screens from '../constants/Screens'; const ErrorScreen = () => { const [ isRefreshing, setIsRefreshing ] = useState(false); const { theme } = useContext(ThemeContext); const insets = useSafeAreaInsets(); const navigation = useNavigation(); const route = useRoute(); const { icon, heading, message, details, buttonIcon, buttonTitle } = route.params; const safeAreaEdges = [ 'right', 'left' ]; if (Platform.OS !== 'ios') { safeAreaEdges.push('top'); } return ( {Platform.OS === 'ios' && ( )} {/* 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 */} { setIsRefreshing(true); navigation.replace(Screens.HomeScreen); setIsRefreshing(false); }} enabled={true} // iOS colors tintColor={theme.colors.grey1} backgroundColor={theme.colors.grey0} // Android colors colors={[ theme.colors.primary, theme.colors.secondary ]} progressBackgroundColor={theme.colors.background} /> } > navigation.replace(Screens.HomeScreen)} /> ); }; const styles = StyleSheet.create({ container: { flex: 1 } }); export default ErrorScreen;