diff --git a/apps/mobile/src/components/AddNotebookDialog/index.js b/apps/mobile/src/components/AddNotebookDialog/index.js index a88e03cb3..027f77fac 100644 --- a/apps/mobile/src/components/AddNotebookDialog/index.js +++ b/apps/mobile/src/components/AddNotebookDialog/index.js @@ -10,14 +10,14 @@ import {db} from '../../utils/DB'; import {ph, pv, SIZE} from '../../utils/SizeUtils'; import {sleep} from '../../utils/TimeUtils'; import {ActionIcon} from '../ActionIcon'; +import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper'; +import {Button} from '../Button'; import BaseDialog from '../Dialog/base-dialog'; import DialogButtons from '../Dialog/dialog-buttons'; import DialogHeader from '../Dialog/dialog-header'; import Input from '../Input'; -import {Placeholder} from '../ListPlaceholders'; +import Seperator from '../Seperator'; import {Toast} from '../Toast'; -import Heading from '../Typography/Heading'; -import Paragraph from '../Typography/Paragraph'; let refs = []; @@ -33,7 +33,7 @@ export class AddNotebookDialog extends React.Component { count: 0, topicInputFocused: false, editTopic: false, - loading: false, + loading: false }; this.title = null; this.description = null; @@ -50,6 +50,7 @@ export class AddNotebookDialog extends React.Component { this.hiddenInput = createRef(); this.topicInputRef = createRef(); this.addingTopic = false; + this.actionSheetRef = createRef(); } open = () => { @@ -69,16 +70,20 @@ export class AddNotebookDialog extends React.Component { this.setState({ topics: [...topicsList], - visible: true, + visible: true }); } else { this.setState({ - visible: true, + visible: true }); } + sleep(100).then(r => { + this.actionSheetRef.current?.show(); + }); }; close = () => { + this.actionSheetRef.current?.hide(); refs = []; this.prevIndex = null; this.prevItem = null; @@ -92,7 +97,7 @@ export class AddNotebookDialog extends React.Component { topics: [], descFocused: false, titleFocused: false, - editTopic: false, + editTopic: false }); }; @@ -115,17 +120,17 @@ export class AddNotebookDialog extends React.Component { this.prevItem = null; this.currentInputValue = null; this.topicInputRef.current?.setNativeProps({ - text: null, + text: null }); } this.setState({ - topics: nextTopics, + topics: nextTopics }); }; addNewNotebook = async () => { this.setState({ - loading: true, + loading: true }); let {topics} = this.state; let edit = this.props.toEdit; @@ -134,10 +139,10 @@ export class AddNotebookDialog extends React.Component { ToastEvent.show({ heading: 'Notebook title is required', type: 'error', - context: 'local', + context: 'local' }); this.setState({ - loading: false, + loading: false }); return; } @@ -170,7 +175,7 @@ export class AddNotebookDialog extends React.Component { await db.notebooks.add({ title: this.title, description: this.description, - id: id, + id: id }); let nextTopics = toEdit.topics.map((topic, index) => { @@ -192,17 +197,17 @@ export class AddNotebookDialog extends React.Component { title: this.title, description: this.description, topics: prevTopics, - id: id, + id: id }); } useMenuStore.getState().setMenuPins(); Navigation.setRoutesToUpdate([ Navigation.routeNames.Notebooks, Navigation.routeNames.Notebook, - Navigation.routeNames.NotesPage, + Navigation.routeNames.NotesPage ]); this.setState({ - loading: false, + loading: false }); this.close(); }; @@ -218,7 +223,7 @@ export class AddNotebookDialog extends React.Component { if (this.prevItem === null) { prevTopics.push(this.currentInputValue); this.setState({ - topics: prevTopics, + topics: prevTopics }); setTimeout(() => { this.listRef.scrollToEnd({animated: true}); @@ -227,7 +232,7 @@ export class AddNotebookDialog extends React.Component { } else { prevTopics[this.prevIndex] = this.currentInputValue; this.setState({ - topics: prevTopics, + topics: prevTopics }); this.currentInputValue = null; @@ -235,7 +240,7 @@ export class AddNotebookDialog extends React.Component { this.topicInputRef.current?.blur(); Keyboard.dismiss(); this.setState({ - editTopic: false, + editTopic: false }); willFocus = false; } @@ -250,7 +255,7 @@ export class AddNotebookDialog extends React.Component { } } this.topicInputRef.current?.setNativeProps({ - text: '', + text: '' }); willFocus && this.topicInputRef.current?.focus(); }; @@ -260,12 +265,20 @@ export class AddNotebookDialog extends React.Component { const {topics, visible, topicInputFocused} = this.state; if (!visible) return null; return ( - { + { this.topicsToDelete = []; await sleep(300); this.props.toEdit?.type !== 'notebook' && this.titleRef?.focus(); }} + fwdRef={this.actionSheetRef} + onClose={() => { + this.close(); + this.setState({ + visible: false + }); + }} + animation="fade" centered={false} statusBarTranslucent={false} onRequestClose={this.close}> @@ -275,7 +288,7 @@ export class AddNotebookDialog extends React.Component { width: 1, height: 1, opacity: 0, - position: 'absolute', + position: 'absolute' }} blurOnSubmit={false} /> @@ -285,8 +298,10 @@ export class AddNotebookDialog extends React.Component { styles.container, { backgroundColor: colors.bg, - paddingTop: 5, - }, + height: null, + borderTopRightRadius: 10, + borderTopLeftRadius: 10 + } ]}> + (this.titleRef = ref)} @@ -338,8 +354,8 @@ export class AddNotebookDialog extends React.Component { refs[this.prevIndex].setNativeProps({ text: value, style: { - borderBottomColor: colors.accent, - }, + borderBottomColor: colors.accent + } }); } }} @@ -352,7 +368,7 @@ export class AddNotebookDialog extends React.Component { button={{ icon: this.state.editTopic ? 'check' : 'plus', onPress: this.onSubmit, - color: topicInputFocused ? colors.accent : colors.icon, + color: topicInputFocused ? colors.accent : colors.icon }} placeholder="Add a topic" /> @@ -361,26 +377,6 @@ export class AddNotebookDialog extends React.Component { data={topics} ref={ref => (this.listRef = ref)} keyExtractor={(item, index) => item + index.toString()} - ListEmptyComponent={ - - - Topics - - You have not added any topics yet. - - - } renderItem={({item, index}) => ( )} /> - - +