-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
67 lines (65 loc) · 1.73 KB
/
App.js
File metadata and controls
67 lines (65 loc) · 1.73 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
import { useState } from 'react';
import {
SafeAreaView,
StyleSheet,
Platform,
StatusBar,
Image,
View,
} from 'react-native';
import uuid from 'react-native-uuid';
import { Focus } from './src/features/Focus';
import { Timer } from './src/features/Timer';
import colors from './src/utils/colors';
import { FocusHistory } from './src/features/FocusHistory';
import WhiteDot from './assets/white_dot..png';
export default function App() {
const [subject, setSubject] = useState(null);
const [history, setHistory] = useState([
{ id: uuid.v4(), text: 'React Native' },
{ id: uuid.v4(), text: 'Fingerstyle guitar' },
]);
return (
<SafeAreaView style={styles.container}>
{!subject ? (
<>
<View style={styles.logoContainer}>
<Image source={WhiteDot} style={styles.logo} />
</View>
<Focus addSubject={setSubject} />
<FocusHistory history={history} onPress={setSubject} />
</>
) : (
<Timer
setFocusSubject={setSubject}
focusSubject={subject}
onTimerEnd={(subject) => {
console.log('subject', subject)
const subjectExists = history.some(item => item.text === subject.text)
if (!subjectExists) {
setHistory([...history, subject]);
}
}}
clearSubject={() => {}}
/>
)}
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0,
backgroundColor: colors.black,
},
logoContainer: {
flex: 0.2,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
logo: {
width: 64,
height: 64,
},
});