2024-12-12 23:23:39 +00:00
|
|
|
import { StyleSheet } from 'react-native'
|
|
|
|
import "maplibre-gl/dist/maplibre-gl.css"
|
|
|
|
import { useBackgroundPermissions } from 'expo-location'
|
|
|
|
import Map from '@/components/Map'
|
|
|
|
import { FAB, Surface, Text } from 'react-native-paper'
|
|
|
|
import { useGame } from '@/hooks/useGame'
|
|
|
|
import { FontAwesome6 } from '@expo/vector-icons'
|
|
|
|
import FreeChaseBanner from '@/components/FreeChaseBanner'
|
2024-12-13 00:18:55 +00:00
|
|
|
import { View } from 'react-native'
|
2024-12-02 19:11:31 +00:00
|
|
|
|
2024-12-12 23:23:39 +00:00
|
|
|
export default function MapScreen() {
|
|
|
|
const [backgroundStatus, requestBackgroundPermission] = useBackgroundPermissions()
|
|
|
|
if (!backgroundStatus?.granted && backgroundStatus?.canAskAgain)
|
|
|
|
requestBackgroundPermission()
|
|
|
|
|
|
|
|
const game = useGame()
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Surface style={styles.page}>
|
2024-12-13 00:18:55 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
{backgroundStatus?.granted ? <Map /> : <Text>La géolocalisation est requise pour utiliser la carte.</Text>}
|
|
|
|
<FAB
|
|
|
|
style={styles.moneyBadge}
|
|
|
|
visible={game.gameStarted || game.money > 0}
|
|
|
|
icon={(props) => <FontAwesome6 {...props} name='coins' size={20} />}
|
|
|
|
color='black'
|
2024-12-14 11:36:50 +00:00
|
|
|
label={`${game.money}`}
|
|
|
|
onPress={() => {}} />
|
2024-12-13 00:18:55 +00:00
|
|
|
<FAB
|
|
|
|
style={styles.statusBadge}
|
|
|
|
visible={game.gameStarted || game.money > 0}
|
|
|
|
size='small'
|
|
|
|
color='black'
|
|
|
|
icon={game.currentRunner ? 'run-fast' : () => <FontAwesome6 name='cat' size={20} />}
|
2024-12-14 11:36:50 +00:00
|
|
|
label={game.currentRunner ? "Coureuse" : "Poursuiveuse"}
|
|
|
|
onPress={() => {}} />
|
2024-12-13 00:18:55 +00:00
|
|
|
</View>
|
2024-12-12 23:23:39 +00:00
|
|
|
<FreeChaseBanner />
|
|
|
|
</Surface>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
page: {
|
|
|
|
flex: 1,
|
|
|
|
},
|
2024-12-13 00:18:55 +00:00
|
|
|
container: {
|
|
|
|
flexGrow: 1,
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
},
|
2024-12-12 23:23:39 +00:00
|
|
|
map: {
|
|
|
|
flex: 1,
|
|
|
|
alignSelf: 'stretch',
|
|
|
|
},
|
|
|
|
moneyBadge: {
|
|
|
|
position: 'absolute',
|
|
|
|
top: 40,
|
|
|
|
right: 20,
|
|
|
|
backgroundColor: 'orange',
|
|
|
|
},
|
|
|
|
statusBadge: {
|
|
|
|
position: 'absolute',
|
|
|
|
top: 40,
|
|
|
|
left: 20,
|
|
|
|
backgroundColor: 'pink',
|
|
|
|
},
|
|
|
|
})
|