-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
142 lines (135 loc) Β· 3.61 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import React, { Component } from "./node_modules/react";
import { TouchableOpacity, StyleSheet, Text, View, Image } from "react-native";
import { ic_check_box, ic_check_box_outline_blank } from "./img";
import HideModal from "./hidemodal";
export default class App extends Component {
state = {
modalVisible: false,
};
toggleModal = () => {
this.setState({ modalVisible: !this.state.modalVisible });
};
toggleChecked = () => {
this.setState({ checked: !this.state.checked });
};
cancelModal = () => {
this.setState({ checked: false, modalVisible: false });
};
render() {
return (
<View style={styles.container}>
<TouchableOpacity onPress={this.toggleModal}>
<Text>modal with invisibleDuration</Text>
</TouchableOpacity>
<HideModal
invisibleDuration={3000}
modalVisible={this.state.modalVisible}
hideChecked={this.state.checked}
modalProps={{ transparent: true, animationType: "slide" }}
id="testid"
>
<View style={styles.modalContainer}>
<View style={styles.modalContentContainer}>
<View style={styles.checkBoxContainer}>
<View style={styles.content}>
<Text>This your view</Text>
</View>
<TouchableOpacity
style={styles.innerCheckBoxContainer}
onPress={this.toggleChecked}
>
<Image
source={
this.state.checked
? ic_check_box
: ic_check_box_outline_blank
}
style={styles.checkBox}
/>
<Text>Never show for 3 seconds</Text>
</TouchableOpacity>
</View>
<View style={styles.buttonView}>
<TouchableOpacity
hitSlop={{ top: 5, right: 5, bottom: 5, left: 5 }}
onPress={this.toggleModal}
>
<Text>Confirm</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={this.cancelModal}
hitSlop={{ top: 5, right: 5, bottom: 5, left: 5 }}
>
<Text>Cancel</Text>
</TouchableOpacity>
</View>
</View>
</View>
</HideModal>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "space-around",
alignItems: "center",
backgroundColor: "#F5FCFF",
},
welcome: {
fontSize: 20,
textAlign: "center",
margin: 10,
},
instructions: {
textAlign: "center",
color: "#333333",
marginBottom: 5,
},
myView: {
backgroundColor: "red",
height: 300,
justifyContent: "center",
alignItems: "center",
},
closeButton: {
width: 30,
height: 30,
backgroundColor: "orange",
},
modalContainer: {
justifyContent: "center",
alignItems: "center",
flex: 1,
},
checkBoxContainer: {
backgroundColor: "orange",
padding: 10,
},
innerCheckBoxContainer: {
flexDirection: "row",
alignItems: "center",
},
checkBox: {
width: 20,
height: 20,
},
modalContentContainer: {
width: "88%",
padding: 20,
borderRadius: 10,
backgroundColor: "rgba(222,222,111,0.56)",
},
buttonView: {
flexDirection: "row",
justifyContent: "space-around",
paddingVertical: 10,
},
content: {
backgroundColor: "red",
height: 160,
justifyContent: "center",
alignItems: "center",
},
});