-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
94 lines (89 loc) · 2.56 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
import {
DripsyProvider,
SafeAreaView,
Button,
Box,
Row,
Text,
createThemedComponent,
} from 'dripsy';
import { StatusBar } from 'expo-status-bar';
import React, { useCallback, useState } from 'react';
import { Alert, Platform } from 'react-native';
enum TimerMode {
POMODORO = 'Pomodoro',
SHORT_BREAK = 'Short Break',
LONG_BREAK = 'Long Break',
}
const timerModeValueMap = {
[TimerMode.POMODORO]: 25,
[TimerMode.SHORT_BREAK]: 5,
[TimerMode.LONG_BREAK]: 10,
};
const theme = {
colors: {
// theme ui says that you using at least have the default color keys set, but setting them doesn't seem to have an effect so I might deviate
primary: '#db524d',
secondary: 'white',
secondaryTransparent: 'rgba(255,255,255,0.1)',
},
text: {
body: {
color: 'secondary',
},
},
cards: {
main: {
backgroundColor: 'secondaryTransparent',
width: ['90%', '40%'],
height: '40%',
padding: 3,
},
},
};
const Card = createThemedComponent(Box, {
themeKey: 'cards',
defaultVariant: 'main',
});
export default function App() {
const [timerMode, setTimerMode] = useState(TimerMode.POMODORO);
const onPressStart = useCallback(() => {
const message = `Set timer for ${timerModeValueMap[timerMode]} minutes! Just kidding I haven't coded this part yet.`;
if (Platform.OS === 'web') {
return console.info(message);
}
return Alert.alert(message);
}, [timerMode]);
return (
<DripsyProvider theme={theme}>
<SafeAreaView
sx={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'primary',
}}>
<Card>
<Row sx={{ flex: 1, justifyContent: 'space-evenly' }}>
<Button title={TimerMode.POMODORO} onPress={() => setTimerMode(TimerMode.POMODORO)} />
<Button
title={TimerMode.SHORT_BREAK}
onPress={() => setTimerMode(TimerMode.SHORT_BREAK)}
/>
<Button
title={TimerMode.LONG_BREAK}
onPress={() => setTimerMode(TimerMode.LONG_BREAK)}
/>
</Row>
<Box sx={{ flex: 3, flexDirection: 'column', justifyContent: 'center' }}>
<Text
sx={{ textAlign: 'center', fontSize: 8 }}>{`${timerModeValueMap[timerMode]}`}</Text>
</Box>
<Button title={'Start'} onPress={onPressStart} sx={{ flex: 1 }} />
</Card>
<Text sx={{ padding: 3 }}>Time to work!</Text>
<StatusBar style="auto" />
</SafeAreaView>
</DripsyProvider>
);
}