forked from dsernst/GoenkaNative
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'Be happy' msg after countdown finishes
- Loading branch information
Showing
6 changed files
with
167 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useState } from 'react' | ||
import { Animated } from 'react-native' | ||
|
||
const bodyTextColor = '#f1f1f1' | ||
|
||
export default () => { | ||
const [fadeAnim] = useState(new Animated.Value(0)) | ||
|
||
React.useEffect(() => { | ||
Animated.loop( | ||
Animated.sequence([ | ||
Animated.timing(fadeAnim, { | ||
duration: 4000, | ||
toValue: 0.8, | ||
}), | ||
Animated.timing(fadeAnim, { | ||
duration: 3000, | ||
toValue: 0, | ||
}), | ||
]), | ||
).start() | ||
}, [fadeAnim]) | ||
|
||
return ( | ||
<Animated.Text | ||
style={{ | ||
alignSelf: 'center', | ||
color: bodyTextColor, | ||
fontFamily: 'Palatino', | ||
fontSize: 30, | ||
fontStyle: 'italic', | ||
fontWeight: '400', | ||
marginTop: 45, | ||
opacity: fadeAnim, | ||
}} | ||
> | ||
Be happy | ||
</Animated.Text> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,64 @@ | ||
/* eslint-disable react-native/no-inline-styles */ | ||
import React from 'react' | ||
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native' | ||
import { Text, TouchableOpacity, View } from 'react-native' | ||
import KeepAwake from 'react-native-keep-awake' | ||
import CountdownCircle from './react-native-countdown-circle' | ||
import BeHappyText from './BeHappyText' | ||
|
||
// Shared vars | ||
const bodyTextColor = '#f1f1f1' | ||
const btnSize = 80 | ||
|
||
type CountdownScreenProps = { | ||
duration: string | ||
finished: boolean | ||
pressStop: () => void | ||
toggle: (key: string) => () => void | ||
} | ||
|
||
const CountdownScreen = ({ duration, pressStop }: CountdownScreenProps) => ( | ||
const CountdownScreen = ({ duration, pressStop, toggle, finished }: CountdownScreenProps) => ( | ||
<> | ||
<KeepAwake /> | ||
<View style={{ alignItems: 'center', marginTop: 80 }}> | ||
<CountdownCircle | ||
bgColor="#001709" | ||
borderWidth={4} | ||
color="#0a2013" | ||
duration={Number(duration)} | ||
labelStyle={{ color: bodyTextColor, fontSize: 18, opacity: 0.2 }} | ||
minutes | ||
onTimeElapsed={() => console.log('Elapsed!')} | ||
radius={80} | ||
shadowColor="#001709" | ||
textStyle={{ color: bodyTextColor, fontSize: 40 }} | ||
/> | ||
{!finished ? ( | ||
<CountdownCircle | ||
bgColor="#001709" | ||
borderWidth={4} | ||
color="#0a2013" | ||
duration={Number(duration)} | ||
labelStyle={{ color: bodyTextColor, fontSize: 18, opacity: 0.2 }} | ||
minutes | ||
onTimeElapsed={toggle('finished')} | ||
radius={80} | ||
shadowColor="#001709" | ||
textStyle={{ color: bodyTextColor, fontSize: 40 }} | ||
/> | ||
) : ( | ||
<BeHappyText /> | ||
)} | ||
</View> | ||
<TouchableOpacity onPress={pressStop} style={s.stopBtn}> | ||
<Text style={s.stopText}>Stop</Text> | ||
<TouchableOpacity | ||
onPress={pressStop} | ||
style={{ | ||
alignItems: 'center', | ||
alignSelf: 'center', | ||
height: btnSize, | ||
justifyContent: 'center', | ||
marginBottom: 30, | ||
marginTop: 'auto', | ||
width: btnSize, | ||
}} | ||
> | ||
<Text | ||
style={{ | ||
color: bodyTextColor, | ||
fontSize: 18, | ||
opacity: 0.2, | ||
}} | ||
> | ||
Stop | ||
</Text> | ||
</TouchableOpacity> | ||
</> | ||
) | ||
|
||
const s = StyleSheet.create({ | ||
stopBtn: { | ||
alignItems: 'center', | ||
alignSelf: 'center', | ||
height: btnSize, | ||
justifyContent: 'center', | ||
marginBottom: 30, | ||
marginTop: 'auto', | ||
width: btnSize, | ||
}, | ||
stopText: { | ||
color: bodyTextColor, | ||
fontSize: 18, | ||
opacity: 0.2, | ||
}, | ||
text: { | ||
alignSelf: 'center', | ||
color: bodyTextColor, | ||
fontSize: 48, | ||
fontWeight: '400', | ||
marginTop: 40, | ||
}, | ||
}) | ||
|
||
export default CountdownScreen |
Oops, something went wrong.