-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
113 lines (103 loc) · 2.94 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import React, { useState, useEffect } from "react";
import { NativeRouter as Router, Route, Switch } from "react-router-native";
import AsyncStorage from "@react-native-community/async-storage";
import Home from "./components/Home";
import SafeLayout from "./layouts/SafeLayout";
import Guilds from "./components/Guilds";
import Guild from "./components/Guild";
import Players from "./components/Players";
import Player from "./components/Player";
import Market from "./components/Market";
import ItemResult from "./components/ItemResult";
import Options from "./components/Options";
export default function App() {
const [lang, setLang] = useState("EN-US");
useEffect(() => {
const getLang = async () => {
try {
const savedLang = await AsyncStorage.getItem("lang");
if (savedLang !== null) setLang(savedLang);
} catch {}
};
getLang();
}, []);
useEffect(() => {
const saveLang = async () => {
try {
await AsyncStorage.setItem("lang", lang);
} catch {}
};
saveLang();
}, [lang]);
const [itemName, setItemName] = useState("");
const [guilds, setGuilds] = useState([]);
const [guildName, setGuildName] = useState([]);
const [playerName, setPlayerName] = useState("");
return (
<SafeLayout>
<Router>
<Switch>
<Route
path="/market/:id"
children={
<ItemResult
itemName={[itemName, setItemName]}
lang={[lang, setLang]}
/>
}
/>
<Route
path="/guild/:id"
children={
<Guild
guilds={[guilds, setGuilds]}
guildName={[guildName, setGuildName]}
playerName={[playerName, setPlayerName]}
lang={[lang, setLang]}
/>
}
/>
<Route
path="/guild"
children={
<Guilds
guilds={[guilds, setGuilds]}
guildName={[guildName, setGuildName]}
lang={[lang, setLang]}
/>
}
/>
<Route
path="/player/:id"
children={
<Player
playerName={[playerName, setPlayerName]}
guildName={[guildName, setGuildName]}
lang={[lang, setLang]}
/>
}
/>
<Route
path="/player"
children={
<Players
playerName={[playerName, setPlayerName]}
lang={[lang, setLang]}
/>
}
/>
<Route
path="/options"
children={<Options lang={[lang, setLang]} />}
/>
<Route
path="/"
children={
<Market setItemName={setItemName} lang={[lang, setLang]} />
}
/>
</Switch>
</Router>
</SafeLayout>
);
}