Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_pickImageSource() {
try {
ActionSheet.show({
options: [
"Take Photo", "Pick From Album", "Cancel"
],
cancelButtonIndex: 2,
title: "Testing ActionSheet"
}, buttonIndex => {
// this 'buttonIndex value is a string on android and number on ios :-(
console.log(buttonIndex)
if (buttonIndex + "" === '0') {
this._pickImage(true)
} else if (buttonIndex + "" === '1') {
this._pickImage(false)
} else {
console.log('nothing')
}
})
handleImage = ({ row, index }) => () => {
const { activeRowIndex, rows = [] } = this.state
ActionSheet.show({
options: ['Delete', 'Cancel'],
cancelButtonIndex: 1,
destructiveButtonIndex: 0,
title: "Delete Image"
}, i => {
if (i === 0) {
// this.changeRowType({ index: activeRowIndex, type: ROW_TYPES.TEXT })
this.removeRow({ index, focusPrev: true })
}
})
}
delete () {
ActionSheet.show({
options: ['Delete', 'Cancel'],
cancelButtonIndex: 1,
destructiveButtonIndex: 0,
title: 'Do you really want to delete this entry?'
},
(buttonIndex) => {
if (buttonIndex === 0) {
Passwords.deleteItem(this.state.item.id)
.then(() => this.goBack())
.catch((err) => {
if (__DEV__) console.log('err', err)
})
}
})
}
_showActionSheet = () => {
ActionSheet.show(
{
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
destructiveButtonIndex: DESTRUCTIVE_INDEX,
title: "選擇電話類型"
},
buttonIndex => {
switch (BUTTONS[buttonIndex]) {
case GLOBAL_PARAMS.phoneType.HK.label:
this.setState({ selectedValue: GLOBAL_PARAMS.phoneType.HK });
break;
case GLOBAL_PARAMS.phoneType.CHN.label:
this.setState({ selectedValue: GLOBAL_PARAMS.phoneType.CHN });
break;
}
}
onPress={() =>
ActionSheet.show(
{
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
title: "Testing ActionSheet"
},
buttonIndex => {
this.setState({ clicked: BUTTONS[buttonIndex] });
}
)}
>
text: strings(Strings.CAMERA),
icon: 'camera',
iconColor: Colors.ACCENT,
},
{
text: strings(Strings.PHOTO_GALLERY),
icon: 'flower',
iconColor: Colors.BASE,
},
{
text: strings(Strings.CANCEL),
icon: 'close',
iconColor: Colors.ICON,
}];
const CANCEL_INDEX = 2;
ActionSheet.show({
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
},
(buttonIndex) => {
if (buttonIndex === 0) {
this.onOpenCameraPress();
}
if (buttonIndex === 1) {
this.onChooseFromGalleryPress();
}
});
}
_showActionSheet = () => {
ActionSheet.show(
{
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
destructiveButtonIndex: DESTRUCTIVE_INDEX,
title: "選擇電話類型"
},
buttonIndex => {
switch (BUTTONS[buttonIndex]) {
case GLOBAL_PARAMS.phoneType.HK.label:
this.setState({ selectedValue: GLOBAL_PARAMS.phoneType.HK });
break;
case GLOBAL_PARAMS.phoneType.CHN.label:
this.setState({ selectedValue: GLOBAL_PARAMS.phoneType.CHN });
break;
}
}
onPress={() =>
ActionSheet.show(
{
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
destructiveButtonIndex: DESTRUCTIVE_INDEX,
title: "Testing ActionSheet"
},
buttonIndex => {
this.setState({ clicked: BUTTONS[buttonIndex] });
}
)}
>
text: strings(Strings.CAMERA),
icon: 'camera',
iconColor: Colors.ACCENT,
},
{
text: strings(Strings.PHOTO_GALLERY),
icon: 'flower',
iconColor: Colors.BASE,
},
{
text: strings(Strings.CANCEL),
icon: 'close',
iconColor: Colors.ICON,
}];
const CANCEL_INDEX = 2;
ActionSheet.show({
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
},
(buttonIndex) => {
if (buttonIndex === 0) {
this.onOpenCameraPress();
}
if (buttonIndex === 1) {
this.onChooseFromGalleryPress();
}
});
}