-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
51 lines (49 loc) · 1.9 KB
/
App.js
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
import React, { Component } from 'react';
import { View, Text, ToastAndroid } from 'react-native';
import Prompt from 'react-native-modal-prompt';
class App extends Component {
constructor(props) {
super(props);
this.state = {
promptVisible: false
};
}
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#fff' }}>
<View>
<Text style={{ fontSize: 20 }} onPress={() => this.setState({ promptVisible: true })}>
open prompt
</Text>
</View>
<Prompt
visible={this.state.promptVisible}
title="title"
placeholder="please write something"
defaultValue="prompt"
showCount={true}
operation={[
{
text: 'Cancel',
color: '#000',
onPress: () => {
ToastAndroid.showWithGravity('if return false, the modal will not close', 1000, ToastAndroid.CENTER);
return false;
}},
{
text: 'Ok',
onPress: (value) =>
new Promise((resolve) => {
console.log(`the prompt value is ${value}`);
// ajax....
ToastAndroid.showWithGravity('ajax request sucess', 1000, ToastAndroid.CENTER);
setTimeout(resolve, 2000);
}),
},
]}
/>
</View>
);
}
}
export default App;