diff --git a/js/components/DataManagement/DataManagement.react.tsx b/js/components/DataManagement/DataManagement.react.tsx index 2cba370..6dda324 100644 --- a/js/components/DataManagement/DataManagement.react.tsx +++ b/js/components/DataManagement/DataManagement.react.tsx @@ -1,22 +1,30 @@ -import React from 'react'; +import React, { useState } from 'react'; import { View, Text, StyleSheet, TouchableNativeFeedback, Alert, + Modal, + TextInput, + Button, } from 'react-native'; import {ScrollView} from 'react-native-gesture-handler'; import useStatusBarStyle from '../../hooks/useStatusBarStyle'; import CourseData from '../../course-data'; import DownloadManager from '../../download-manager'; -import {genDeleteProgressForCourse} from '../../persistence'; +import {genDeleteProgressForCourse, genSetProgressForCourse} from '../../persistence'; import {log} from '../../metrics'; import { useNavigation } from '@react-navigation/core'; import { MainNavigationProp } from '../App.react'; const DataManagement = ({route}: {route: any}) => { useStatusBarStyle('white', 'dark-content'); + const [modalVisible, setModalVisible] = useState(false); + const [lastLessonNumber, _setLastLessonNumber] = useState(''); + const setLastLessonNumber = (val: string) => { + _setLastLessonNumber(val.replace(/[^0-9]/g, '')); + }; const {navigate} = useNavigation>(); const {course} = route.params; @@ -66,6 +74,89 @@ const DataManagement = ({route}: {route: any}) => { + + setModalVisible(true)} + // TODO: Replace with modal with number input and guide text. Added this for testing purposes. + useForeground={true}> + + + Set {courseTitle} progress + + + This will set all the lessons up to the given lesson number as + completed. + + + + { + Alert.alert('Modal has been closed.'); + setModalVisible(!modalVisible); + // TODO: How do I do this better? I don't need the value of the input after the modal is closed so it can be discarded. A local variable would suffice. + setLastLessonNumber(''); + }}> + + + + Set the lesson number you wish to set your course progress to: + + + + + +