-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
128 lines (119 loc) · 3.48 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import React, { useState } from "react";
import { StatusBar, SafeAreaView, Text, Image, Platform, TouchableOpacity } from "react-native";
import { Entypo, AntDesign } from "@expo/vector-icons";
import { NavigationContainer } from "@react-navigation/native";
import { createMaterialTopTabNavigator } from "@react-navigation/material-top-tabs";
import { theme, statusBarHeight } from "./shared/theme";
import { JournalNavigator } from "./screens/JournalList/JournalNavigator";
import { TodayJournalScreen } from "./screens/TodayJournalScreen";
import { GlobalProvider } from "./shared/context";
import styled from "styled-components/native";
import { useAsyncAssets } from "./shared/assets";
import { withNavigationContext } from "./shared/navigation-context";
import { SettingsNavigator } from "./screens/Settings/SettingsNavigator";
const TopSafeAreaPadding = styled.SafeAreaView`
flex: 0;
background-color: ${theme.color.topbar.background};
`;
const MainSafeArea = styled.SafeAreaView`
flex: 1;
background-color: ${theme.color.navbarBackground};
`;
const LoadingContainer = styled.SafeAreaView`
flex: 1;
background-color: ${theme.color.background};
justify-content: center;
align-items: center;
`;
const LogoImage = styled.Image`
height: 100px;
width: 90px;
`;
const Tab = createMaterialTopTabNavigator();
function BottomNavigator() {
return (
<Tab.Navigator
tabBarPosition="bottom"
tabBarOptions={{
tabStyle: {
borderTopColor: theme.color.navbarBorder,
borderTopWidth: 3
},
iconStyle: {
justifyContent: "center",
alignItems: "center"
},
activeTintColor: "#000",
showIcon: true,
indicatorStyle: {
height: 0
},
pressColor: theme.color.background,
pressOpacity: 1,
labelStyle: {
textTransform: "none",
fontFamily: theme.font.sansBold
},
style: {
backgroundColor: theme.color.navbarBackground
}
}}
>
<Tab.Screen
name="Journal"
component={withNavigationContext(JournalNavigator)}
options={{
tabBarLabel: "Journal",
tabBarIcon: props => (
<Entypo name="calendar" color={props.color} size={props.focused ? 24 : 20} />
)
}}
/>
<Tab.Screen
name="Today"
component={withNavigationContext(TodayJournalScreen)}
options={{
tabBarLabel: "Today",
tabBarIcon: props => (
<Entypo name="new-message" color={props.color} size={props.focused ? 24 : 20} />
)
}}
/>
<Tab.Screen
name="Settings"
component={withNavigationContext(SettingsNavigator)}
options={{
tabBarIcon: props => (
<AntDesign name="setting" color={props.color} size={props.focused ? 24 : 20} />
)
}}
/>
</Tab.Navigator>
);
}
export default function App() {
const loading = useAsyncAssets();
if (loading) {
return (
<>
<StatusBar hidden={false} />
<LoadingContainer>
<LogoImage source={require("./assets/stoic-journal-icon-512w.png")} />
</LoadingContainer>
</>
);
}
return (
<>
<StatusBar hidden={false} />
<TopSafeAreaPadding />
<MainSafeArea>
<GlobalProvider>
<NavigationContainer>
<BottomNavigator />
</NavigationContainer>
</GlobalProvider>
</MainSafeArea>
</>
);
}