Correction masquage bandeau pourchasseuse
This commit is contained in:
parent
30a687018f
commit
9e5cdfb132
@ -7,7 +7,7 @@ import { Banner, MD3Colors, ProgressBar, Text } from "react-native-paper"
|
|||||||
export default function FreeChaseBanner() {
|
export default function FreeChaseBanner() {
|
||||||
const game = useGame()
|
const game = useGame()
|
||||||
const chaseFreeTime = game.chaseFreeTime
|
const chaseFreeTime = game.chaseFreeTime
|
||||||
const stunChase = game.gameStarted && !game.currentRunner && chaseFreeTime !== null
|
const chaser = !game.gameStarted && !game.currentRunner && chaseFreeTime !== null
|
||||||
const chaseFreeDate = useMemo(() => new Date(chaseFreeTime || 0), [chaseFreeTime])
|
const chaseFreeDate = useMemo(() => new Date(chaseFreeTime || 0), [chaseFreeTime])
|
||||||
const chaseFreePretty = chaseFreeDate.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' })
|
const chaseFreePretty = chaseFreeDate.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' })
|
||||||
const [remainingTime, setRemainingTime] = useState(0)
|
const [remainingTime, setRemainingTime] = useState(0)
|
||||||
@ -22,21 +22,22 @@ export default function FreeChaseBanner() {
|
|||||||
}, [remainingTime])
|
}, [remainingTime])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!stunChase)
|
const now = new Date().getTime()
|
||||||
|
if (!chaser || (chaseFreeTime < now && remainingTime < 0))
|
||||||
return
|
return
|
||||||
const interval = setInterval(() => setRemainingTime(Math.floor((chaseFreeDate.getTime() - new Date().getTime()) / 1000)), 1000)
|
const interval = setInterval(() => setRemainingTime(Math.floor(chaseFreeTime - now) / 1000), 1000)
|
||||||
return () => clearInterval(interval)
|
return () => clearInterval(interval)
|
||||||
}, [stunChase, chaseFreeDate])
|
}, [game.gameStarted, game.currentRunner, chaseFreeDate])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
visible={stunChase}
|
visible={chaser && remainingTime > 0}
|
||||||
animatedValue={1 - remainingTime / (45 * 60)}
|
animatedValue={1 - remainingTime / (45 * 60)}
|
||||||
color={'green'}
|
color={'green'}
|
||||||
style={{ height: 6 }} />
|
style={{ height: 6 }} />
|
||||||
<Banner
|
<Banner
|
||||||
visible={stunChase}
|
visible={chaser && remainingTime > 0}
|
||||||
icon={({ size }) => <FontAwesome6 name={iconName} size={size} color={MD3Colors.secondary90} />}
|
icon={({ size }) => <FontAwesome6 name={iconName} size={size} color={MD3Colors.secondary90} />}
|
||||||
style={{ backgroundColor: MD3Colors.secondary40 }}>
|
style={{ backgroundColor: MD3Colors.secondary40 }}>
|
||||||
<View>
|
<View>
|
||||||
|
@ -86,8 +86,9 @@ export default function GameProvider({ children }: { children: ReactNode }) {
|
|||||||
&& challengeAction.penaltyStart <= now && now <= challengeAction.penaltyEnd)
|
&& challengeAction.penaltyStart <= now && now <= challengeAction.penaltyEnd)
|
||||||
if (!activeChallenge || !game.currentRunner)
|
if (!activeChallenge || !game.currentRunner)
|
||||||
updatePenalty({ penaltyStart: null, penaltyEnd: null })
|
updatePenalty({ penaltyStart: null, penaltyEnd: null })
|
||||||
else if (activeChallenge && (activeChallenge.penaltyStart !== game.penaltyStart || activeChallenge.penaltyEnd))
|
else if (activeChallenge && (activeChallenge.penaltyStart !== game.penaltyStart || activeChallenge.penaltyEnd)) {
|
||||||
updatePenalty({ penaltyStart: activeChallenge.penaltyStart, penaltyEnd: activeChallenge.penaltyEnd })
|
updatePenalty({ penaltyStart: activeChallenge.penaltyStart, penaltyEnd: activeChallenge.penaltyEnd })
|
||||||
|
}
|
||||||
}, [game.currentRunner, challengeActions])
|
}, [game.currentRunner, challengeActions])
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
|
Loading…
Reference in New Issue
Block a user