Skip to content

Commit

Permalink
feat: Add destructiveColor option (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilichev authored May 19, 2020
1 parent b605fb8 commit 5549e36
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ The below props allow modification of the Android ActionSheet. They have no effe
| showSeparators | boolean | No | false |
| containerStyle | ViewStyle | No | |
| separatorStyle | ViewStyle | No | |
| useModal | boolean | No | false |
| useModal | boolean | No | false |
| destructiveColor | string | No | #d32f2f |

#### `icons` (optional)

Expand Down Expand Up @@ -155,6 +156,9 @@ Modify the look of the separators rather than use the default look.
#### `useModal`: (optional)
Wrap the ActionSheet with a Modal, in order to show in front of other Modals that were already opened ([issue reference](https://github.com/expo/react-native-action-sheet/issues/164)).

#### `destructiveColor`: (optional)
Modify color for text of destructive option.

## Try it out

Try it in Expo: https://expo.io/@community/react-native-action-sheet-example
Expand Down
3 changes: 2 additions & 1 deletion src/ActionSheet/ActionGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default class ActionGroup extends React.Component<Props> {
options,
icons,
destructiveButtonIndex,
destructiveColor = DESTRUCTIVE_COLOR,
onSelect,
startIndex,
length,
Expand All @@ -125,7 +126,7 @@ export default class ActionGroup extends React.Component<Props> {
const defaultColor = tintColor
? tintColor
: (textStyle || {}).color || BLACK_87PC_TRANSPARENT;
const color = i === destructiveButtonIndex ? DESTRUCTIVE_COLOR : defaultColor;
const color = i === destructiveButtonIndex ? destructiveColor : defaultColor;
const iconSource = icons != null ? icons[i] : null;

optionViews.push(
Expand Down
2 changes: 2 additions & 0 deletions src/ActionSheet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default class ActionSheet extends React.Component<Props, State> {
icons,
tintIcons,
destructiveButtonIndex,
destructiveColor,
textStyle,
tintColor,
title,
Expand Down Expand Up @@ -142,6 +143,7 @@ export default class ActionSheet extends React.Component<Props, State> {
icons={icons}
tintIcons={tintIcons === undefined ? true : tintIcons}
destructiveButtonIndex={destructiveButtonIndex}
destructiveColor={destructiveColor}
onSelect={this._onSelect}
startIndex={0}
length={optionsArray.length}
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ export interface ActionSheetOptions extends ActionSheetIOSOptions {
containerStyle?: ViewStyle;
separatorStyle?: ViewStyle;
useModal?: boolean;
destructiveColor?: string;
}

0 comments on commit 5549e36

Please sign in to comment.