diff --git a/src/app/(screens)/grades.tsx b/src/app/(screens)/grades.tsx index eb8b45e6..2122ea12 100644 --- a/src/app/(screens)/grades.tsx +++ b/src/app/(screens)/grades.tsx @@ -18,7 +18,14 @@ import { useQuery } from '@tanstack/react-query' import { router } from 'expo-router' import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' -import { RefreshControl, ScrollView, Text, View } from 'react-native' +import { + AppState, + type AppStateStatus, + RefreshControl, + ScrollView, + Text, + View, +} from 'react-native' import { createStyleSheet, useStyles } from 'react-native-unistyles' import packageInfo from '../../../package.json' @@ -97,6 +104,23 @@ export default function GradesSCreen(): JSX.Element { void loadAverageGrade(spoName ?? undefined) }, [spoWeights, grades?.finished]) + useEffect(() => { + const handleAppStateChange = (nextAppState: AppStateStatus): void => { + if (nextAppState === 'inactive' || nextAppState === 'background') { + router.back() + } + } + + const subscription = AppState.addEventListener( + 'change', + handleAppStateChange + ) + + return () => { + subscription.remove() + } + }, []) + return ( { + const handleAppStateChange = (nextAppState: AppStateStatus): void => { + if (nextAppState === 'inactive' || nextAppState === 'background') { + setIsBackground(true) + } else { + setIsBackground(false) + } + } + + const subscription = AppState.addEventListener( + 'change', + handleAppStateChange + ) + + return () => { + subscription.remove() + } + }, []) const copyToClipboard = async (text: string): Promise => { if (text.length === 0) { @@ -246,7 +267,10 @@ export default function Profile(): JSX.Element { {isSuccess && (data?.mtknr !== undefined ? ( - + ) : ( = ({ const RenderSectionItems: React.FC<{ items: SectionGroup[] + privacyHidden: boolean rowStyle?: ViewStyle -}> = ({ items, rowStyle }) => { +}> = ({ items, privacyHidden, rowStyle }) => { const { styles, theme } = useStyles(stylesheet) return ( @@ -87,7 +89,7 @@ const RenderSectionItems: React.FC<{ )} - {item.value != null && ( + {item.value != null && !privacyHidden && ( = ({ sections, rowStyle }) => { +const FormList: React.FC = ({ + sections, + rowStyle, + privacyHidden, +}) => { const { styles } = useStyles(stylesheet) return ( @@ -165,6 +171,7 @@ const FormList: React.FC = ({ sections, rowStyle }) => { ) : section.item != null ? (