mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
Fixed app.tsx showing blank when not specifying url and made drawer responsive to login state
This commit is contained in:
parent
c4f241f799
commit
9cdb4f1ba2
2 changed files with 103 additions and 61 deletions
2
App.tsx
2
App.tsx
|
@ -50,8 +50,6 @@ export default function App() {
|
||||||
}, [initialRoute]);
|
}, [initialRoute]);
|
||||||
|
|
||||||
if (!initialRoute) {
|
if (!initialRoute) {
|
||||||
console.log("heh");
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -11,10 +11,52 @@ import HomeIcon from "../../icons/HomeIcon/HomeIcon";
|
||||||
import LoginIcon from "../../icons/LoginIcon/LoginIcon";
|
import LoginIcon from "../../icons/LoginIcon/LoginIcon";
|
||||||
import SignupIcon from "../../icons/SignupIcon/SignupIcon";
|
import SignupIcon from "../../icons/SignupIcon/SignupIcon";
|
||||||
import DrawerButton from "../Button/DrawerButton";
|
import DrawerButton from "../Button/DrawerButton";
|
||||||
import AddIcon from "../../icons/AddIcon/AddIcon";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
import { RootState } from "../../features/redux/Store/Store";
|
||||||
|
import LogoutIcon from "../../icons/LogoutIcon/LogoutIcon";
|
||||||
|
import { clear } from "../../features/redux/slices/AuthSlice/AuthSlice";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
|
|
||||||
export default function CustomDrawerContent(props: {}) {
|
export default function CustomDrawerContent(props: {}) {
|
||||||
const navigation = useNavigation<RootDrawerParamList>();
|
const navigation = useNavigation<RootDrawerParamList>();
|
||||||
|
const logged_in = useSelector(
|
||||||
|
(state: RootState) => state.auth.creds.logged_in
|
||||||
|
);
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
if (logged_in) {
|
||||||
|
return (
|
||||||
|
<DrawerContentScrollView {...props}>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
...styles.flex_row,
|
||||||
|
...{ justifyContent: "center" },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AppIcon size={32} />
|
||||||
|
<Text style={styles.text_white_medium}>Stud-E</Text>
|
||||||
|
</View>
|
||||||
|
<DrawerButton
|
||||||
|
color={colors.blue_2}
|
||||||
|
onPress={() => {
|
||||||
|
navigation.navigate("Home");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<HomeIcon size={32} />
|
||||||
|
<Text style={styles.text_white_medium}>Home</Text>
|
||||||
|
</DrawerButton>
|
||||||
|
<DrawerButton
|
||||||
|
color={colors.blue_2}
|
||||||
|
onPress={async () => {
|
||||||
|
dispatch(await clear());
|
||||||
|
AsyncStorage.clear();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LogoutIcon size={32} />
|
||||||
|
<Text style={styles.text_white_medium}>Logout</Text>
|
||||||
|
</DrawerButton>
|
||||||
|
</DrawerContentScrollView>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
return (
|
return (
|
||||||
<DrawerContentScrollView {...props}>
|
<DrawerContentScrollView {...props}>
|
||||||
<View
|
<View
|
||||||
|
@ -47,19 +89,21 @@ export default function CustomDrawerContent(props: {}) {
|
||||||
<DrawerButton
|
<DrawerButton
|
||||||
color={colors.blue_2}
|
color={colors.blue_2}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
navigation.navigate("Register");
|
dispatch(clear());
|
||||||
|
navigation.navigate("Login");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SignupIcon size={32} />
|
<SignupIcon size={32} />
|
||||||
<Text style={styles.text_white_medium}>Register</Text>
|
<Text style={styles.text_white_medium}>Register</Text>
|
||||||
</DrawerButton>
|
</DrawerButton>
|
||||||
{/*<DrawerButton
|
{/*
|
||||||
|
Debug buttons for accessing revalidation and activation page
|
||||||
|
<DrawerButton
|
||||||
color={colors.blue_2}
|
color={colors.blue_2}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
navigation.navigate("Revalidation");
|
navigation.navigate("Revalidation");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<AddIcon size={32} />
|
|
||||||
<Text style={styles.text_white_medium}>Revalidation</Text>
|
<Text style={styles.text_white_medium}>Revalidation</Text>
|
||||||
</DrawerButton>
|
</DrawerButton>
|
||||||
<DrawerButton
|
<DrawerButton
|
||||||
|
@ -68,10 +112,10 @@ export default function CustomDrawerContent(props: {}) {
|
||||||
navigation.navigate("Activation");
|
navigation.navigate("Activation");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<AddIcon size={32} />
|
|
||||||
<Text style={styles.text_white_medium}>Activation</Text>
|
<Text style={styles.text_white_medium}>Activation</Text>
|
||||||
</DrawerButton>
|
</DrawerButton>
|
||||||
*/}
|
*/}
|
||||||
</DrawerContentScrollView>
|
</DrawerContentScrollView>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue