Improved onboarding page

This commit is contained in:
Keannu Bernasol 2023-07-06 16:43:50 +08:00
parent cf08dab685
commit f4ca96e35d
4 changed files with 104 additions and 41 deletions

View file

@ -1,7 +1,6 @@
import * as React from "react"; import * as React from "react";
import { Pressable, GestureResponderEvent } from "react-native"; import { Pressable, GestureResponderEvent } from "react-native";
import styles from "../../styles"; import styles from "../../styles";
import { colors } from "../../styles";
export interface props { export interface props {
children: React.ReactNode; children: React.ReactNode;

View file

@ -0,0 +1,3 @@
export default function isStringEmpty(str: string) {
return str === "" || str === null || str === undefined;
}

View file

@ -7,52 +7,44 @@ import { colors } from "../../styles";
import { AnimatePresence, MotiView } from "moti"; import { AnimatePresence, MotiView } from "moti";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import Button from "../../components/Button/Button"; import Button from "../../components/Button/Button";
import DropDownPicker from "react-native-dropdown-picker";
import isStringEmpty from "../../components/IsStringEmpty/IsStringEmpty";
export default function Onboarding() { export default function Onboarding() {
const navigation = useNavigation<RootDrawerParamList>(); const navigation = useNavigation<RootDrawerParamList>();
// const dispatch = useDispatch(); // const dispatch = useDispatch();
// const creds = useSelector((state: RootState) => state.auth.creds); // const creds = useSelector((state: RootState) => state.auth.creds);
const [student_info, setStudentInfo] = useState({
year_level: "", // Semesters
course: "", const [semester, setSemester] = useState("");
semester: "", const [semesterOpen, setSemesterOpen] = useState(false);
}); const [semesters, setSemesters] = useState([
function isStringEmpty(str: string) { { label: "1st Semester", value: "1st Sem" },
return str === "" || str === null || str === undefined; { 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); const [complete, setComplete] = useState(false);
useEffect(() => { useEffect(() => {
setComplete( setComplete(
!isStringEmpty(student_info.year_level) && !isStringEmpty(year_level) &&
!isStringEmpty(student_info.course) && !isStringEmpty(course) &&
!isStringEmpty(student_info.semester) !isStringEmpty(semester)
); );
}, [student_info]); }, [year_level, course, semester, complete]);
function Introduction() {
const [shown, setShown] = useState(true);
useEffect(() => {
setTimeout(() => {
setShown(false);
}, 5000);
}, []);
return (
<AnimatePresence>
{shown && (
<MotiView
from={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
exitTransition={{ type: "timing", duration: 1200, delay: 600 }}
transition={{ type: "timing", duration: 1200, delay: 600 }}
>
<Text style={styles.text_white_small}>
We're glad to have you on board {"\n"}
Just a few more things before we get started
</Text>
</MotiView>
)}
</AnimatePresence>
);
}
return ( return (
<View style={styles.background}> <View style={styles.background}>
@ -75,18 +67,82 @@ export default function Onboarding() {
}} }}
/> />
<View style={{ paddingVertical: 4 }} /> <View style={{ paddingVertical: 4 }} />
<Introduction /> <MotiView
from={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ type: "timing", duration: 1200, delay: 600 }}
>
<Text style={styles.text_white_small}>
We're glad to have you on board {"\n"}
Just a few more things before we get started
</Text>
</MotiView>
<View style={{ paddingVertical: 8 }} /> <View style={{ paddingVertical: 8 }} />
<MotiView <MotiView
from={{ opacity: 0 }} from={{ opacity: 0 }}
animate={{ opacity: 1 }} animate={{ opacity: 1 }}
transition={{ type: "timing", duration: 900, delay: 2000 }} transition={{ type: "timing", duration: 900, delay: 2000 }}
> >
<Text style={styles.text_white_medium}>Academic Info</Text> <Text style={styles.text_white_medium}>Academic Info</Text>
<DropDownPicker
zIndex={3000}
open={courseOpen}
value={course}
items={courses}
setOpen={(open) => {
setCourseOpen(open);
setSemesterOpen(false);
setYearLevelOpen(false);
}}
setValue={setCourse}
placeholder="Choose your course"
containerStyle={{
...styles.dropdown_template,
...{ zIndex: 3000 },
}}
dropDownContainerStyle={{ backgroundColor: "white" }}
/>
<DropDownPicker
zIndex={2000}
open={semesterOpen}
value={semester}
items={semesters}
setOpen={(open) => {
setSemesterOpen(open);
setCourseOpen(false);
setYearLevelOpen(false);
}}
setValue={setSemester}
placeholder="Current semester"
containerStyle={{
...styles.dropdown_template,
...{ zIndex: 2000 },
}}
dropDownContainerStyle={{ backgroundColor: "white" }}
/>
<DropDownPicker
zIndex={1000}
open={yearLevelOpen}
value={year_level}
items={year_levels}
setOpen={(open) => {
setYearLevelOpen(open);
setSemesterOpen(false);
setCourseOpen(false);
}}
setValue={setYearLevel}
placeholder="Your Year Level"
containerStyle={{
...styles.dropdown_template,
...{ zIndex: 1000 },
}}
dropDownContainerStyle={{ backgroundColor: "white" }}
/>
</MotiView> </MotiView>
<MotiView <MotiView
from={{ opacity: 0 }} from={{ opacity: 0 }}
animate={{ opacity: 1 }} animate={{ opacity: 1, zIndex: -1 }}
transition={{ type: "timing", duration: 900, delay: 2000 }} transition={{ type: "timing", duration: 900, delay: 2000 }}
style={styles.button_template} style={styles.button_template}
> >

View file

@ -99,6 +99,11 @@ const styles = StyleSheet.create({
padding: 10, padding: 10,
borderRadius: 8, borderRadius: 8,
}, },
dropdown_template: {
borderRadius: 16,
width: "70%",
marginVertical: 6,
},
}); });
export default styles; export default styles;