refactored app theme

changed texts to suit dark theme.
This commit is contained in:
suddenlyoranges committed 2026-04-09 21:39:42 +01:00
1 parent 07b12cdd0f
commit 12847cc46c
5 files changed
+116 -56

No files matched your search

@@ -67,7 +67,8 @@ const GlobalCacheViewScreen = ({ navigation, route }) => {
{!initIsFound ? ( {!initIsFound ? (
<Text style={styles.claimHint}> <Text style={styles.claimHint}>
Claim this cache from the Global Map while within 30m and facing it. Claim this cache from the Global Map while within 30m and facing
it.
</Text> </Text>
) : null} ) : null}
</Card> </Card>
@@ -91,7 +92,7 @@ const styles = StyleSheet.create({
title: { title: {
fontSize: 22, fontSize: 22,
fontWeight: "700", fontWeight: "700",
color: "#111827", color: "#cdd6f4",
}, },
statusBadge: { statusBadge: {
alignSelf: "flex-start", alignSelf: "flex-start",
@@ -100,15 +101,15 @@ const styles = StyleSheet.create({
borderRadius: 12, borderRadius: 12,
}, },
badgeFound: { badgeFound: {
backgroundColor: "#d1fae5", backgroundColor: "#1e3a2f",
}, },
badgeOpen: { badgeOpen: {
backgroundColor: "#fef3c7", backgroundColor: "#3d3117",
}, },
statusText: { statusText: {
fontSize: 13, fontSize: 13,
fontWeight: "600", fontWeight: "600",
color: "#374151", color: "#cdd6f4",
}, },
detailRow: { detailRow: {
gap: 2, gap: 2,
@@ -116,17 +117,17 @@ const styles = StyleSheet.create({
label: { label: {
fontSize: 12, fontSize: 12,
fontWeight: "600", fontWeight: "600",
color: "#6b7280", color: "#a6adc8",
textTransform: "uppercase", textTransform: "uppercase",
letterSpacing: 0.5, letterSpacing: 0.5,
}, },
value: { value: {
fontSize: 15, fontSize: 15,
color: "#111827", color: "#cdd6f4",
}, },
claimHint: { claimHint: {
marginTop: 6, marginTop: 6,
color: "#2563eb", color: "#89b4fa",
fontSize: 13, fontSize: 13,
fontWeight: "600", fontWeight: "600",
}, },
@@ -10,12 +10,8 @@ import {GAME_MODE} from "../../../utils/gameConstants";
const GlobalEventsScreen = ({ navigation }) => { const GlobalEventsScreen = ({ navigation }) => {
// Initialisations --------------------- // Initialisations ---------------------
const { const { getPublicEvents, getPlayersByEvent, joinEvent, isGlobalApiReady } =
getPublicEvents, useGlobalHook();
getPlayersByEvent,
joinEvent,
isGlobalApiReady,
} = useGlobalHook();
const session = getSession(); const session = getSession();
const globalApiRef = useRef({ const globalApiRef = useRef({
getPublicEvents, getPublicEvents,
@@ -45,7 +41,9 @@ const GlobalEventsScreen = ({ navigation }) => {
if (!globalApiRef.current.isGlobalApiReady()) { if (!globalApiRef.current.isGlobalApiReady()) {
setEvents([]); setEvents([]);
setError("Global API URL is not configured yet. Add it in src/components/API/api.json."); setError(
"Global API URL is not configured yet. Add it in src/components/API/api.json.",
);
setIsLoading(false); setIsLoading(false);
return; return;
} }
@@ -68,7 +66,9 @@ const GlobalEventsScreen = ({ navigation }) => {
setJoining(event.EventID); setJoining(event.EventID);
if (!globalApiRef.current.isGlobalApiReady()) { if (!globalApiRef.current.isGlobalApiReady()) {
setError("Global API URL is not configured yet. Add it in src/components/API/api.json."); setError(
"Global API URL is not configured yet. Add it in src/components/API/api.json.",
);
setJoining(null); setJoining(null);
return; return;
} }
@@ -82,7 +82,10 @@ const GlobalEventsScreen = ({ navigation }) => {
}; };
// Check if already a player // Check if already a player
const players = await globalApiRef.current.getPlayersByEvent(event.EventID, {forceRefresh: true}); const players = await globalApiRef.current.getPlayersByEvent(
event.EventID,
{ forceRefresh: true },
);
const existing = (players || []).find( const existing = (players || []).find(
(p) => String(p.PlayerUserID) === String(globalUserId), (p) => String(p.PlayerUserID) === String(globalUserId),
); );
@@ -110,7 +113,10 @@ const GlobalEventsScreen = ({ navigation }) => {
} }
// If create fails due duplicate race/server behavior, recover by re-reading players. // If create fails due duplicate race/server behavior, recover by re-reading players.
const refreshedPlayers = await globalApiRef.current.getPlayersByEvent(event.EventID, {forceRefresh: true}); const refreshedPlayers = await globalApiRef.current.getPlayersByEvent(
event.EventID,
{ forceRefresh: true },
);
const recovered = (refreshedPlayers || []).find( const recovered = (refreshedPlayers || []).find(
(p) => String(p.PlayerUserID) === String(globalUserId), (p) => String(p.PlayerUserID) === String(globalUserId),
); );
@@ -131,7 +137,10 @@ const GlobalEventsScreen = ({ navigation }) => {
<Screen> <Screen>
<View style={styles.container}> <View style={styles.container}>
<ButtonTray> <ButtonTray>
<Button label="Refresh" onClick={() => loadEvents({forceRefresh: true})} /> <Button
label="Refresh"
onClick={() => loadEvents({ forceRefresh: true })}
/>
</ButtonTray> </ButtonTray>
{error ? <Text style={styles.error}>{error}</Text> : null} {error ? <Text style={styles.error}>{error}</Text> : null}
@@ -174,21 +183,21 @@ const styles = StyleSheet.create({
gap: 10, gap: 10,
}, },
loadingText: { loadingText: {
color: "#6b7280", color: "#a6adc8",
fontSize: 14, fontSize: 14,
}, },
empty: { empty: {
textAlign: "center", textAlign: "center",
color: "#9ca3af", color: "#a6adc8",
marginTop: 30, marginTop: 30,
fontSize: 15, fontSize: 15,
}, },
hint: { hint: {
fontSize: 13, fontSize: 13,
color: "#6b7280", color: "#a6adc8",
}, },
error: { error: {
color: "#dc2626", color: "#f38ba8",
fontSize: 14, fontSize: 14,
}, },
overlay: { overlay: {
@@ -1,5 +1,11 @@
import { useCallback, useEffect, useRef, useState } from "react"; import { useCallback, useEffect, useRef, useState } from "react";
import {ActivityIndicator, ScrollView, StyleSheet, Text, View,} from "react-native"; import {
ActivityIndicator,
ScrollView,
StyleSheet,
Text,
View,
} from "react-native";
import Screen from "../../layout/Screen"; import Screen from "../../layout/Screen";
import { Button, ButtonTray } from "../../UI/Button"; import { Button, ButtonTray } from "../../UI/Button";
import Card from "../../UI/Card"; import Card from "../../UI/Card";
@@ -35,7 +41,8 @@ const GlobalLeaderboardScreen = ({ navigation, route }) => {
// Handlers ---------------------------- // Handlers ----------------------------
const loadData = useCallback(async (options = {}) => { const loadData = useCallback(
async (options = {}) => {
if (!eventId) return; if (!eventId) return;
setIsLoading(true); setIsLoading(true);
@@ -103,7 +110,9 @@ const GlobalLeaderboardScreen = ({ navigation, route }) => {
setRankings(ranked); setRankings(ranked);
setIsLoading(false); setIsLoading(false);
}, [eventId]); },
[eventId],
);
useEffect(() => { useEffect(() => {
if (session.isBusiness || session.currentGameMode !== GAME_MODE.GLOBAL) { if (session.isBusiness || session.currentGameMode !== GAME_MODE.GLOBAL) {
@@ -126,12 +135,21 @@ const GlobalLeaderboardScreen = ({ navigation, route }) => {
]); ]);
useEffect(() => { useEffect(() => {
if (!eventId || session.currentGameMode !== GAME_MODE.GLOBAL || !session.currentGlobalPlayerId) { if (
!eventId ||
session.currentGameMode !== GAME_MODE.GLOBAL ||
!session.currentGlobalPlayerId
) {
return; return;
} }
loadData(); loadData();
}, [eventId, loadData, session.currentGameMode, session.currentGlobalPlayerId]); }, [
eventId,
loadData,
session.currentGameMode,
session.currentGlobalPlayerId,
]);
// View -------------------------------- // View --------------------------------
@@ -199,7 +217,10 @@ const GlobalLeaderboardScreen = ({ navigation, route }) => {
)} )}
<ButtonTray> <ButtonTray>
<Button label="Refresh" onClick={() => loadData({forceRefresh: true})} /> <Button
label="Refresh"
onClick={() => loadData({ forceRefresh: true })}
/>
</ButtonTray> </ButtonTray>
</View> </View>
</Screen> </Screen>
@@ -222,13 +243,13 @@ const tabStyles = StyleSheet.create({
paddingVertical: 8, paddingVertical: 8,
fontSize: 14, fontSize: 14,
fontWeight: "600", fontWeight: "600",
color: "#6b7280", color: "#a6adc8",
borderBottomWidth: 2, borderBottomWidth: 2,
borderBottomColor: "transparent", borderBottomColor: "transparent",
}, },
activeTab: { activeTab: {
color: "#111827", color: "#cdd6f4",
borderBottomColor: "#111827", borderBottomColor: "#89b4fa",
}, },
}); });
@@ -244,7 +265,7 @@ const styles = StyleSheet.create({
tabs: { tabs: {
flexDirection: "row", flexDirection: "row",
borderBottomWidth: 1, borderBottomWidth: 1,
borderBottomColor: "#e5e7eb", borderBottomColor: "#45475a",
}, },
rankList: { rankList: {
gap: 6, gap: 6,
@@ -254,7 +275,7 @@ const styles = StyleSheet.create({
marginBottom: 0, marginBottom: 0,
}, },
myCard: { myCard: {
borderColor: "#2563eb", borderColor: "#89b4fa",
borderWidth: 2, borderWidth: 2,
}, },
rankRow: { rankRow: {
@@ -265,14 +286,14 @@ const styles = StyleSheet.create({
rankPos: { rankPos: {
fontSize: 16, fontSize: 16,
fontWeight: "700", fontWeight: "700",
color: "#6b7280", color: "#a6adc8",
width: 32, width: 32,
}, },
rankName: { rankName: {
flex: 1, flex: 1,
fontSize: 15, fontSize: 15,
fontWeight: "600", fontWeight: "600",
color: "#111827", color: "#cdd6f4",
}, },
rankRight: { rankRight: {
alignItems: "flex-end", alignItems: "flex-end",
@@ -280,15 +301,15 @@ const styles = StyleSheet.create({
rankPoints: { rankPoints: {
fontSize: 16, fontSize: 16,
fontWeight: "700", fontWeight: "700",
color: "#16a34a", color: "#a6e3a1",
}, },
rankFinds: { rankFinds: {
fontSize: 12, fontSize: 12,
color: "#9ca3af", color: "#a6adc8",
}, },
empty: { empty: {
textAlign: "center", textAlign: "center",
color: "#9ca3af", color: "#a6adc8",
marginTop: 30, marginTop: 30,
fontSize: 15, fontSize: 15,
}, },
@@ -77,7 +77,8 @@ const GlobalMapScreen = ({ navigation, route }) => {
// Handlers ---------------------------- // Handlers ----------------------------
const loadData = useCallback(async (options = {}) => { const loadData = useCallback(
async (options = {}) => {
if (!eventId) return; if (!eventId) return;
setIsLoading(true); setIsLoading(true);
@@ -86,14 +87,19 @@ const GlobalMapScreen = ({ navigation, route }) => {
const [cacheData, findsData] = await Promise.all([ const [cacheData, findsData] = await Promise.all([
globalApiRef.current.getCachesByEvent(eventId, options), globalApiRef.current.getCachesByEvent(eventId, options),
session.currentGlobalPlayerId session.currentGlobalPlayerId
? globalApiRef.current.getFindsByPlayer(session.currentGlobalPlayerId, options) ? globalApiRef.current.getFindsByPlayer(
session.currentGlobalPlayerId,
options,
)
: Promise.resolve([]), : Promise.resolve([]),
]); ]);
setCaches(cacheData || []); setCaches(cacheData || []);
setFoundCacheIds((findsData || []).map((f) => f.FindCacheID)); setFoundCacheIds((findsData || []).map((f) => f.FindCacheID));
setIsLoading(false); setIsLoading(false);
}, [eventId, session.currentGlobalPlayerId]); },
[eventId, session.currentGlobalPlayerId],
);
const handleClaim = useCallback( const handleClaim = useCallback(
async (cacheId) => { async (cacheId) => {
@@ -131,7 +137,9 @@ const GlobalMapScreen = ({ navigation, route }) => {
}; };
const handleOpenSelectedCache = () => { const handleOpenSelectedCache = () => {
const selected = (caches || []).find((cache) => cache.CacheID === selectedCacheId); const selected = (caches || []).find(
(cache) => cache.CacheID === selectedCacheId,
);
if (!selected) return; if (!selected) return;
navigation.navigate("GlobalCacheViewScreen", { navigation.navigate("GlobalCacheViewScreen", {
cache: selected, cache: selected,
@@ -166,12 +174,21 @@ const GlobalMapScreen = ({ navigation, route }) => {
]); ]);
useEffect(() => { useEffect(() => {
if (!eventId || session.currentGameMode !== GAME_MODE.GLOBAL || !session.currentGlobalPlayerId) { if (
!eventId ||
session.currentGameMode !== GAME_MODE.GLOBAL ||
!session.currentGlobalPlayerId
) {
return; return;
} }
loadData(); loadData();
}, [eventId, loadData, session.currentGameMode, session.currentGlobalPlayerId]); }, [
eventId,
loadData,
session.currentGameMode,
session.currentGlobalPlayerId,
]);
useEffect(() => { useEffect(() => {
const routeSelected = route?.params?.selectedCacheId; const routeSelected = route?.params?.selectedCacheId;
@@ -180,7 +197,10 @@ const GlobalMapScreen = ({ navigation, route }) => {
}, [route?.params?.selectedCacheId]); }, [route?.params?.selectedCacheId]);
useEffect(() => { useEffect(() => {
if (selectedCacheId && claimableCaches.some((cache) => cache.id === selectedCacheId)) { if (
selectedCacheId &&
claimableCaches.some((cache) => cache.id === selectedCacheId)
) {
return; return;
} }
setSelectedCacheId(claimableCaches[0]?.id || null); setSelectedCacheId(claimableCaches[0]?.id || null);
@@ -291,7 +311,9 @@ const GlobalMapScreen = ({ navigation, route }) => {
}} }}
title={cache.CacheName} title={cache.CacheName}
description={`${cache.CachePoints ?? 0} pts${found ? " · Found" : ""}`} description={`${cache.CachePoints ?? 0} pts${found ? " · Found" : ""}`}
pinColor={found ? "#22c55e" : selected ? "#f59e0b" : "#ef4444"} pinColor={
found ? "#22c55e" : selected ? "#f59e0b" : "#ef4444"
}
onPress={() => setSelectedCacheId(cache.CacheID)} onPress={() => setSelectedCacheId(cache.CacheID)}
onCalloutPress={() => onCalloutPress={() =>
navigation.navigate("GlobalCacheViewScreen", { navigation.navigate("GlobalCacheViewScreen", {
@@ -337,9 +359,16 @@ const GlobalMapScreen = ({ navigation, route }) => {
/> />
<ButtonTray> <ButtonTray>
<Button label="Details" onClick={handleOpenSelectedCache} disabled={!selectedCacheId} /> <Button
label="Details"
onClick={handleOpenSelectedCache}
disabled={!selectedCacheId}
/>
<Button label="Leaderboard" onClick={handleGotoLeaderboard} /> <Button label="Leaderboard" onClick={handleGotoLeaderboard} />
<Button label="Refresh" onClick={() => loadData({forceRefresh: true})} /> <Button
label="Refresh"
onClick={() => loadData({ forceRefresh: true })}
/>
</ButtonTray> </ButtonTray>
</View> </View>
</Screen> </Screen>
@@ -362,13 +391,13 @@ const tabStyles = StyleSheet.create({
paddingVertical: 8, paddingVertical: 8,
fontSize: 14, fontSize: 14,
fontWeight: "600", fontWeight: "600",
color: "#6b7280", color: "#a6adc8",
borderBottomWidth: 2, borderBottomWidth: 2,
borderBottomColor: "transparent", borderBottomColor: "transparent",
}, },
activeTab: { activeTab: {
color: "#111827", color: "#cdd6f4",
borderBottomColor: "#111827", borderBottomColor: "#89b4fa",
}, },
}); });
@@ -384,13 +413,13 @@ const styles = StyleSheet.create({
tabs: { tabs: {
flexDirection: "row", flexDirection: "row",
borderBottomWidth: 1, borderBottomWidth: 1,
borderBottomColor: "#e5e7eb", borderBottomColor: "#45475a",
}, },
map: { map: {
flex: 1, flex: 1,
}, },
error: { error: {
color: "#dc2626", color: "#f38ba8",
fontSize: 14, fontSize: 14,
}, },
}); });
@@ -242,7 +242,7 @@ const styles = StyleSheet.create({
justifyContent: "center", justifyContent: "center",
}, },
error: { error: {
color: "#dc2626", color: "#f38ba8",
fontSize: 14, fontSize: 14,
}, },
avatarWrap: { avatarWrap: {
@@ -257,7 +257,7 @@ const styles = StyleSheet.create({
}, },
label: { label: {
fontSize: 13, fontSize: 13,
color: "#9ca3af", color: "#a6adc8",
fontWeight: "600", fontWeight: "600",
}, },
input: { input: {