Created
May 29, 2023 08:44
-
-
Save mkhmylife/5b1f13698ad9719e54d3b806379223bc to your computer and use it in GitHub Desktop.
NotFound.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StyleSheet, TouchableOpacity } from 'react-native'; | |
import { Text, View } from '../components/Themed'; | |
import { RootStackScreenProps } from '../types'; | |
import WebView from "react-native-webview"; | |
export default function NotFoundScreen({ navigation, route }: RootStackScreenProps<'NotFound'>) { | |
if (route.path) { | |
return ( | |
<View style={{flex: 1}}> | |
<WebView style={styles.webview} source={{ uri: `https://www.kilowatt.hk/${route.path}` }} /> | |
</View> | |
) | |
} | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.title}>未能找到頁面</Text> | |
<TouchableOpacity onPress={() => navigation.replace('Root')} style={styles.link}> | |
<Text style={styles.linkText}>返回主頁</Text> | |
</TouchableOpacity> | |
</View> | |
); | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
webview: { | |
flex: 1, | |
alignItems: 'center', | |
justifyContent: 'center', | |
flexDirection: 'column' | |
}, | |
title: { | |
fontSize: 20, | |
fontWeight: 'bold', | |
}, | |
link: { | |
marginTop: 15, | |
paddingVertical: 15, | |
}, | |
linkText: { | |
fontSize: 14, | |
color: '#2e78b7', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment