forked from jzpz/inventoryapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHome.js
More file actions
181 lines (178 loc) · 8.19 KB
/
Home.js
File metadata and controls
181 lines (178 loc) · 8.19 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import React, { useState, useEffect, useContext } from 'react';
import { StyleSheet, Text, View, Button, KeyboardAvoidingView, Linking, ImageBackground, ScrollView } from 'react-native';
import { database, auth } from './Database';
import { userSignIn, userSignOut, registerAccount } from './database_functions/UserAuth';
import Icon from 'react-native-vector-icons/FontAwesome';
import { Divider, Avatar } from 'react-native-elements';
import { SolidButton } from './components/SolidButton';
import { TransparentButton } from './components/TransparentButton';
import { StyledInput } from './components/StyledInput';
import { useTheme } from '@react-navigation/native';
import { styles } from './Styles'
import { InfoDialog } from './components/InfoDialog';
import { UserContext } from './AppContext';
import { Ionicons } from '@expo/vector-icons';
export const Frontpage = ({ navigation }) => {
const [visibleDialog, setVisibleDialog] = useState('');
const { user, setUser } = useContext(UserContext);
const [dialogMessage, setDialogMessage] = useState({title: '', message: ''})
const colors = useTheme().colors;
const changeVisibleDialog = (value, data = null) => {
if(value !== null) setVisibleDialog(value)
if(data) setDialogMessage(data)
}
return (
<>
<ScrollView contentContainerStyle={{alignItems:"center"}} style={[{flex:1, padding: 10}]}>
<View style={{flex:1}}>
{/* Input Container Main */}
<View style={[{width:"100%",flexDirection:"row",alignItems:"center", backgroundColor:colors.card, borderRadius:5, padding:20}]}>
<View style={{width:"100%"}}>
<View style={{flexDirection:"row"}}>
<Ionicons name="logo-react" size={27} color={colors.primary2} style={{marginRight:10}} />
<Text style={{color:colors.primary3, fontSize:22, fontWeight:"bold"}}>
Welcome {user?.displayName}
</Text>
</View>
<Divider color={colors.reverse.card} style={{marginTop:10,marginBottom:10}} />
<View style={{flexDirection:"row"}}>
<View style={{marginRight:10}}>
<Avatar
title="user"
size={65}
rounded
source={ user?.photoURL ? { uri: user?.photoURL || {} } : require("./assets/user.png")}
/>
</View>
<View>
<Text style={[styles.buttonLabel, {color: colors.text, fontSize:16}]}>
Welcome to Inventory App!
</Text>
</View>
</View>
</View>
</View>
{/* Profile Containers */}
<View style={[{width:"100%",flexDirection:"row",alignItems:"center"}]}>
{/* User profile */}
<View style={{flex: 1, marginTop:10, marginBottom:10, marginRight:5, backgroundColor:colors.card, borderRadius:5, padding:20}}>
<View style={{flexDirection:"row"}}>
<Icon
style={{marginRight: 15}}
name="user"
size={30}
color={colors.primary2}
/>
<Text style={{color:colors.primary3, fontSize:20, fontWeight:"bold"}}>Account</Text>
</View>
<Divider color={colors.reverse.card} style={{marginTop:10,marginBottom:10}} />
<Text style={[styles.buttonLabel, {color: colors.text, fontSize:16, marginBottom:18}]}>
Change preferences and edit account details at Settings
</Text>
<SolidButton
style={{width:"100%", marginTop:10}}
onPress={() => navigation.navigate('Settings')}
title="Go to Settings"
/>
</View>
{/* User item data */}
<View style={{flex: 1, marginTop:10, marginBottom:10, marginLeft:5, backgroundColor:colors.card, borderRadius:5, padding:20}}>
<View style={{flexDirection:"row"}}>
<Icon
style={{marginRight: 15}}
name="briefcase"
size={30}
color={colors.primary2}
/>
<Text style={{color:colors.primary3, fontSize:20, fontWeight:"bold"}}>My Items</Text>
</View>
<Divider color={colors.reverse.card} style={{marginTop:10,marginBottom:10}} />
<View style={{flexDirection:"row"}}></View>
<Text style={[styles.buttonLabel, {color: colors.text, fontSize:16}]}>
View your inventory, inventories and items at the Items tab
</Text>
<SolidButton
style={{width:"100%", marginTop:10}}
onPress={() => navigation.navigate('Items', { screen: 'Inventories' })}
title="Go to Items"
/>
</View>
</View>
{/* Help Container */}
<View style={[{width:"100%",flexDirection:"row",alignItems:"center", backgroundColor:colors.card, borderRadius:5, padding:20}]}>
<View style={{width:"100%", alignItems:"center"}}>
<View style={{flexDirection:"row"}}>
<Icon
style={{marginRight: 15}}
name="question-circle"
size={30}
color={colors.primary2}
/>
<Text style={{color:colors.extradark, fontSize:20, fontWeight:"bold", textDecorationLine:"underline"}}
onPress={() => {
setVisibleDialog("info")
setDialogMessage({
title: "About the app",
message: <>
<Text style={{color: colors.text}}>
Inventory App allows you to create lists which contain information about items. Get started by clicking
</Text>
<Text style={{color:colors.primary3}}> Items</Text>
<Text style={{color: colors.text}}> on the bottom right corner.</Text>
<Text style={{color: colors.text}}>{"\n\n"}GitHub:{"\n"}</Text>
<Text
style={{color: colors.primary3, textDecorationLine:"underline", fontSize:16}}
onPress={() => Linking.openURL('https://github.com/bgj424/inventoryapp')}
>
github.com/bgj424/inventoryapp
</Text>
<Text style={{color: colors.text}}>{"\n\n"}Made with </Text>
<Ionicons name="logo-firebase" size={20} color={colors.text} style={{marginRight:5}} />
<Ionicons name="logo-react" size={20} color={colors.text} style={{marginRight:5}} />
</>
})
}}
>
About the app
</Text>
</View>
</View>
</View>
{/* Footer */}
<View style={{alignItems:"center", marginVertical: 20}}>
<View style={[{width:"70%", alignItems:"center"}]}>
{/* Logout Button */}
<SolidButton
style={{width:"50%", marginBottom:10}}
color={colors.extradark}
onPress={() => userSignOut()}
title="Log out"
/>
{/* App info */}
<View style={{flexDirection:"row", borderRadius:5, alignItems:"center"}}>
<Ionicons name="logo-react" size={20} color={colors.subtle} style={{marginRight:5}} />
<Text style={{color: colors.subtle, fontSize:16, marginRight:6}}>
Inventory App (Version 1.0)
</Text>
<Ionicons name="logo-github" size={20} color={colors.text} style={{marginRight:5, marginLeft: 6}} />
<Text
style={{color: colors.primary3, textDecorationLine:"underline", fontSize:16}}
onPress={() => Linking.openURL('https://github.com/bgj424/inventoryapp')}
>
GitHub
</Text>
</View>
</View>
</View>
</View>
</ScrollView>
<InfoDialog
visibleDialog={visibleDialog}
changeVisibleDialog={changeVisibleDialog}
title={dialogMessage.title}
message={dialogMessage.message}
icon={dialogMessage.icon}
/>
</>
)
}