@exponent/react-native-action-sheet
Advanced tools
Comparing version 0.2.1 to 0.2.3
@@ -12,2 +12,3 @@ // @flow | ||
Text, | ||
Image, | ||
NativeModules, | ||
@@ -20,9 +21,8 @@ TouchableOpacity, | ||
// Not everybody has this enabled yet | ||
const useNativeDriver = !!NativeModules.NativeAnimatedModule; | ||
type ActionSheetOptions = { | ||
options: Array<string>, | ||
icons: ?Array<number>, | ||
destructiveButtonIndex: ?number, | ||
cancelButtonIndex: ?number, | ||
textStyle: ?any, | ||
} | ||
@@ -32,2 +32,3 @@ | ||
options: Array<string>, | ||
icons: ?Array<number>, | ||
destructiveButtonIndex: ?number, | ||
@@ -37,2 +38,3 @@ onSelect: (i: number) => boolean, | ||
length: number, | ||
textStyle: ?any, | ||
} | ||
@@ -51,2 +53,3 @@ | ||
children: ?any, | ||
useNativeDriver: ?boolean, | ||
} | ||
@@ -62,2 +65,3 @@ | ||
options: PropTypes.array.isRequired, | ||
icons: PropTypes.array, | ||
destructiveButtonIndex: PropTypes.number, | ||
@@ -67,2 +71,3 @@ onSelect: PropTypes.func.isRequired, | ||
length: PropTypes.number.isRequired, | ||
textStyle: Text.propTypes.style, | ||
}; | ||
@@ -73,2 +78,3 @@ | ||
options, | ||
icons, | ||
destructiveButtonIndex, | ||
@@ -78,2 +84,3 @@ onSelect, | ||
length, | ||
textStyle, | ||
} = this.props; | ||
@@ -94,2 +101,13 @@ | ||
let iconElement = undefined | ||
if (icons && icons[i]) { | ||
iconElement = ( | ||
<Image | ||
source={icons[i]} | ||
style={styles.icon} | ||
/> | ||
) | ||
} | ||
optionViews.push( | ||
@@ -102,3 +120,4 @@ <TouchableNativeFeedbackSafe | ||
style={styles.button}> | ||
<Text style={[styles.text, {color}]}> | ||
{iconElement} | ||
<Text style={[styles.text, {color}, textStyle]}> | ||
{options[i]} | ||
@@ -175,2 +194,3 @@ </Text> | ||
options={this.state.options.options} | ||
icons={this.state.options.icons} | ||
destructiveButtonIndex={this.state.options.destructiveButtonIndex} | ||
@@ -180,2 +200,3 @@ onSelect={this._onSelect} | ||
length={numOptions} | ||
textStyle={this.state.options.textStyle} | ||
/> | ||
@@ -212,3 +233,3 @@ </View> | ||
duration: OPACITY_ANIMATION_TIME, | ||
useNativeDriver, | ||
useNativeDriver: this.props.useNativeDriver, | ||
}), | ||
@@ -219,3 +240,3 @@ Animated.timing(this.state.sheetOpacity, { | ||
duration: OPACITY_ANIMATION_TIME, | ||
useNativeDriver, | ||
useNativeDriver: this.props.useNativeDriver, | ||
}), | ||
@@ -237,3 +258,3 @@ ]).start(result => { | ||
if (!this.state.options) { | ||
return; | ||
return false; | ||
} | ||
@@ -273,3 +294,3 @@ | ||
duration: OPACITY_ANIMATION_TIME, | ||
useNativeDriver, | ||
useNativeDriver: this.props.useNativeDriver, | ||
}), | ||
@@ -280,3 +301,3 @@ Animated.timing(this.state.sheetOpacity, { | ||
duration: OPACITY_ANIMATION_TIME, | ||
useNativeDriver, | ||
useNativeDriver: this.props.useNativeDriver, | ||
}), | ||
@@ -300,9 +321,9 @@ ]).start(result => { | ||
ActionSheet.defaultProps = { | ||
useNativeDriver: true | ||
}; | ||
let TouchableComponent; | ||
if (Platform.OS === 'android') { | ||
TouchableComponent = Platform.Version <= 20 ? TouchableOpacity : TouchableNativeFeedback; | ||
} else { | ||
TouchableComponent = TouchableOpacity; | ||
} | ||
TouchableComponent = Platform.Version <= 20 ? TouchableOpacity : TouchableNativeFeedback; | ||
@@ -351,10 +372,15 @@ if (TouchableComponent !== TouchableNativeFeedback) { | ||
button: { | ||
justifyContent: 'center', | ||
alignItems: 'flex-start', | ||
justifyContent: 'flex-start', | ||
alignItems: 'center', | ||
flexDirection: 'row', | ||
height: 50, | ||
paddingHorizontal: 16, | ||
}, | ||
icon: { | ||
marginRight: 15, | ||
}, | ||
text: { | ||
fontSize: 17, | ||
fontWeight: '700', | ||
textAlignVertical: 'center', | ||
}, | ||
@@ -361,0 +387,0 @@ rowSeparator: { |
{ | ||
"name": "@exponent/react-native-action-sheet", | ||
"version": "0.2.1", | ||
"version": "0.2.3", | ||
"description": "A cross-platform ActionSheet for React Native", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,2 +15,5 @@ # react-native-action-sheet [![Slack](http://slack.exponentjs.com/badge.svg)](http://slack.exponentjs.com) | ||
```js | ||
import ActionSheet from '@exponent/react-native-action-sheet'; | ||
// other imports.. | ||
class MainApp extends React.Component { | ||
@@ -41,2 +44,5 @@ | ||
```js | ||
import ActionSheet from '@exponent/react-native-action-sheet'; | ||
// other imports.. | ||
class OtherComponent extends React.Component { | ||
@@ -43,0 +49,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17382
10
372
68