mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
fix topic editing and deleting on AddNotebookDialog
This commit is contained in:
@@ -97,10 +97,12 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
refs = [];
|
refs = [];
|
||||||
prevTopics.splice(index, 1);
|
prevTopics.splice(index, 1);
|
||||||
let edit = this.props.toEdit;
|
let edit = this.props.toEdit;
|
||||||
|
if (edit && edit.id) {
|
||||||
let topicToDelete = edit.topics[index + 1];
|
let topicToDelete = edit.topics[index + 1];
|
||||||
|
if (topicToDelete) {
|
||||||
this.topicsToDelete.push(topicToDelete.id);
|
this.topicsToDelete.push(topicToDelete.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
let nextTopics = [...prevTopics];
|
let nextTopics = [...prevTopics];
|
||||||
if (this.prevIndex === index) {
|
if (this.prevIndex === index) {
|
||||||
this.prevIndex = null;
|
this.prevIndex = null;
|
||||||
@@ -246,7 +248,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
visible={visible}
|
visible={visible}
|
||||||
transparent={true}
|
transparent={true}
|
||||||
animated
|
animated
|
||||||
animationType="fade"
|
animationType={DDS.isTab ? "fade" :"slide"}
|
||||||
onShow={() => {
|
onShow={() => {
|
||||||
this.topicsToDelete = [];
|
this.topicsToDelete = [];
|
||||||
this.titleRef.focus();
|
this.titleRef.focus();
|
||||||
@@ -305,7 +307,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
onSubmitEditing={() => {
|
onSubmitEditing={() => {
|
||||||
this.descriptionRef.focus();
|
this.descriptionRef.focus();
|
||||||
}}
|
}}
|
||||||
placeholder="Title of notebook"
|
placeholder="Title"
|
||||||
placeholderTextColor={colors.icon}
|
placeholderTextColor={colors.icon}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
@@ -314,12 +316,10 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
styles.input,
|
styles.input,
|
||||||
{
|
{
|
||||||
borderColor: descFocused ? colors.accent : colors.nav,
|
borderColor: descFocused ? colors.accent : colors.nav,
|
||||||
minHeight: 90,
|
minHeight: 45,
|
||||||
color: colors.pri,
|
color: colors.pri,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
textAlignVertical="top"
|
|
||||||
numberOfLines={2}
|
|
||||||
maxLength={150}
|
maxLength={150}
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -338,8 +338,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
onSubmitEditing={() => {
|
onSubmitEditing={() => {
|
||||||
this.topicInputRef.focus();
|
this.topicInputRef.focus();
|
||||||
}}
|
}}
|
||||||
multiline
|
placeholder="Describe your notebook."
|
||||||
placeholder="What is this notebook about?"
|
|
||||||
placeholderTextColor={colors.icon}
|
placeholderTextColor={colors.icon}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -382,7 +381,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
marginTop: 5,
|
marginTop: 5,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
placeholder="Add a new topic"
|
placeholder="Add a topic"
|
||||||
placeholderTextColor={colors.icon}
|
placeholderTextColor={colors.icon}
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@@ -403,21 +402,21 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
zIndex:10
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
|
||||||
<FlatList
|
<FlatList
|
||||||
data={topics}
|
data={topics}
|
||||||
ref={(ref) => (this.listRef = ref)}
|
ref={(ref) => (this.listRef = ref)}
|
||||||
removeClippedSubviews={false}
|
|
||||||
enableEmptySections={false}
|
|
||||||
getItemLayout={(data, index) => ({
|
|
||||||
length: 50,
|
|
||||||
offset: 50 * index,
|
|
||||||
index,
|
|
||||||
})}
|
|
||||||
keyExtractor={(item, index) => item + index.toString()}
|
keyExtractor={(item, index) => item + index.toString()}
|
||||||
renderItem={({item, index}) => (
|
renderItem={({item, index}) => (
|
||||||
<TopicItem
|
<TopicItem
|
||||||
item={item}
|
item={item}
|
||||||
onPress={(item, index) => {
|
onPress={(item, index) => {
|
||||||
|
console.log("here")
|
||||||
this.prevIndex = index;
|
this.prevIndex = index;
|
||||||
this.prevItem = item;
|
this.prevItem = item;
|
||||||
this.topicInputRef.setNativeProps({
|
this.topicInputRef.setNativeProps({
|
||||||
@@ -432,6 +431,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
<View style={styles.buttonContainer}>
|
<View style={styles.buttonContainer}>
|
||||||
<Button
|
<Button
|
||||||
@@ -465,15 +465,20 @@ const TopicItem = ({item, index, colors, onPress, onDelete}) => {
|
|||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
marginTop: 10,
|
|
||||||
}}>
|
}}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
|
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '80%',
|
||||||
|
backgroundColor:"transparent",
|
||||||
|
zIndex:10,
|
||||||
|
position:'absolute',
|
||||||
|
height:30
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
onPress(item, index);
|
onPress(item, index)
|
||||||
}}>
|
}}
|
||||||
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
ref={topicRef}
|
ref={topicRef}
|
||||||
editable={false}
|
editable={false}
|
||||||
@@ -489,7 +494,7 @@ const TopicItem = ({item, index, colors, onPress, onDelete}) => {
|
|||||||
placeholder="Add a topic"
|
placeholder="Add a topic"
|
||||||
placeholderTextColor={colors.icon}
|
placeholderTextColor={colors.icon}
|
||||||
/>
|
/>
|
||||||
</TouchableOpacity>
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
onDelete(index);
|
onDelete(index);
|
||||||
@@ -545,7 +550,7 @@ const styles = StyleSheet.create({
|
|||||||
fontFamily: WEIGHT.regular,
|
fontFamily: WEIGHT.regular,
|
||||||
padding: pv - 2,
|
padding: pv - 2,
|
||||||
borderWidth: 1.5,
|
borderWidth: 1.5,
|
||||||
marginTop: 20,
|
marginTop: 10,
|
||||||
marginBottom: 5,
|
marginBottom: 5,
|
||||||
},
|
},
|
||||||
addBtn: {
|
addBtn: {
|
||||||
@@ -572,12 +577,12 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
topicInput: {
|
topicInput: {
|
||||||
padding: pv - 5,
|
padding: pv - 5,
|
||||||
paddingHorizontal: 0,
|
|
||||||
fontSize: SIZE.sm,
|
fontSize: SIZE.sm,
|
||||||
fontFamily: WEIGHT.regular,
|
fontFamily: WEIGHT.regular,
|
||||||
paddingHorizontal: ph,
|
paddingHorizontal: ph,
|
||||||
borderBottomWidth: 1.5,
|
borderBottomWidth: 1.5,
|
||||||
paddingRight: 40,
|
paddingRight: 40,
|
||||||
|
paddingVertical:10,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
maxWidth: '100%',
|
maxWidth: '100%',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user