Compare commits

..
2 Commits
Author SHA1 Message Date
Colin Darie 39fc431c97 feat(android): allow customizing container styles (#142)
* Android: container style configurable (background)
* Add containerStyle prop description to readme
* Add containerStyle prop to example app
2019-11-18 22:12:18 -06:00
Hammad Jutt 76397fa7c4 feat: Allow pointerEvents prop to pass through to containing view (#124) 2019-11-18 21:41:57 -06:00
6 changed files with 28 additions and 5 deletions

No files matched your search

+4
View File
@@ -109,6 +109,7 @@ The below props allow modification of the Android ActionSheet. They have no effe
| titleTextStyle | TextStyle | No | |
| messageTextStyle | TextStyle | No | |
| showSeparators | boolean | No | false |
| containerStyle | ViewStyle | No | |
| separatorStyle | ViewStyle | No | |
#### `icons` (optional)
@@ -130,6 +131,9 @@ Apply any text style props to the message if present.
#### `showSeparators`: (optional)
Show separators between items. On iOS, separators always show so this prop has no effect.
#### `containerStyle`: (optional)
Apply any view style props to the container rather than use the default look (e.g. dark mode).
#### `separatorStyle`: (optional)
Modify the look of the separators rather than use the default look.
+10 -2
View File
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Text, View, TextStyle } from 'react-native';
import { Text, View, TextStyle, ViewStyle } from 'react-native';
import { MaterialIcons, Entypo } from '@expo/vector-icons';
import { ActionSheetOptions } from '@expo/react-native-action-sheet';
@@ -74,6 +74,12 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
textAlign: 'right',
}
: undefined;
const containerStyle: ViewStyle | undefined = withCustomStyles
? {
backgroundColor: 'lightgrey',
}
: undefined;
showActionSheetWithOptions(
{
options,
@@ -91,7 +97,9 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
// Android only
titleTextStyle,
// Android only
messageTextStyle, // Android only
messageTextStyle,
// Android only,
containerStyle,
},
buttonIndex => {
// Do something here depending on the button index selected
+1 -1
View File
@@ -25,7 +25,7 @@ export default class ActionGroup extends React.Component<Props> {
render() {
return (
<View style={styles.groupContainer}>
<View style={[styles.groupContainer, this.props.containerStyle]}>
{this._renderTitleContent()}
<ScrollView>{this._renderOptionViews()}</ScrollView>
</View>
+7 -2
View File
@@ -1,16 +1,21 @@
import * as React from 'react';
import { ActionSheetIOS, View } from 'react-native';
import { ActionSheetIOS, View, ViewProps } from 'react-native';
import { ActionSheetIOSOptions } from '../types';
interface Props {
readonly children: React.ReactNode;
readonly pointerEvents?: ViewProps['pointerEvents'];
}
type onSelect = (buttonIndex: number) => void;
export default class ActionSheet extends React.Component<Props> {
render() {
return <View style={{ flex: 1 }}>{React.Children.only(this.props.children)}</View>;
return (
<View pointerEvents={this.props.pointerEvents} style={{ flex: 1 }}>
{React.Children.only(this.props.children)}
</View>
);
}
showActionSheetWithOptions(options: ActionSheetIOSOptions, onSelect: onSelect) {
+5
View File
@@ -6,6 +6,7 @@ import {
StyleSheet,
TouchableWithoutFeedback,
View,
ViewProps,
} from 'react-native';
import ActionGroup from './ActionGroup';
import { ActionSheetOptions } from '../types';
@@ -21,6 +22,7 @@ interface State {
interface Props {
readonly useNativeDriver: boolean | undefined;
readonly pointerEvents?: ViewProps['pointerEvents'];
}
const OPACITY_ANIMATION_IN_TIME = 225;
@@ -64,6 +66,7 @@ export default class ActionSheet extends React.Component<Props, State> {
) : null;
return (
<View
pointerEvents={this.props.pointerEvents}
style={{
flex: 1,
}}>
@@ -93,6 +96,7 @@ export default class ActionSheet extends React.Component<Props, State> {
message,
messageTextStyle,
showSeparators,
containerStyle,
separatorStyle,
} = options;
return (
@@ -129,6 +133,7 @@ export default class ActionSheet extends React.Component<Props, State> {
message={message || undefined}
messageTextStyle={messageTextStyle}
showSeparators={showSeparators}
containerStyle={containerStyle}
separatorStyle={separatorStyle}
/>
</View>
+1
View File
@@ -23,5 +23,6 @@ export interface ActionSheetOptions extends ActionSheetIOSOptions {
titleTextStyle?: TextStyle;
messageTextStyle?: TextStyle;
showSeparators?: boolean;
containerStyle?: ViewStyle;
separatorStyle?: ViewStyle;
}