import React from 'react'; import {Modal, Text, TouchableOpacity, View} from 'react-native'; import {TextInput} from 'react-native-gesture-handler'; import Icon from 'react-native-vector-icons/Feather'; import {opacity, ph, pv, SIZE, WEIGHT} from '../../common/common'; import {getElevation, ToastEvent} from '../../utils/utils'; export class AddTopicDialog extends React.Component { constructor(props) { super(props); this.state = { visible: false, titleFocused: false, }; this.title; } addNewTopic = async () => { if (!this.title) return ToastEvent.show('Title is required', 'error', 3000, () => {}, ''); //db.addTopicToNotebook(toEdit.dateCreated, title); ToastEvent.show('New topic added', 'success', 3000, () => {}, ''); close(true); }; open() { this.setState({ visible: true, }); } close() { this.title = null; this.setState({ visible: false, }); } render() { const {visible, titleFocused} = this.state; const {colors, toEdit} = this.props; return ( (refs = [])}> close()} style={{ width: '100%', height: '100%', position: 'absolute', }} /> {toEdit ? 'Edit Topic' : 'Add New Topic'} { this.setState({ titleFocused: true, }); }} onBlur={() => { this.setState({ titleFocused: true, }); }} defaultValue={toEdit ? toEdit.title : null} onChangeText={value => { this.title = value; }} placeholder="Enter title of topic" placeholderTextColor={colors.icon} /> await this.addNewTopic()} style={{ paddingVertical: pv, paddingHorizontal: ph, borderRadius: 5, width: '45%', justifyContent: 'center', alignItems: 'center', borderColor: colors.accent, backgroundColor: colors.accent, borderWidth: 1, }}> Add this.close()} style={{ paddingVertical: pv, paddingHorizontal: ph, borderRadius: 5, width: '45%', justifyContent: 'center', alignItems: 'center', backgroundColor: colors.nav, }}> Cancel ); } }