Loading mobile/src/profile/hooks/useSlideControl.ts 0 → 100644 +15 −0 Original line number Diff line number Diff line import { useState } from "react"; export const useSlideControl = ( onFinish: () => void) => { const [currentSlide, setCurrentSlide] = useState(0); const onNext = () => { setCurrentSlide(currentSlide + 1); }; const onPrevious = () => { setCurrentSlide(currentSlide - 1); }; return { currentSlide, onNext, onPrevious, onFinish }; }; No newline at end of file mobile/src/profile/screens/first_time_config_screen.tsx 0 → 100644 +51 −0 Original line number Diff line number Diff line import { View, StyleSheet, Text } from "react-native"; import { LIGHT_THEME } from "../../common/constants/theme"; import { ScrollView } from "react-native-gesture-handler"; import { useState } from "react"; import { MultipleOptionPicker, } from "../components/multiple_option_pickeer"; import { DateTextInput } from "../../common/components/form/date_text_input"; import { TouchableOpacity } from "@gorhom/bottom-sheet"; import { SlideControl } from "../../common/components/slide_control"; import { InterestSlide } from "../components/interest_slide"; import { BirthdateSlide } from "../components/birthdate_slide"; import { useSetUpProfile } from "../hooks/useSetUpProfile"; import { useSlideControl } from "../hooks/useSlideControl"; import { router } from "expo-router"; export const FirstTimeComfigScreen = () => { const { onSubmit, toogleInterest, interests, control } = useSetUpProfile(); const onFinishCallback = () => { onSubmit(); }; console.log('render'); const { onFinish, onNext, onPrevious, currentSlide } = useSlideControl(onFinishCallback); const slides = [ <InterestSlide options={interests} onToogleOption={toogleInterest} />, <BirthdateSlide control={control} />, ]; return ( <View style={styles.mainContainer}> {slides[currentSlide]} <SlideControl onFinish={onFinish} onNext={onNext} onPrevious={onPrevious} isFirst={currentSlide==0} isLast={currentSlide==slides.length - 1}/> </View> ); }; const styles = StyleSheet.create({ mainContainer: { flex: 1, alignItems: "center", padding: 20, }, container: { flex: 1, }, controlsContainer: { flexDirection: "row", justifyContent: "space-between", }, }); Loading
mobile/src/profile/hooks/useSlideControl.ts 0 → 100644 +15 −0 Original line number Diff line number Diff line import { useState } from "react"; export const useSlideControl = ( onFinish: () => void) => { const [currentSlide, setCurrentSlide] = useState(0); const onNext = () => { setCurrentSlide(currentSlide + 1); }; const onPrevious = () => { setCurrentSlide(currentSlide - 1); }; return { currentSlide, onNext, onPrevious, onFinish }; }; No newline at end of file
mobile/src/profile/screens/first_time_config_screen.tsx 0 → 100644 +51 −0 Original line number Diff line number Diff line import { View, StyleSheet, Text } from "react-native"; import { LIGHT_THEME } from "../../common/constants/theme"; import { ScrollView } from "react-native-gesture-handler"; import { useState } from "react"; import { MultipleOptionPicker, } from "../components/multiple_option_pickeer"; import { DateTextInput } from "../../common/components/form/date_text_input"; import { TouchableOpacity } from "@gorhom/bottom-sheet"; import { SlideControl } from "../../common/components/slide_control"; import { InterestSlide } from "../components/interest_slide"; import { BirthdateSlide } from "../components/birthdate_slide"; import { useSetUpProfile } from "../hooks/useSetUpProfile"; import { useSlideControl } from "../hooks/useSlideControl"; import { router } from "expo-router"; export const FirstTimeComfigScreen = () => { const { onSubmit, toogleInterest, interests, control } = useSetUpProfile(); const onFinishCallback = () => { onSubmit(); }; console.log('render'); const { onFinish, onNext, onPrevious, currentSlide } = useSlideControl(onFinishCallback); const slides = [ <InterestSlide options={interests} onToogleOption={toogleInterest} />, <BirthdateSlide control={control} />, ]; return ( <View style={styles.mainContainer}> {slides[currentSlide]} <SlideControl onFinish={onFinish} onNext={onNext} onPrevious={onPrevious} isFirst={currentSlide==0} isLast={currentSlide==slides.length - 1}/> </View> ); }; const styles = StyleSheet.create({ mainContainer: { flex: 1, alignItems: "center", padding: 20, }, container: { flex: 1, }, controlsContainer: { flexDirection: "row", justifyContent: "space-between", }, });