From 3844167a9e0570b981bde4f27610a481a9d4b8b8 Mon Sep 17 00:00:00 2001 From: Sverre <59171289+sverben@users.noreply.github.com> Date: Wed, 7 Aug 2024 23:39:29 +0200 Subject: [PATCH] chore: warn users for demo mode (#18) --- src/auth.tsx | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/auth.tsx b/src/auth.tsx index 4028f3e..9653ac6 100644 --- a/src/auth.tsx +++ b/src/auth.tsx @@ -3,7 +3,13 @@ import { jwtDecode } from "jwt-decode"; import * as SecureStore from "expo-secure-store"; import * as AuthSession from "expo-auth-session"; import { Alert, Platform, SafeAreaView, StyleSheet, View } from "react-native"; -import { Button, useTheme, Text, ActivityIndicator } from "react-native-paper"; +import { + Button, + useTheme, + Text, + ActivityIndicator, + Snackbar, +} from "react-native-paper"; import * as WebBrowser from "expo-web-browser"; import { DiscoveryDocument } from "expo-auth-session"; import * as Device from "expo-device"; @@ -276,11 +282,13 @@ export function AuthProvider({ children }: { children: JSX.Element }) { const [authenticated, setAuthenticated] = useState({ authenticated: Authed.LOADING, }); + const [guestWarning, setGuestWarning] = useState(false); useEffect(() => { if (!discovery) return; async function getAuthenticated() { if (await SecureStore.getItemAsync("guest")) { + setGuestWarning(true); return setAuthenticated({ authenticated: Authed.GUEST, login: async () => { @@ -340,6 +348,23 @@ export function AuthProvider({ children }: { children: JSX.Element }) { ))} + + setGuestWarning(false)} + action={{ + label: "OK", + onPress: () => setGuestWarning(false), + }} + theme={{ + colors: { + inverseSurface: theme.colors.errorContainer, + inverseOnSurface: theme.colors.onErrorContainer, + }, + }} + > + Demo mode staat aan, acties worden niet bewaard! + ); }