From f4ca96e35d18f9692a0c1a1d443542273a44dd75 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Thu, 6 Jul 2023 16:43:50 +0800 Subject: [PATCH] Improved onboarding page --- src/components/Button/Button.tsx | 1 - .../IsStringEmpty/IsStringEmpty.tsx | 3 + src/routes/Onboarding/Onboarding.tsx | 136 ++++++++++++------ src/styles.tsx | 5 + 4 files changed, 104 insertions(+), 41 deletions(-) create mode 100644 src/components/IsStringEmpty/IsStringEmpty.tsx diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 3375a7e..83b9d7b 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -1,7 +1,6 @@ import * as React from "react"; import { Pressable, GestureResponderEvent } from "react-native"; import styles from "../../styles"; -import { colors } from "../../styles"; export interface props { children: React.ReactNode; diff --git a/src/components/IsStringEmpty/IsStringEmpty.tsx b/src/components/IsStringEmpty/IsStringEmpty.tsx new file mode 100644 index 0000000..b1cd9d1 --- /dev/null +++ b/src/components/IsStringEmpty/IsStringEmpty.tsx @@ -0,0 +1,3 @@ +export default function isStringEmpty(str: string) { + return str === "" || str === null || str === undefined; +} diff --git a/src/routes/Onboarding/Onboarding.tsx b/src/routes/Onboarding/Onboarding.tsx index 22a225d..2a68a37 100644 --- a/src/routes/Onboarding/Onboarding.tsx +++ b/src/routes/Onboarding/Onboarding.tsx @@ -7,52 +7,44 @@ import { colors } from "../../styles"; import { AnimatePresence, MotiView } from "moti"; import { useEffect, useState } from "react"; import Button from "../../components/Button/Button"; +import DropDownPicker from "react-native-dropdown-picker"; +import isStringEmpty from "../../components/IsStringEmpty/IsStringEmpty"; + export default function Onboarding() { const navigation = useNavigation(); // const dispatch = useDispatch(); // const creds = useSelector((state: RootState) => state.auth.creds); - const [student_info, setStudentInfo] = useState({ - year_level: "", - course: "", - semester: "", - }); - function isStringEmpty(str: string) { - return str === "" || str === null || str === undefined; - } + + // Semesters + const [semester, setSemester] = useState(""); + const [semesterOpen, setSemesterOpen] = useState(false); + const [semesters, setSemesters] = useState([ + { label: "1st Semester", value: "1st Sem" }, + { label: "2nd Semester", value: "2nd Sem" }, + ]); + // Year Level + const [year_level, setYearLevel] = useState(""); + const [yearLevelOpen, setYearLevelOpen] = useState(false); + const [year_levels, setYearLevels] = useState([ + { label: "1st Year", value: "1st Year" }, + { label: "2nd Year", value: "2nd Year" }, + ]); + // Course + const [course, setCourse] = useState(""); + const [courseOpen, setCourseOpen] = useState(false); + const [courses, setCourses] = useState([ + { label: "Bachelor of Science in Information Technology", value: "BSIT" }, + { label: "Bachelor of Science in Computer Science", value: "BSCS" }, + ]); const [complete, setComplete] = useState(false); + useEffect(() => { setComplete( - !isStringEmpty(student_info.year_level) && - !isStringEmpty(student_info.course) && - !isStringEmpty(student_info.semester) + !isStringEmpty(year_level) && + !isStringEmpty(course) && + !isStringEmpty(semester) ); - }, [student_info]); - function Introduction() { - const [shown, setShown] = useState(true); - useEffect(() => { - setTimeout(() => { - setShown(false); - }, 5000); - }, []); - return ( - - {shown && ( - - - We're glad to have you on board {"\n"} - Just a few more things before we get started - - - )} - - ); - } + }, [year_level, course, semester, complete]); return ( @@ -75,18 +67,82 @@ export default function Onboarding() { }} /> - + + + We're glad to have you on board {"\n"} + Just a few more things before we get started + + + Academic Info + { + setCourseOpen(open); + setSemesterOpen(false); + setYearLevelOpen(false); + }} + setValue={setCourse} + placeholder="Choose your course" + containerStyle={{ + ...styles.dropdown_template, + ...{ zIndex: 3000 }, + }} + dropDownContainerStyle={{ backgroundColor: "white" }} + /> + { + setSemesterOpen(open); + setCourseOpen(false); + setYearLevelOpen(false); + }} + setValue={setSemester} + placeholder="Current semester" + containerStyle={{ + ...styles.dropdown_template, + ...{ zIndex: 2000 }, + }} + dropDownContainerStyle={{ backgroundColor: "white" }} + /> + { + setYearLevelOpen(open); + setSemesterOpen(false); + setCourseOpen(false); + }} + setValue={setYearLevel} + placeholder="Your Year Level" + containerStyle={{ + ...styles.dropdown_template, + ...{ zIndex: 1000 }, + }} + dropDownContainerStyle={{ backgroundColor: "white" }} + /> diff --git a/src/styles.tsx b/src/styles.tsx index d3dfd15..6700f9a 100644 --- a/src/styles.tsx +++ b/src/styles.tsx @@ -99,6 +99,11 @@ const styles = StyleSheet.create({ padding: 10, borderRadius: 8, }, + dropdown_template: { + borderRadius: 16, + width: "70%", + marginVertical: 6, + }, }); export default styles;