-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextModal.js
More file actions
125 lines (119 loc) · 2.83 KB
/
Copy pathTextModal.js
File metadata and controls
125 lines (119 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import React from 'react';
import {
Text,
View,
StyleSheet,
KeyboardAvoidingView,
} from 'react-native';
// Paper
import {
FAB,
Modal,
TextInput,
Portal,
} from 'react-native-paper';
export default class TextModal extends React.Component {
constructor(props) {
super(props);
this.state = {
text: "",
status: this.props.onFilterText(""),
};
}
componentDidMount = () => {
// Reset state to default
this.setState({ text: "", status: this.props.onFilterText("") });
}
render() {
return (
<Portal>
<Modal
animationType="fade"
transparent={true}
visible={this.props.visible}
onDismiss={this.props.onRequestClose}
onShow={() => {
this.setState({ text: "", status: this.props.onFilterText("") }); // Child views are destroyed, so onChangeText is never called, so reset the state.
this.textField.focus();
}}>
<View style={styles.textInputView}>
<TextInput
ref={(ref) => { ref = this.textField }} // autoFocus does nothing. see onShow
style={[styles.textInput, styles.text]}
clearButtonMode="always"
autoCorrect={false}
autoCapitalize="none"
returnKeyType="done"
underlineColorAndroid='#0000'
rows={3}
blurOnSubmit
placeholder="#"
placeholderTextColor='#888'
multiline
autoFocus
onChangeText={(text) => {
this.setState({ text, status: this.props.onFilterText(text) });
}}
/>
<FAB
style={styles.fab}
icon="check"
onPress={() => this.props.onTextAccepted(this.state.text)}
/>
<Text style={styles.statusText}>{this.state.status}</Text>
</View>
</Modal>
</Portal>
);
}
}
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
backgroundColor: '#000a',
},
text: {
color: '#aaa',
fontSize: 28,
},
hashtag: {
color: '#777',
fontSize: 38,
},
textAvoidingView: {
...StyleSheet.absoluteFillObject,
flexDirection: 'column',
alignItems: 'center',
},
textInputView: {
flexDirection: 'column',
alignItems: 'center',
},
textInput: {
maxWidth: '80%',
minWidth: 200,
maxHeight: '80%',
textAlign: 'center',
},
buttonContainer: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
},
statusText: {
color: '#777',
fontSize: 20,
margin: 5,
textAlign: 'center',
},
fab: {
x: 0,
y: 0,
width: 64,
height: 64,
margin: 16,
borderRadius: 32,
alignItems: 'center',
justifyContent: 'center',
},
});