mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
refactor add notebook dialog
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React, {createRef} from 'react';
|
import React, {createRef} from 'react';
|
||||||
import {Keyboard, StyleSheet, TouchableOpacity, View} from 'react-native';
|
import {Keyboard, StyleSheet, TouchableOpacity, View} from 'react-native';
|
||||||
import {FlatList, TextInput} from 'react-native-gesture-handler';
|
import {FlatList, ScrollView, TextInput} from 'react-native-gesture-handler';
|
||||||
import {notesnook} from '../../../e2e/test.ids';
|
import {notesnook} from '../../../e2e/test.ids';
|
||||||
import {useMenuStore} from '../../provider/stores';
|
import {useMenuStore} from '../../provider/stores';
|
||||||
import {DDS} from '../../services/DeviceDetection';
|
import {DDS} from '../../services/DeviceDetection';
|
||||||
@@ -12,8 +12,6 @@ import {sleep} from '../../utils/TimeUtils';
|
|||||||
import {ActionIcon} from '../ActionIcon';
|
import {ActionIcon} from '../ActionIcon';
|
||||||
import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';
|
import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';
|
||||||
import {Button} from '../Button';
|
import {Button} from '../Button';
|
||||||
import BaseDialog from '../Dialog/base-dialog';
|
|
||||||
import DialogButtons from '../Dialog/dialog-buttons';
|
|
||||||
import DialogHeader from '../Dialog/dialog-header';
|
import DialogHeader from '../Dialog/dialog-header';
|
||||||
import Input from '../Input';
|
import Input from '../Input';
|
||||||
import Seperator from '../Seperator';
|
import Seperator from '../Seperator';
|
||||||
@@ -54,13 +52,12 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open = () => {
|
open = () => {
|
||||||
|
console.log('opening called')
|
||||||
refs = [];
|
refs = [];
|
||||||
let {toEdit} = this.props;
|
let {toEdit} = this.props;
|
||||||
|
|
||||||
if (toEdit && toEdit.type === 'notebook') {
|
if (toEdit && toEdit.type === 'notebook') {
|
||||||
let topicsList = [];
|
let topicsList = [];
|
||||||
toEdit.topics.forEach((item, index) => {
|
toEdit.topics.forEach((item, index) => {
|
||||||
//if (index === 0) return;
|
|
||||||
topicsList.push(item.title);
|
topicsList.push(item.title);
|
||||||
});
|
});
|
||||||
this.id = toEdit.id;
|
this.id = toEdit.id;
|
||||||
@@ -69,7 +66,6 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
topics: [...topicsList],
|
topics: [...topicsList],
|
||||||
|
|
||||||
visible: true
|
visible: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -273,36 +269,30 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
}}
|
}}
|
||||||
fwdRef={this.actionSheetRef}
|
fwdRef={this.actionSheetRef}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
|
console.log('closing now');
|
||||||
this.close();
|
this.close();
|
||||||
this.setState({
|
this.setState({
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
animation="fade"
|
|
||||||
centered={false}
|
|
||||||
statusBarTranslucent={false}
|
statusBarTranslucent={false}
|
||||||
onRequestClose={this.close}>
|
onRequestClose={this.close}>
|
||||||
<TextInput
|
|
||||||
ref={this.hiddenInput}
|
|
||||||
style={{
|
|
||||||
width: 1,
|
|
||||||
height: 1,
|
|
||||||
opacity: 0,
|
|
||||||
position: 'absolute'
|
|
||||||
}}
|
|
||||||
blurOnSubmit={false}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
style={[
|
style={{
|
||||||
styles.container,
|
maxHeight: DDS.isTab ? '90%' : '100%',
|
||||||
{
|
borderRadius: DDS.isTab ? 5 : 0,
|
||||||
backgroundColor: colors.bg,
|
paddingHorizontal: 12
|
||||||
height: null,
|
}}>
|
||||||
borderTopRightRadius: 10,
|
<TextInput
|
||||||
borderTopLeftRadius: 10
|
ref={this.hiddenInput}
|
||||||
}
|
style={{
|
||||||
]}>
|
width: 1,
|
||||||
|
height: 1,
|
||||||
|
opacity: 0,
|
||||||
|
position: 'absolute'
|
||||||
|
}}
|
||||||
|
blurOnSubmit={false}
|
||||||
|
/>
|
||||||
<DialogHeader
|
<DialogHeader
|
||||||
title={
|
title={
|
||||||
toEdit && toEdit.dateCreated ? 'Edit Notebook' : 'New Notebook'
|
toEdit && toEdit.dateCreated ? 'Edit Notebook' : 'New Notebook'
|
||||||
@@ -493,13 +483,6 @@ const styles = StyleSheet.create({
|
|||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center'
|
alignItems: 'center'
|
||||||
},
|
},
|
||||||
container: {
|
|
||||||
width: DDS.isTab ? 500 : '100%',
|
|
||||||
height: DDS.isTab ? 600 : '100%',
|
|
||||||
maxHeight: DDS.isTab ? 600 : '100%',
|
|
||||||
borderRadius: DDS.isTab ? 5 : 0,
|
|
||||||
paddingHorizontal: 12
|
|
||||||
},
|
|
||||||
overlay: {
|
overlay: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
|
|||||||
Reference in New Issue
Block a user