Obanana_test/App.js

120 lines
3.2 KiB
JavaScript
Raw Normal View History

2024-02-12 08:58:57 +08:00
import {
faCheck,
faCheckCircle,
faExclamationCircle,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome";
2023-09-26 14:33:01 +08:00
import { StatusBar } from "expo-status-bar";
import {
Platform,
SafeAreaView,
StyleSheet,
Text,
View,
StatusBar as StatusBars,
Dimensions,
} from "react-native";
2024-02-12 08:58:57 +08:00
import { ToastProvider } from "react-native-toast-notifications";
2023-09-26 14:33:01 +08:00
import Route from "./app/routes/route";
2024-02-12 08:58:57 +08:00
// import WebSocket from "ws";
// import { WebSocket } from 'react-native';
// const ws = new WebSocket('wss://192.168.50.15:4028/');
2023-09-26 14:33:01 +08:00
const height = Dimensions.get("window").height;
const width = Dimensions.get("window").width;
2024-02-12 08:58:57 +08:00
export default function App() {
2024-02-12 08:58:57 +08:00
// const ws = new WebSocket("ws://localhost:8080");
return (
2023-09-26 14:33:01 +08:00
<SafeAreaView style={styles.container}>
2024-02-12 08:58:57 +08:00
<ToastProvider
successColor="#98eb00"
dangerColor="red"
offsetTop={110}
// renderType={{
// custom_type: (toast) => (
// <View style={{padding: 15, backgroundColor: 'grey'}}>
// <Text>{toast.message}</Text>
// </View>
// )
// }}
renderToast={(toast) => (
<View
style={{
// padding: 15,
paddingHorizontal: 25,
paddingVertical: 10,
color:
toast.type === "success"
? "#98eb00"
: toast.type === "danger"
? "red"
: toast.type === "warning"
? "yellow"
: toast.type === "normal"
? "#98eb00"
: "red",
backgroundColor: "#ffff",
borderWidth: 1,
borderColor: "#eeee",
borderRadius: 25,
flexDirection: "row",
}}
>
<FontAwesomeIcon
icon={
toast.type === "success"
? faCheckCircle
: toast.type === "danger"
? faExclamationCircle
: toast.type === "warning"
? faExclamationCircle
: toast.type === "normal"
? faCheck
: "red"
}
color={
toast.type === "success"
? "#98eb00"
: toast.type === "danger"
? "red"
: toast.type === "warning"
? "yellow"
: toast.type === "normal"
? "#98eb00"
: "red"
}
size={20}
/>
<Text style={{ paddingLeft: 10 }}>{toast.message}</Text>
</View>
)}
>
<View style={styles.wrapper}>
<StatusBar style="auto" />
<Route />
</View>
</ToastProvider>
2023-09-26 14:33:01 +08:00
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
2023-09-26 14:33:01 +08:00
// flex: 1,
backgroundColor: "#ffff",
alignItems: "center",
// justifyContent: "center",
height: "100%",
paddingTop: Platform.OS === "android" ? StatusBars.currentHeight + 10 : "",
},
wrapper: {
height: "100%",
width: "100%",
// backgroundColor:"#333"
},
});