From c3ab206d0170c00e4776d0322f6b92e79d01906f Mon Sep 17 00:00:00 2001 From: Wenny Yustalim Date: Sat, 11 Jan 2025 15:01:22 -0800 Subject: [PATCH 1/6] Add back button for easier navigation on Android. --- app/home.tsx | 2 +- lib/collection/ui/Game.tsx | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/home.tsx b/app/home.tsx index 96b2b50..a61043b 100644 --- a/app/home.tsx +++ b/app/home.tsx @@ -72,7 +72,7 @@ export default function Home() { useEffect(() => { if (!reportState.meta) return; - router.replace("/game"); + router.push("/game"); }, [reportState.meta]); return ( diff --git a/lib/collection/ui/Game.tsx b/lib/collection/ui/Game.tsx index b8c099f..d946266 100644 --- a/lib/collection/ui/Game.tsx +++ b/lib/collection/ui/Game.tsx @@ -11,14 +11,15 @@ import { ExitWingAction } from "./actions/ExitWingAction"; import * as Haptics from "expo-haptics"; import { AutoCollectPieceActions } from "./actions/AutoCollectPieceActions"; import { Alert } from "react-native"; -// import { colors } from "../../colors"; -// import { Icon } from "../../components/Icon"; // import { AllianceColor } from "../../models/AllianceColor"; // import { GameAction } from "./GameAction"; // import { // FieldOrientation, // useFieldOrientationStore, // } from "../../storage/userStores"; +import { View, TouchableOpacity } from "react-native"; +import { Icon } from "../../components/Icon"; +import { colors } from "../../colors"; export function Game() { const reportState = useReportStateStore(); @@ -97,11 +98,25 @@ export function Game() { gamePhaseMessage: "Pre-Match", field: , topLeftReplacement: ( - + + {router.canGoBack() && ( + router.back()} + style={{ padding: 8 }} + > + + + )} + + ), startEnabled: reportState.startPosition !== undefined, }, From bf1b4e57e8aa2c582d7e9585572604cc5b25893e Mon Sep 17 00:00:00 2001 From: MangoSwirl Date: Sat, 11 Jan 2025 15:31:10 -0800 Subject: [PATCH 2/6] Reset match state when home is focused (fixes start match button not working after you go back) --- app/home.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/home.tsx b/app/home.tsx index a61043b..008cc78 100644 --- a/app/home.tsx +++ b/app/home.tsx @@ -65,6 +65,7 @@ export default function Home() { useFocusEffect( useCallback(() => { + reportState.reset(); loadServices(); }, []), ); @@ -173,7 +174,7 @@ const MatchSelection = ({ const scouterScheduleForTournament = (scouterSchedule?.data.length ?? 0) > 0 && - scouterSchedule?.data[0].matchIdentity.tournamentKey === tournament?.key + scouterSchedule?.data[0].matchIdentity.tournamentKey === tournament?.key ? scouterSchedule : null; switch (matchSelectionMode) { @@ -206,7 +207,7 @@ const AutomaticMatchSelection = ({ const selectedTournament = useTournamentStore((state) => state.value); const scouterScheduleForTournament = (scouterSchedule?.data.length ?? 0) > 0 && - scouterSchedule?.data[0].matchIdentity.tournamentKey === + scouterSchedule?.data[0].matchIdentity.tournamentKey === selectedTournament?.key ? scouterSchedule : null; @@ -231,11 +232,11 @@ const AutomaticMatchSelection = ({ history.some( (report) => report.meta.matchIdentity.matchNumber === - match.matchIdentity.matchNumber && + match.matchIdentity.matchNumber && report.meta.matchIdentity.matchType === - match.matchIdentity.matchType && + match.matchIdentity.matchType && report.meta.matchIdentity.tournamentKey === - match.matchIdentity.tournamentKey, + match.matchIdentity.tournamentKey, ), ); matchesWithHistory.sort((a, b) => { @@ -501,7 +502,7 @@ const ScheduleColorGradient = () => { const scouterScheduleForTournament = (scouterSchedule?.data.length ?? 0) > 0 && - scouterSchedule?.data[0].matchIdentity.tournamentKey === tournament?.key + scouterSchedule?.data[0].matchIdentity.tournamentKey === tournament?.key ? scouterSchedule : null; From 9a5b8d94af563095c9f80af61dfd80cd611ebd8c Mon Sep 17 00:00:00 2001 From: MangoSwirl Date: Sat, 11 Jan 2025 15:43:49 -0800 Subject: [PATCH 3/6] Disable back gesture in game screens --- app/game/index.tsx | 1 + app/game/post-match.tsx | 1 + app/game/submit.tsx | 14 +++++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/game/index.tsx b/app/game/index.tsx index 6853850..4e53015 100644 --- a/app/game/index.tsx +++ b/app/game/index.tsx @@ -31,6 +31,7 @@ export default function GamePage() { animationDuration: 0, animationTypeForReplace: "push", animation: "flip", + gestureEnabled: false, }} /> }> diff --git a/app/game/post-match.tsx b/app/game/post-match.tsx index d61ceee..e561812 100644 --- a/app/game/post-match.tsx +++ b/app/game/post-match.tsx @@ -53,6 +53,7 @@ export default function PostMatch() { animationDuration: 0, animationTypeForReplace: "push", animation: "flip", + gestureEnabled: false, }} /> diff --git a/app/game/submit.tsx b/app/game/submit.tsx index 8ed37aa..d423f7b 100644 --- a/app/game/submit.tsx +++ b/app/game/submit.tsx @@ -11,7 +11,7 @@ import { } from "../../lib/models/match"; import { Suspense, useEffect, useState } from "react"; import { ScoutReport } from "../../lib/collection/ScoutReport"; -import { router } from "expo-router"; +import { router, Stack } from "expo-router"; import { uploadReport } from "../../lib/lovatAPI/uploadReport"; import { Icon } from "../../lib/components/Icon"; import { useHistoryStore } from "../../lib/storage/historyStore"; @@ -72,6 +72,14 @@ export default function Submit() { return ( <> + @@ -240,8 +248,8 @@ const UploadIndicator = ({ state }: { state: UploadState }) => { ))} {(effectiveState === UploadState.Uploaded || effectiveState == UploadState.AlreadyUploaded) && ( - - )} + + )} {effectiveState === UploadState.Error && ( )} From ef37ccbe0244d1f8f2ac4935965d16b32dc977cc Mon Sep 17 00:00:00 2001 From: MangoSwirl Date: Sat, 11 Jan 2025 15:45:55 -0800 Subject: [PATCH 4/6] Format code --- app/game/submit.tsx | 4 ++-- app/home.tsx | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/game/submit.tsx b/app/game/submit.tsx index d423f7b..3b64239 100644 --- a/app/game/submit.tsx +++ b/app/game/submit.tsx @@ -248,8 +248,8 @@ const UploadIndicator = ({ state }: { state: UploadState }) => { ))} {(effectiveState === UploadState.Uploaded || effectiveState == UploadState.AlreadyUploaded) && ( - - )} + + )} {effectiveState === UploadState.Error && ( )} diff --git a/app/home.tsx b/app/home.tsx index 008cc78..dca8f60 100644 --- a/app/home.tsx +++ b/app/home.tsx @@ -174,7 +174,7 @@ const MatchSelection = ({ const scouterScheduleForTournament = (scouterSchedule?.data.length ?? 0) > 0 && - scouterSchedule?.data[0].matchIdentity.tournamentKey === tournament?.key + scouterSchedule?.data[0].matchIdentity.tournamentKey === tournament?.key ? scouterSchedule : null; switch (matchSelectionMode) { @@ -207,7 +207,7 @@ const AutomaticMatchSelection = ({ const selectedTournament = useTournamentStore((state) => state.value); const scouterScheduleForTournament = (scouterSchedule?.data.length ?? 0) > 0 && - scouterSchedule?.data[0].matchIdentity.tournamentKey === + scouterSchedule?.data[0].matchIdentity.tournamentKey === selectedTournament?.key ? scouterSchedule : null; @@ -232,11 +232,11 @@ const AutomaticMatchSelection = ({ history.some( (report) => report.meta.matchIdentity.matchNumber === - match.matchIdentity.matchNumber && + match.matchIdentity.matchNumber && report.meta.matchIdentity.matchType === - match.matchIdentity.matchType && + match.matchIdentity.matchType && report.meta.matchIdentity.tournamentKey === - match.matchIdentity.tournamentKey, + match.matchIdentity.tournamentKey, ), ); matchesWithHistory.sort((a, b) => { @@ -502,7 +502,7 @@ const ScheduleColorGradient = () => { const scouterScheduleForTournament = (scouterSchedule?.data.length ?? 0) > 0 && - scouterSchedule?.data[0].matchIdentity.tournamentKey === tournament?.key + scouterSchedule?.data[0].matchIdentity.tournamentKey === tournament?.key ? scouterSchedule : null; From 4dc9982cc3ee03fdd62dce8ca047ac33788fdb31 Mon Sep 17 00:00:00 2001 From: Clouch1234 <143346546+Clouch1234@users.noreply.github.com> Date: Mon, 13 Jan 2025 20:49:42 +0000 Subject: [PATCH 5/6] change back button implementation to reset repostate on press --- app/home.tsx | 1 - lib/collection/ui/Game.tsx | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/home.tsx b/app/home.tsx index dca8f60..a61043b 100644 --- a/app/home.tsx +++ b/app/home.tsx @@ -65,7 +65,6 @@ export default function Home() { useFocusEffect( useCallback(() => { - reportState.reset(); loadServices(); }, []), ); diff --git a/lib/collection/ui/Game.tsx b/lib/collection/ui/Game.tsx index 96889f9..2f948d7 100644 --- a/lib/collection/ui/Game.tsx +++ b/lib/collection/ui/Game.tsx @@ -104,7 +104,10 @@ export function Game() { {router.canGoBack() && ( router.back()} + onPress={() => { + reportState.reset(); + router.back() + }} style={{ padding: 8 }} > Date: Mon, 13 Jan 2025 20:51:24 +0000 Subject: [PATCH 6/6] fix formatting --- lib/collection/ui/Game.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/collection/ui/Game.tsx b/lib/collection/ui/Game.tsx index 2f948d7..4384deb 100644 --- a/lib/collection/ui/Game.tsx +++ b/lib/collection/ui/Game.tsx @@ -106,7 +106,7 @@ export function Game() { { reportState.reset(); - router.back() + router.back(); }} style={{ padding: 8 }} >