Skip to content

Commit

Permalink
feat: change user flow
Browse files Browse the repository at this point in the history
  • Loading branch information
caileanhtuan committed Apr 4, 2024
1 parent 14e8680 commit 8c445b2
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 41 deletions.
52 changes: 26 additions & 26 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,31 @@ export default function App() {
<Provider store={store}>
<PersistGate persistor={persistor} loading={null}>
<SafeAreaProvider>
<AuthGuard>
<NavigationContainerWithTracking>
<Stack.Navigator
// Consistent styling across all stacked screens
screenOptions={{
headerBackTitleVisible: false,
gestureEnabled: false,
headerTintColor: "black",
headerLeft: null,
headerStyle: {
backgroundColor: "white",
},
headerTitleStyle: {
fontWeight: "bold",
fontSize: 22,
color: "black",
},
headerTitleAlign: "center",
animation: "fade",
}}
>
{MergedStacks}
</Stack.Navigator>
</NavigationContainerWithTracking>
</AuthGuard>
{/* <AuthGuard> */}
<NavigationContainerWithTracking>
<Stack.Navigator
// Consistent styling across all stacked screens
screenOptions={{
headerBackTitleVisible: false,
gestureEnabled: false,
headerTintColor: "black",
headerLeft: null,
headerStyle: {
backgroundColor: "white",
},
headerTitleStyle: {
fontWeight: "bold",
fontSize: 22,
color: "black",
},
headerTitleAlign: "center",
animation: "fade",
}}
>
{MergedStacks}
</Stack.Navigator>
</NavigationContainerWithTracking>
{/* </AuthGuard> */}
</SafeAreaProvider>
</PersistGate>
</Provider>
Expand All @@ -75,5 +75,5 @@ axios.interceptors.request.use(
// Do something with request error
logAxiosError(error);
return Promise.reject(error);
},
}
);
2 changes: 2 additions & 0 deletions src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ export async function internalRequest<T>({
});

if (response.data.success === false) {
console.log("Error1:", response.data.message);
throw new Error(`Unable to connect to API: ${response.data.message}`);
}
return response.data.payload;
} catch (e) {
console.log("Error2:", e);
throw new Error(`Unable to connect to API: ${e}`);
}
}
9 changes: 8 additions & 1 deletion src/screens/Game/ExercisesCompleted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Text from "../../components/Text";
import useAsyncStorage from "../../hooks/useAsyncStorage";
import { RootStackParamList, SoundSetting, Settings } from "../../types";
import useSound from "../../hooks/useSound";
import { GameTypes } from "../../types";

const sound = require("../../assets/congrats.mp3") as AVPlaybackSource;

Expand Down Expand Up @@ -40,7 +41,7 @@ type Props = NativeStackScreenProps<RootStackParamList, "ExercisesCompleted">;
function ExercisesCompleted({ navigation }: Props) {
const { storageValue: settings } = useAsyncStorage<Settings>("SETTINGS");
const { unloadSound } = useSound(sound, SoundSetting.voiceOverOn);

const gameCompleted = "Math";
const correct = 1;
const total = 1;

Expand Down Expand Up @@ -73,6 +74,12 @@ function ExercisesCompleted({ navigation }: Props) {
navigation.navigate("ExtraPractice");
}}
/>
<Button
title="To Section Summary"
onPress={() => {
navigation.navigate("SectionSummary");
}}
/>
</View>
</View>
);
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Game/MathMain/MathMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ function MathMain({ route, navigation }: Props) {
remainingTimeRef.current.getRemainingTime();
}, waitSeconds * 1000);
},
[getNewProblem, remainingTimeRef],
[getNewProblem, remainingTimeRef]
);

const onPressChoice = (choiceValue: number) => {
const isCorrect = choiceValue === problem.solution;
updateStatsOnAnswer(
isCorrect,
prevProblemRemainingTimeRef.current -
remainingTimeRef.current.getRemainingTime(),
remainingTimeRef.current.getRemainingTime()
);
if (isCorrect) {
Toast.show({
Expand Down
21 changes: 21 additions & 0 deletions src/screens/Game/SectionSummary/SectionSummary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { View } from "react-native";
import Text from "../../../components/Text";
import Button from "../../../components/Button";
import { NativeStackScreenProps } from "@react-navigation/native-stack";
import { RootStackParamList, GameTypes } from "../../../types";

type Props = NativeStackScreenProps<RootStackParamList, "ExercisesCompleted">;

export default function SectionSummary({ navigation, route }: Props) {
return (
<View>
<Text>Section Summary</Text>
<Button
title="Return to Home"
onPress={() => {
navigation.navigate("HomeScreen");
}}
/>
</View>
);
}
14 changes: 7 additions & 7 deletions src/screens/Stacks/gameDescriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const triviaImage = require("../../assets/Trivia_Icon.png") as AVPlaybackSource;
const gameDescriptions: GameDescriptions = {
Math: {
title: "Math",
minutes: 5,
minutes: 0.1,
intro: {
name: "MathIntro",
sound: mathSound,
Expand All @@ -27,12 +27,12 @@ const gameDescriptions: GameDescriptions = {
},
game: {
name: "MathMain",
nextScreenArgs: ["ReadingIntro"],
nextScreenArgs: ["ExercisesCompleted"],
},
},
Reading: {
title: "Reading",
minutes: 5,
minutes: 0.1,
intro: {
name: "ReadingIntro",
sound: readingSound,
Expand All @@ -43,12 +43,12 @@ const gameDescriptions: GameDescriptions = {
},
game: {
name: "ReadingMain",
nextScreenArgs: ["WritingIntro"],
nextScreenArgs: ["ExercisesCompleted"],
},
},
Writing: {
title: "Writing",
minutes: 5,
minutes: 0.1,
intro: {
name: "WritingIntro",
sound: writingSound,
Expand All @@ -59,12 +59,12 @@ const gameDescriptions: GameDescriptions = {
},
game: {
name: "WritingMain",
nextScreenArgs: ["TriviaIntro"],
nextScreenArgs: ["ExercisesCompleted"],
},
},
Trivia: {
title: "Writing (Trivia)",
minutes: 5,
minutes: 0.1,
intro: {
name: "TriviaIntro",
sound: triviaSound,
Expand Down
10 changes: 6 additions & 4 deletions src/screens/Stacks/generalDescriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import GameOverview from "../Game/GameOverview";
import ExtraPractice from "../Game/ExtraPractice";
import ExercisesCompleted from "../Game/ExercisesCompleted";
import Pause from "../Game/Pause";
import SectionSummary from "../Game/SectionSummary/SectionSummary"
import HomeScreen from "../Home/HomeScreen";

const generalDescriptions: ScreenDescription[] = [
Expand Down Expand Up @@ -30,10 +31,11 @@ const generalDescriptions: ScreenDescription[] = [
title: "Exercises done!",
},
{
name: "ExtraPractice",
component: ExtraPractice,
title: "More Exercises",
},
name: "SectionSummary",
component: SectionSummary,
title: "Section Summary",
}

];

export default generalDescriptions;
6 changes: 5 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ export type RootStackParamList = {
TriviaIntro: { nextScreenArgs: NavigationArgs } | undefined;
TriviaMain: { nextScreenArgs: NavigationArgs } | undefined;
Pause: undefined;
ExercisesCompleted: undefined;
ExercisesCompleted: {nextScreenArgs: NavigationArgs} | undefined;
SectionSummary:{nextScreenArgs: NavigationArgs} | undefined;
// SectionSummary: {gameCompleted: string};
// SectionSummary:{gameCompleted: GameTypes} | undefined;

ExtraPractice: undefined;
SettingsScreen: undefined;
TimePicker: undefined;
Expand Down

0 comments on commit 8c445b2

Please sign in to comment.