|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import { |
| 3 | + Text, |
| 4 | + View, |
| 5 | + SafeAreaView, |
| 6 | + StyleSheet, |
| 7 | + Platform, |
| 8 | + StatusBar, |
| 9 | +} from 'react-native'; |
| 10 | +import { colors } from './src/utils/colors'; |
| 11 | +import { AddTask } from './src/features/AddTask'; |
| 12 | +import { Timer } from './src/components/Timer'; |
| 13 | +import { StartButton } from './src/components/StartButton'; |
| 14 | +import { StopButton } from './src/components/StopButton'; |
| 15 | +import { PauseButton } from './src/components/PauseButton'; |
| 16 | +import { Pomodoro } from './src/components/Pomodoro'; |
| 17 | + |
| 18 | +export default function App({ onPress = { onPress } }) { |
| 19 | + const [currentTextInput, setCurrentTextInput] = useState(null); |
| 20 | + const [isStartTimerPressed, setIsStartTimerPressed] = useState(false); |
| 21 | + const [isStopTimerPressed, setIsStopTimerPressed] = useState(false); |
| 22 | + const [isPauseTimerPressed, setIsSPauseTimerPressed] = useState(false); |
| 23 | + |
| 24 | + const stopTimer = () => { |
| 25 | + if (isStartTimerPressed) { |
| 26 | + setIsStartTimerPressed(false); |
| 27 | + } else { |
| 28 | + setIsStartTimerPressed(true); |
| 29 | + } |
| 30 | + }; |
| 31 | + const pauseTimer = () => { |
| 32 | + if (isPauseTimerPressed) { |
| 33 | + setIsSPauseTimerPressed(false); |
| 34 | + } else { |
| 35 | + setIsSPauseTimerPressed(true); |
| 36 | + } |
| 37 | + }; |
| 38 | + |
| 39 | + return ( |
| 40 | + <SafeAreaView style={styles.container}> |
| 41 | + <View style={styles.titleContainer}> |
| 42 | + <Text style={styles.title}>Think Flow App</Text> |
| 43 | + </View> |
| 44 | + {!currentTextInput ? ( |
| 45 | + <AddTask addFlow={setCurrentTextInput} /> |
| 46 | + ) : ( |
| 47 | + <View style={styles.timerContainer}> |
| 48 | + <View style={styles.startTimeContainer}> |
| 49 | + {isStartTimerPressed ? ( |
| 50 | + <View style={styles.timerContainer}> |
| 51 | + <Text style={styles.text}> |
| 52 | + Focusing on: {currentTextInput} |
| 53 | + </Text> |
| 54 | + </View> |
| 55 | + ) : ( |
| 56 | + <View style={styles.timerContainer}> |
| 57 | + <Text style={styles.text}> |
| 58 | + Start your flow state timer for {currentTextInput} |
| 59 | + </Text> |
| 60 | + </View> |
| 61 | + )} |
| 62 | + {!isStartTimerPressed ? ( |
| 63 | + <StartButton |
| 64 | + startTimer={setIsStartTimerPressed} |
| 65 | + isStartTimerPressed={isStartTimerPressed} |
| 66 | + /> |
| 67 | + ) : ( |
| 68 | + <View style={styles.stopTimeContainer}> |
| 69 | + <Timer isPauseTimerPressed={isPauseTimerPressed} /> |
| 70 | + <View style={styles.buttons}> |
| 71 | + <StopButton |
| 72 | + stopTimer={stopTimer} |
| 73 | + isStopTimerPressed={isStopTimerPressed} |
| 74 | + isStartTimerPressed={isStartTimerPressed} |
| 75 | + /> |
| 76 | + <PauseButton |
| 77 | + pauseTimer={pauseTimer} |
| 78 | + isPauseTimerPressed={isPauseTimerPressed} |
| 79 | + setIsSPauseTimerPressed={setIsSPauseTimerPressed} |
| 80 | + /> |
| 81 | + </View> |
| 82 | + <View style={styles.pomodoro}> |
| 83 | + <Pomodoro /> |
| 84 | + </View> |
| 85 | + </View> |
| 86 | + )} |
| 87 | + </View> |
| 88 | + </View> |
| 89 | + )} |
| 90 | + </SafeAreaView> |
| 91 | + ); |
| 92 | +} |
| 93 | + |
| 94 | +const styles = StyleSheet.create({ |
| 95 | + container: { |
| 96 | + flex: 1, |
| 97 | + paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0, |
| 98 | + backgroundColor: colors.backgroundDark, |
| 99 | + }, |
| 100 | + titleContainer: { |
| 101 | + alignItems: 'center', |
| 102 | + justifyContent: 'center', |
| 103 | + color: 'white', |
| 104 | + marginTop: 80, |
| 105 | + }, |
| 106 | + title: { |
| 107 | + justifyContent: 'center', |
| 108 | + alignItems: 'center', |
| 109 | + fontSize: 24, |
| 110 | + color: 'white', |
| 111 | + fontWeight: 900, |
| 112 | + }, |
| 113 | + timerContainer: { |
| 114 | + marginTop: 10, |
| 115 | + alignItems: 'center', |
| 116 | + justifyContent: 'center', |
| 117 | + height: 50, |
| 118 | + }, |
| 119 | + text: { |
| 120 | + color: colors.textColor, |
| 121 | + alignItems: 'center', |
| 122 | + justifyContent: 'center', |
| 123 | + fontSize: 16, |
| 124 | + }, |
| 125 | + startTimeContainer: { |
| 126 | + alignItems: 'center', |
| 127 | + justifyContent: 'center', |
| 128 | + marginTop: 60, |
| 129 | + }, |
| 130 | + stopTimeContainer: { |
| 131 | + alignItems: 'center', |
| 132 | + justifyContent: 'space-between', |
| 133 | + height: 90, |
| 134 | + }, |
| 135 | + buttons: { |
| 136 | + width: 320, |
| 137 | + flexDirection: 'row', |
| 138 | + marginTop: 10, |
| 139 | + justifyContent: 'space-between', |
| 140 | + }, |
| 141 | + pomodoro: { |
| 142 | + height: 350, |
| 143 | + width: 350, |
| 144 | + marginTop: 20, |
| 145 | + alignItems: 'center', |
| 146 | + textAlign: 'center', |
| 147 | + }, |
| 148 | +}); |
0 commit comments