Browse Source

stop game after completed

pull/8/head
Tim Glasgow 2 years ago
parent
commit
0ed28e7c09
  1. 21
      squarenotsquare/src/screens/Game.js
  2. 2
      squarenotsquare/src/screens/styles/AppStyles.js
  3. 3
      squarenotsquare/src/themes/Icons.js

21
squarenotsquare/src/screens/Game.js

@ -79,9 +79,18 @@ function Game(props){
scrollDestination.current = newDestination; scrollDestination.current = newDestination;
challengeState.current = challengeState.current + 1; challengeState.current = challengeState.current + 1;
setScrollOrigin(newOrigin); setScrollOrigin(newOrigin);
if (challengeState.current >= 20) {
completeChallenge();
}
} }
} }
function completeChallenge(){
clearInterval(localTimer.current);
setTimerState(4);
}
function generateSquare(pairIndex){ function generateSquare(pairIndex){
return ( return (
<TouchableOpacity <TouchableOpacity
@ -153,8 +162,18 @@ function Game(props){
destination={scrollDestination.current} destination={scrollDestination.current}
duration={250} duration={250}
> >
<View style={[styles.gameStart]} /> <View style={[styles.gameView]} />
{squareMemo} {squareMemo}
<View style={[styles.gameView, styles.flexRow, styles.spaceEvenly, styles.centeredItems]}>
<MaterialIcon
name={Icons.squareIcons.check}
color={Colors.material.green800}
size={Metrics.icons.buttonIcon}
/>
<Text style={[styles.headerTitleFont, styles.greyText]}>
Finish
</Text>
</View>
</Autoscroll> </Autoscroll>
</View> </View>
</SafeAreaView> </SafeAreaView>

2
squarenotsquare/src/screens/styles/AppStyles.js

@ -80,7 +80,7 @@ export const styles = StyleSheet.create({
}, },
smallMargin: {margin: Metrics.margins.default}, smallMargin: {margin: Metrics.margins.default},
gameStart: {margin: Metrics.margins.gameStartMargin}, gameView: {margin: Metrics.margins.gameStartMargin},
buttonMargin: { buttonMargin: {
marginBottom: Metrics.margins.buttonMargin, marginBottom: Metrics.margins.buttonMargin,
marginTop: Metrics.margins.buttonMargin marginTop: Metrics.margins.buttonMargin

3
squarenotsquare/src/themes/Icons.js

@ -3,7 +3,8 @@ class AppIcons {
square: 'square', square: 'square',
settings: 'cog-outline', settings: 'cog-outline',
toggleOn: 'toggle-switch-on', toggleOn: 'toggle-switch-on',
toggleOfff: 'toggle-switch-off', toggleOff: 'toggle-switch-off',
check: 'check'
}; };
wrongShapes = { wrongShapes = {

Loading…
Cancel
Save