-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeViewController.tsx
More file actions
221 lines (203 loc) · 11 KB
/
Copy pathHomeViewController.tsx
File metadata and controls
221 lines (203 loc) · 11 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import React, { useState } from 'react';
import {
Button,
View,
TouchableOpacity,
Text,
TextInput,
KeyboardAvoidingView,
StatusBar,
ScrollView,
Alert,
TouchableWithoutFeedback,
TouchableHighlight,
RefreshControl
} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import Svg, { Defs, LinearGradient, Stop, G, Path } from "react-native-svg"
import { ModalView } from 'react-native-ios-modal';
import { TableView, Cell } from 'react-native-tableview-simple';
import globalData from './data/globalData';
import { getAuth, signOut } from "firebase/auth";
import { doc, getDoc } from "firebase/firestore";
import { PointerInteractionView } from '@thefunbots/react-native-pointer-interactions';
const OnBoardLogoSVG = (props) => (
<Svg xmlns="http://www.w3.org/2000/svg" width={50} height={50} {...props}>
<Defs>
<LinearGradient
id="a"
x1={0.25}
x2={1.065}
y2={1.318}
gradientUnits="objectBoundingBox"
>
<Stop offset={0} stopColor="#f2db06" />
<Stop offset={1} stopColor="#f8520b" />
</LinearGradient>
</Defs>
<G data-name="Group 10">
<Path
data-name="Rectangle 6"
d="M0 13A13 13 0 0 1 13 0h24a13 13 0 0 1 13 13v24a13 13 0 0 1-13 13H13A13 13 0 0 1 0 37Z"
fill="url(#a)"
/>
<Path
d="M13.754 13.49Q17.961 9.247 25 9.247t11.2 4.243q4.207 4.243 4.207 11.511t-4.203 11.51q-4.165 4.243-11.2 4.243t-11.25-4.243Q9.589 32.268 9.589 25t4.165-11.51Zm5.207 18.862A7.536 7.536 0 0 0 25 34.873a7.411 7.411 0 0 0 6-2.521q2.166-2.521 2.166-7.352t-2.168-7.353a7.411 7.411 0 0 0-6-2.521 7.536 7.536 0 0 0-6.037 2.521q-2.124 2.521-2.124 7.352t2.124 7.353Z"
fill="#fff7e1"
/>
</G>
</Svg>
)
const UserCircle = (props) => {
return (
<Svg
width={45}
height={45}
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M40.5 22.5c0 9.941-8.059 18-18 18s-18-8.059-18-18 8.059-18 18-18 18 8.059 18 18ZM27 15.75a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Zm-4.5 9c-4.54 0-8.451 2.689-10.23 6.56A13.47 13.47 0 0 0 22.5 36a13.47 13.47 0 0 0 10.229-4.69 11.252 11.252 0 0 0-10.23-6.56Z"
fill="#333"
/>
</Svg>
)
}
const HomeViewController = props => {
const [modalVisible, setModalVisible] = useState(false);
const logOutPressed = () => {
const auth = getAuth();
signOut(auth).then(() => {
// Sign-out successful.
globalData.userEmail = ''
globalData.useruuid = ''
this.isModalOpen.setVisibility(false)
props.navigation.goBack()
}).catch((error) => {
// An error happened.
Alert.alert(
"Alert",
`${error}`,
[
{ text: "Dismiss", onPress: () => console.log("Dismiss Pressed") }
]
)
});
}
const [refreshing, setRefreshing] = useState(false);
const onRefresh = React.useCallback(() => {
setRefreshing(true);
wait(2000).then(() => setRefreshing(false));
}, []);
const wait = (timeout) => {
return new Promise(resolve => setTimeout(resolve, timeout));
}
return (
<View style={{ backgroundColor: '#FFFFFF', width: '100%', height: '100%' }}>
<ModalView ref={r => this.isModalOpen = r} isModalBGBlurred={false} isModalBGTransparent={false} >
<View style={{ width: '100%', height: '100%', backgroundColor: '#f3f2f8' }}>
<View style={{ height: 55, backgroundColor: '#F8F6F8', alignItems: 'center', justifyContent: 'center', borderBottomWidth: 0.5, borderColor: '#C0BFBF' }}>
<Text style={{ textAlign: 'center', fontSize: 16, }}>User Settings</Text>
<PointerInteractionView style={{ marginLeft: 5, alignSelf: 'flex-start', position: 'absolute', height: 45, alignItems: 'center', justifyContent: 'center', width: 70 }} pointerMode="highlight">
<TouchableOpacity onPress={() => {this.isModalOpen.setVisibility(false)}}><Text style={{ color: '#007AFF', fontSize: 17, }}>Close</Text></TouchableOpacity>
</PointerInteractionView>
</View>
<ScrollView style={{ width: '100%', height: '100%' }}>
<TableView style={{ marginTop: 20, }}>
<Cell
title={`${globalData.userEmail}`}
/>
<Cell
title={'Log Out'}
onPress={() => {logOutPressed()}}
titleTextColor={'red'}
/>
</TableView>
</ScrollView>
</View>
</ModalView>
<View style={{ paddingLeft: 25, flexDirection: 'row', justifyContent: 'space-between', paddingRight: 15, paddingBottom: 18, }}>
<View style={{ height: '100%', flexDirection: 'row', alignItems: 'center' }}>
<OnBoardLogoSVG style={{ marginTop: 15, }}></OnBoardLogoSVG>
</View>
<View style={{ height: '100%', flexDirection: 'row', alignItems: 'center' }}>
<PointerInteractionView pointerMode="highlight" style={{ borderRadius: 60, width: 55, height: 55, justifyContent: 'center', alignItems: 'center', marginTop: 15 }}>
<TouchableOpacity onPress={() => {this.isModalOpen.setVisibility(true)}}>
<View>
<UserCircle></UserCircle>
</View>
</TouchableOpacity>
</PointerInteractionView>
</View>
</View>
<ScrollView style={{ width: '100%', height: '100%' }}>
<View style={{ width: '100%', height: '100%', marginTop: 30, flexDirection: 'row', flexWrap: 'wrap', alignItems: 'flex-start' }}>
<PointerInteractionView pointerMode="hover" style={{ width: 250, marginHorizontal: 45, height: 190, borderRadius: 18, marginBottom: 40 }}>
<TouchableOpacity style={{ borderWidth: 1, width: 250, height: 190, borderRadius: 18, backgroundColor: '#FDE0B8', }}>
<Text style={{ fontSize: 24, marginTop: 120, marginLeft: 140, position: 'absolute' }}>Algebra</Text>
<Text style={{ fontSize: 16, marginTop: 150, marginLeft: 195, position: 'absolute' }}>4/8</Text>
</TouchableOpacity>
</PointerInteractionView>
<PointerInteractionView pointerMode="hover" style={{ width: 250, marginHorizontal: 45, height: 190, borderRadius: 18, marginBottom: 40 }}>
<TouchableOpacity style={{ borderWidth: 1, width: 250, height: 190, borderRadius: 18, backgroundColor: '#FDE0B8', }}>
<Text style={{ fontSize: 24, marginTop: 120, marginLeft: 140, position: 'absolute' }}>Algebra</Text>
<Text style={{ fontSize: 16, marginTop: 150, marginLeft: 195, position: 'absolute' }}>4/8</Text>
</TouchableOpacity>
</PointerInteractionView>
<PointerInteractionView pointerMode="hover" style={{ width: 250, marginHorizontal: 45, height: 190, borderRadius: 18, marginBottom: 40 }}>
<TouchableOpacity style={{ borderWidth: 1, width: 250, height: 190, borderRadius: 18, backgroundColor: '#FDE0B8', }}>
<Text style={{ fontSize: 24, marginTop: 120, marginLeft: 140, position: 'absolute' }}>Algebra</Text>
<Text style={{ fontSize: 16, marginTop: 150, marginLeft: 195, position: 'absolute' }}>4/8</Text>
</TouchableOpacity>
</PointerInteractionView>
<PointerInteractionView pointerMode="hover" style={{ width: 250, marginHorizontal: 45, height: 190, borderRadius: 18, marginBottom: 40 }}>
<TouchableOpacity style={{ borderWidth: 1, width: 250, height: 190, borderRadius: 18, backgroundColor: '#FDE0B8', }}>
<Text style={{ fontSize: 24, marginTop: 120, marginLeft: 140, position: 'absolute' }}>Algebra</Text>
<Text style={{ fontSize: 16, marginTop: 150, marginLeft: 195, position: 'absolute' }}>4/8</Text>
</TouchableOpacity>
</PointerInteractionView>
<PointerInteractionView pointerMode="hover" style={{ width: 250, marginHorizontal: 45, height: 190, borderRadius: 18, marginBottom: 40 }}>
<TouchableOpacity style={{ borderWidth: 1, width: 250, height: 190, borderRadius: 18, backgroundColor: '#FDE0B8', }}>
<Text style={{ fontSize: 24, marginTop: 120, marginLeft: 140, position: 'absolute' }}>Algebra</Text>
<Text style={{ fontSize: 16, marginTop: 150, marginLeft: 195, position: 'absolute' }}>4/8</Text>
</TouchableOpacity>
</PointerInteractionView>
<PointerInteractionView pointerMode="hover" style={{ width: 250, marginHorizontal: 45, height: 190, borderRadius: 18, marginBottom: 40 }}>
<TouchableOpacity style={{ borderWidth: 1, width: 250, height: 190, borderRadius: 18, backgroundColor: '#FDE0B8', }}>
<Text style={{ fontSize: 24, marginTop: 120, marginLeft: 140, position: 'absolute' }}>Algebra</Text>
<Text style={{ fontSize: 16, marginTop: 150, marginLeft: 195, position: 'absolute' }}>4/8</Text>
</TouchableOpacity>
</PointerInteractionView>
<PointerInteractionView pointerMode="hover" style={{ width: 250, marginHorizontal: 45, height: 190, borderRadius: 18, marginBottom: 40 }}>
<TouchableOpacity style={{ borderWidth: 1, width: 250, height: 190, borderRadius: 18, backgroundColor: '#FDE0B8', }}>
<Text style={{ fontSize: 24, marginTop: 120, marginLeft: 140, position: 'absolute' }}>Algebra</Text>
<Text style={{ fontSize: 16, marginTop: 150, marginLeft: 195, position: 'absolute' }}>4/8</Text>
</TouchableOpacity>
</PointerInteractionView>
<PointerInteractionView pointerMode="hover" style={{ width: 250, marginHorizontal: 45, height: 190, borderRadius: 18, marginBottom: 40 }}>
<TouchableOpacity style={{ borderWidth: 1, width: 250, height: 190, borderRadius: 18, backgroundColor: '#FDE0B8', }}>
<Text style={{ fontSize: 24, marginTop: 120, marginLeft: 140, position: 'absolute' }}>Algebra</Text>
<Text style={{ fontSize: 16, marginTop: 150, marginLeft: 195, position: 'absolute' }}>4/8</Text>
</TouchableOpacity>
</PointerInteractionView>
<PointerInteractionView pointerMode="hover" style={{ width: 250, marginHorizontal: 45, height: 190, borderRadius: 18, marginBottom: 40 }}>
<TouchableOpacity style={{ borderWidth: 1, width: 250, height: 190, borderRadius: 18, backgroundColor: '#FDE0B8', }}>
<Text style={{ fontSize: 24, marginTop: 120, marginLeft: 140, position: 'absolute' }}>Algebra</Text>
<Text style={{ fontSize: 16, marginTop: 150, marginLeft: 195, position: 'absolute' }}>4/8</Text>
</TouchableOpacity>
</PointerInteractionView>
</View>
<RefreshControl
refreshing={refreshing}
onRefresh={() => {console.log('refresh'); onRefresh()}}
style={{ position: 'relative' }}
/>
</ScrollView>
</View>
);
};
export default HomeViewController;