import React, {useEffect, useState, createRef} from 'react'; import { ScrollView, View, Text, TouchableOpacity, Dimensions, Image, SafeAreaView, Platform, Modal, } from 'react-native'; import NavigationService from '../../services/NavigationService'; import { COLOR_SCHEME, SIZE, br, ph, pv, opacity, FONT, WEIGHT, } from '../../common/common'; import Icon from 'react-native-vector-icons/Feather'; import {getElevation, h, w, timeSince, ToastEvent} from '../../utils/utils'; import {FlatList, TextInput} from 'react-native-gesture-handler'; import {useForceUpdate} from '../../views/ListsEditor'; import {db} from '../../../App'; export const AddTopicDialog = ({ visible, close = () => {}, notebookID, toEdit = null, }) => { const [colors, setColors] = useState(COLOR_SCHEME); const [topics, setTopics] = useState(['']); const forceUpdate = useForceUpdate(); const setTitleRef = createRef(); let description = 'my first notebook'; let title = null; const addNewTopic = async () => { if (!title) return ToastEvent.show('Title is required', 'error', 3000, () => {}, ''); console.log(notebookID, title); db.addTopicToNotebook(notebookID, title); ToastEvent.show('New topic added', 'success', 3000, () => {}, ''); close(true); }; return ( (refs = [])}> {toEdit ? 'Edit Topic' : 'Add New Topic'} { title = value; }} placeholder="Enter title of topic" placeholderTextColor={colors.icon} /> await addNewTopic()} style={{ paddingVertical: pv, paddingHorizontal: ph, borderRadius: 5, width: '45%', justifyContent: 'center', alignItems: 'center', borderColor: colors.accent, backgroundColor: colors.accent, borderWidth: 1, }}> Add close()} style={{ paddingVertical: pv, paddingHorizontal: ph, borderRadius: 5, width: '45%', justifyContent: 'center', alignItems: 'center', backgroundColor: colors.nav, }}> Cancel ); };