forked from cjam/react-native-spotify-remote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
61 lines (54 loc) · 1.59 KB
/
App.tsx
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
import React, { useContext } from 'react';
import { View, SafeAreaView } from 'react-native';
import { Text, Root, Tabs, Tab } from 'native-base';
import AppContext, { AppContextProvider } from './AppContext';
import styles from './styles';
import ConnectButton from './Components/ConnectButton';
import Authenticate from './Components/Authenticate';
import TransportControls from './Components/TransportControls';
import SpotifyContent from './Components/SpotifyContent';
import Miscelaneous from './Components/Miscelaneous';
import EnvVars from './Components/EnvVars';
const AppLayout: React.SFC = () => {
const { token, error, clearError } = useContext(AppContext);
return (
<View style={styles.container} >
{token ?
<>
<ConnectButton />
<Tabs initialPage={0}>
<Tab heading="Now Playing" tabStyle={{ padding: 10 }}>
<TransportControls />
</Tab>
<Tab heading="Songs">
<SpotifyContent />
</Tab>
<Tab heading="Misc">
<Miscelaneous />
</Tab>
</Tabs>
</>
:
<>
<Authenticate />
<EnvVars />
</>
}
{error && (
<Text onPress={clearError} style={styles.error}>{error.code}: {error.message}</Text>
)}
</View>
)
}
const App: React.SFC = () => {
return (
<AppContextProvider>
<SafeAreaView style={{ width: "100%", height: "100%" }}>
<Root>
<AppLayout />
</Root>
</SafeAreaView >
</AppContextProvider>
);
};
export default App;