-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathWixActionSheet.js
83 lines (77 loc) · 2.55 KB
/
WixActionSheet.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
import React, {Component} from 'react';
import {View, Text, Button, ActionSheet} from 'react-native-ui-lib'; //eslint-disable-line
import _ from 'lodash';
const useCases = [{label: 'Default (Android/iOS)', useNativeIOS: false}, {label: 'Native IOS', useNativeIOS: true}];
export default class WixActionSheet extends Component {
state = {
showNative: false,
showCustom: false,
};
pickOption(index) {
this.setState({
pickedOption: index,
});
}
render() {
const {showCustom, showNative, pickedOption} = this.state;
return (
<View flex padding-25>
<Text text30>Action Sheet</Text>
<View left marginT-40>
{_.map(useCases, (useCase, index) => {
return (
<Button
key={index}
link
size="small"
text50
marginB-10
dark10
label={`> ${useCase.label}`}
onPress={() =>
this.setState({
showNative: useCase.useNativeIOS,
showCustom: !useCase.useNativeIOS,
})}
/>
);
})}
</View>
{!_.isUndefined(pickedOption) && (
<View>
<Text>User picked {pickedOption}</Text>
</View>
)}
<ActionSheet
title="Title"
message="Message of action sheet"
cancelButtonIndex={3}
destructiveButtonIndex={0}
options={[
{label: 'option 1', onPress: () => this.pickOption('option 1')},
{label: 'option 2', onPress: () => this.pickOption('option 2')},
{label: 'option 3', onPress: () => this.pickOption('option 3')},
{label: 'cancel', onPress: () => this.pickOption('cancel')},
]}
visible={showCustom}
onDismiss={() => this.setState({showCustom: false})}
/>
<ActionSheet
title="Title"
message="Message of action sheet"
cancelButtonIndex={3}
destructiveButtonIndex={0}
options={[
{label: 'option 1', onPress: () => this.pickOption('option 1')},
{label: 'option 2', onPress: () => this.pickOption('option 2')},
{label: 'option 3', onPress: () => this.pickOption('option 3')},
{label: 'cancel', onPress: () => this.pickOption('cancel')},
]}
visible={showNative}
useNativeIOS
onDismiss={() => this.setState({showNative: false})}
/>
</View>
);
}
}