-
-
Save rpastorelle/801eabf763f1919cb528fd2e43e16b2a to your computer and use it in GitHub Desktop.
Cross-Platform ActionSheet Component for React Native
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Alert } from 'react-native'; | |
var ActionSheet = { | |
showActionSheetWithOptions: function(options : Object, onSelect : Function) { | |
let title = options.title, | |
buttons = []; | |
if (! title) { | |
if (options.options.length === 2) { | |
title = options.options[0] + '?'; | |
} else { | |
title = 'Choose:'; | |
} | |
} | |
options.options.forEach((label, index) => { | |
buttons.push({ | |
text: label, | |
onPress: () => onSelect(index), | |
}); | |
}); | |
Alert.alert(null, title, buttons); | |
}, | |
}; | |
export default ActionSheet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ActionSheetIOS } from 'react-native'; | |
export default ActionSheetIOS; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment