forked from jaysoo/react-native-prompt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPromptExample.js
43 lines (41 loc) · 1.19 KB
/
PromptExample.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
import React, {
Component,
} from 'react';
import {
Text,
View
} from 'react-native';
import Prompt from 'react-native-prompt';
class PromptExample extends Component {
constructor(props) {
super(props);
this.state = {
message: '',
promptVisible: false
};
}
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<View style={{ height: 80, justifyContent: 'flex-end' }}>
<Text style={{ fontSize: 20 }} onPress={() => this.setState({ promptVisible: true })}>
Open prompt
</Text>
</View>
<View style={{ flex: 1, justifyContent: 'center' }}>
<Text style={{ fontSize: 20 }}>
{this.state.message}
</Text>
</View>
<Prompt
title="Say something"
placeholder="Start typing"
defaultValue="Hello"
visible={this.state.promptVisible}
onCancel={() => this.setState({ promptVisible: false, message: "You cancelled" })}
onSubmit={(value) => this.setState({ promptVisible: false, message: `You said "${value}"` })}/>
</View>
);
}
}
export default PromptExample;