Skip to content

Instantly share code, notes, and snippets.

@mkhmylife
Created May 29, 2023 08:44
Show Gist options
  • Save mkhmylife/5b1f13698ad9719e54d3b806379223bc to your computer and use it in GitHub Desktop.
Save mkhmylife/5b1f13698ad9719e54d3b806379223bc to your computer and use it in GitHub Desktop.
NotFound.tsx
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