Skip to content

Commit

Permalink
Show a + plus icon on next round if it's the last one
Browse files Browse the repository at this point in the history
  • Loading branch information
wyne committed Apr 18, 2024
1 parent 03e24a3 commit 543bf0d
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/components/Headers/GameHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,32 @@ const PrevRoundButton: React.FunctionComponent<PrevRoundButtonProps> = ({ prevRo
interface NextRoundButtonProps {
nextRoundHandler: () => void;
visible: boolean;
showPlus?: boolean;
}

const NextRoundButton: React.FunctionComponent<NextRoundButtonProps> = ({ nextRoundHandler, visible }) => {
const NextRoundButton: React.FunctionComponent<NextRoundButtonProps> = ({ nextRoundHandler, visible, showPlus = false }) => {
return (
<TouchableOpacity style={[styles.headerButton]}
onPress={nextRoundHandler}>
<Icon name="chevron-right"
type="font-awesome-5"
size={20}
color={systemBlue}
style={{ opacity: visible ? 0 : 1 }}
style={{ opacity: visible ? 0 : 1, overflow: 'visible' }}
/>
{showPlus &&
<Icon name="plus"
type="font-awesome-5"
size={7}
color={systemBlue}
containerStyle={{
position: 'absolute',
top: 9,
right: 9,
opacity: visible ? 0 : 1
}}
/>
}
</TouchableOpacity>
);
};
Expand Down Expand Up @@ -84,7 +98,12 @@ const GameHeader: React.FunctionComponent<Props> = ({ navigation }) => {
const nextRoundHandler = async () => {
if (isLastRound && currentGame.locked) return;

Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
if (isLastRound) {
// Stronger haptics if creating a new round
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
} else {
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
}

dispatch(roundNext(currentGame.id));
analytics().logEvent('round_change', {
Expand Down Expand Up @@ -116,7 +135,10 @@ const GameHeader: React.FunctionComponent<Props> = ({ navigation }) => {
headerCenter={<>
<PrevRoundButton prevRoundHandler={prevRoundHandler} visible={isFirstRound} />
<Text style={styles.title}>Round {roundCurrent + 1}</Text>
<NextRoundButton nextRoundHandler={nextRoundHandler} visible={isLastRound && (currentGame.locked || false)} />
<NextRoundButton nextRoundHandler={nextRoundHandler}
visible={isLastRound && (currentGame.locked || false)}
showPlus={isLastRound && !currentGame.locked}
/>
</>}
headerRight={!currentGame.locked && <AddendButton />}
/>
Expand Down

0 comments on commit 543bf0d

Please sign in to comment.