A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
move topic dialog to dialog manager
ammarahm-ed4f63d0e37690
diff --git a/apps/mobile/src/components/AddTopicDialog/index.js b/apps/mobile/src/components/AddTopicDialog/index.jsindex a928363b5..54cc86bf4 100644--- a/apps/mobile/src/components/AddTopicDialog/index.js+++ b/apps/mobile/src/components/AddTopicDialog/index.js@@ -1,164 +1,196 @@-import React, {useState} from 'react';+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 {db} from '../../../App';import {opacity, ph, pv, SIZE, WEIGHT} from '../../common/common';import {useTracked} from '../../provider';import {getElevation, ToastEvent} from '../../utils/utils';-export const AddTopicDialog = ({- visible,- close = () => {},- notebookID,- toEdit = null,-}) => {- const [state, dispatch] = useTracked();- const {colors} = state;- const [titleFocused, setTitleFocused] = useState(false);+export class AddTopicDialog extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ visible: false,+ titleFocused: false,+ };++ this.title;+ }- let title = null;- const addNewTopic = async () => {- if (!title)+ addNewTopic = async () => {+ if (!this.title)return ToastEvent.show('Title is required', 'error', 3000, () => {}, '');- db.addTopicToNotebook(notebookID, title);++ //db.addTopicToNotebook(toEdit.dateCreated, title);+ToastEvent.show('New topic added', 'success', 3000, () => {}, '');close(true);};- return (- <Modal- visible={visible}- animated- animationType="fade"- transparent={true}- onRequestClose={() => (refs = [])}>- <View- style={{- width: '100%',- height: '100%',- backgroundColor: 'rgba(0,0,0,0.3)',- justifyContent: 'center',- alignItems: 'center',- }}>- <TouchableOpacity- onPress={() => close()}- style={{- width: '100%',- height: '100%',- position: 'absolute',- }}- />+ open() {+ this.setState({+ visible: true,+ });+ }+ close() {+ this.title = null;+ this.setState({+ visible: false,+ });+ }++ render() {+ const {visible} = this.state;+ const {colors, toEdit} = this.props;+ return (+ <Modal+ visible={visible}+ animated+ animationType="fade"+ transparent={true}+ onRequestClose={() => (refs = [])}><Viewstyle={{- ...getElevation(5),- width: '80%',- maxHeight: 350,- borderRadius: 5,- backgroundColor: colors.bg,- paddingHorizontal: ph,- paddingVertical: pv,+ width: '100%',+ height: '100%',+ backgroundColor: 'rgba(0,0,0,0.3)',+ justifyContent: 'center',+ alignItems: 'center',}}>- <View- style={{- flexDirection: 'row',- justifyContent: 'center',- alignItems: 'center',- }}>- <Icon name="book-open" color={colors.accent} size={SIZE.lg} />- <Text- style={{- color: colors.accent,- fontFamily: WEIGHT.bold,- marginLeft: 5,- fontSize: SIZE.md,- }}>- {toEdit ? 'Edit Topic' : 'Add New Topic'}- </Text>- </View>-- <TextInput+ <TouchableOpacity+ onPress={() => close()}style={{- padding: pv,- borderWidth: 1.5,- borderColor: titleFocused ? colors.accent : colors.nav,- paddingHorizontal: ph,- borderRadius: 5,- fontSize: SIZE.sm,- fontFamily: WEIGHT.regular,- color: colors.pri,- marginTop: 20,- }}- onFocus={() => {- setTitleFocused(true);- }}- onBlur={() => {- setTitleFocused(false);- }}- defaultValue={toEdit ? toEdit.title : null}- onChangeText={value => {- title = value;+ width: '100%',+ height: '100%',+ position: 'absolute',}}- placeholder="Enter title of topic"- placeholderTextColor={colors.icon}/><Viewstyle={{- justifyContent: 'space-around',- alignItems: 'center',- flexDirection: 'row',- marginTop: 20,+ ...getElevation(5),+ width: '80%',+ maxHeight: 350,+ borderRadius: 5,+ backgroundColor: colors.bg,+ paddingHorizontal: ph,+ paddingVertical: pv,}}>- <TouchableOpacity- activeOpacity={opacity}- onPress={async () => await addNewTopic()}+ <Viewstyle={{- paddingVertical: pv,- paddingHorizontal: ph,- borderRadius: 5,- width: '45%',+ flexDirection: 'row',justifyContent: 'center',alignItems: 'center',- borderColor: colors.accent,- backgroundColor: colors.accent,- borderWidth: 1,}}>+ <Icon name="book-open" color={colors.accent} size={SIZE.lg} /><Textstyle={{- fontFamily: WEIGHT.medium,- color: 'white',- fontSize: SIZE.sm,+ color: colors.accent,+ fontFamily: WEIGHT.bold,+ marginLeft: 5,+ fontSize: SIZE.md,}}>- Add+ {toEdit ? 'Edit Topic' : 'Add New Topic'}</Text>- </TouchableOpacity>+ </View>- <TouchableOpacity- activeOpacity={opacity}- onPress={() => close()}+ <TextInputstyle={{- paddingVertical: pv,+ padding: pv,+ borderWidth: 1.5,+ borderColor: titleFocused ? colors.accent : colors.nav,paddingHorizontal: ph,borderRadius: 5,- width: '45%',- justifyContent: 'center',+ fontSize: SIZE.sm,+ fontFamily: WEIGHT.regular,+ color: colors.pri,+ marginTop: 20,+ }}+ onFocus={() => {+ 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}+ />++ <View+ style={{+ justifyContent: 'space-around',alignItems: 'center',- backgroundColor: colors.nav,+ flexDirection: 'row',+ marginTop: 20,}}>- <Text+ <TouchableOpacity+ activeOpacity={opacity}+ onPress={async () => await this.addNewTopic()}style={{- fontFamily: WEIGHT.medium,- color: colors.icon,- fontSize: SIZE.sm,+ paddingVertical: pv,+ paddingHorizontal: ph,+ borderRadius: 5,+ width: '45%',+ justifyContent: 'center',+ alignItems: 'center',+ borderColor: colors.accent,+ backgroundColor: colors.accent,+ borderWidth: 1,}}>- Cancel- </Text>- </TouchableOpacity>+ <Text+ style={{+ fontFamily: WEIGHT.medium,+ color: 'white',+ fontSize: SIZE.sm,+ }}>+ Add+ </Text>+ </TouchableOpacity>++ <TouchableOpacity+ activeOpacity={opacity}+ onPress={() => this.close()}+ style={{+ paddingVertical: pv,+ paddingHorizontal: ph,+ borderRadius: 5,+ width: '45%',+ justifyContent: 'center',+ alignItems: 'center',+ backgroundColor: colors.nav,+ }}>+ <Text+ style={{+ fontFamily: WEIGHT.medium,+ color: colors.icon,+ fontSize: SIZE.sm,+ }}>+ Cancel+ </Text>+ </TouchableOpacity>+ </View></View></View>- </View>- </Modal>- );+ </Modal>+ );+ }+}++export const AddTopicDialog = ({+ visible,+ close = () => {},+ notebookID,+ toEdit = null,+}) => {+ const [state, dispatch] = useTracked();+ const {colors} = state;};