Skip to content

Commit 5549e36

Browse files
authored
feat: Add destructiveColor option (expo#171)
1 parent b605fb8 commit 5549e36

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ The below props allow modification of the Android ActionSheet. They have no effe
121121
| showSeparators | boolean | No | false |
122122
| containerStyle | ViewStyle | No | |
123123
| separatorStyle | ViewStyle | No | |
124-
| useModal | boolean | No | false |
124+
| useModal | boolean | No | false |
125+
| destructiveColor | string | No | #d32f2f |
125126

126127
#### `icons` (optional)
127128

@@ -155,6 +156,9 @@ Modify the look of the separators rather than use the default look.
155156
#### `useModal`: (optional)
156157
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)).
157158

159+
#### `destructiveColor`: (optional)
160+
Modify color for text of destructive option.
161+
158162
## Try it out
159163

160164
Try it in Expo: https://expo.io/@community/react-native-action-sheet-example

src/ActionSheet/ActionGroup.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export default class ActionGroup extends React.Component<Props> {
107107
options,
108108
icons,
109109
destructiveButtonIndex,
110+
destructiveColor = DESTRUCTIVE_COLOR,
110111
onSelect,
111112
startIndex,
112113
length,
@@ -125,7 +126,7 @@ export default class ActionGroup extends React.Component<Props> {
125126
const defaultColor = tintColor
126127
? tintColor
127128
: (textStyle || {}).color || BLACK_87PC_TRANSPARENT;
128-
const color = i === destructiveButtonIndex ? DESTRUCTIVE_COLOR : defaultColor;
129+
const color = i === destructiveButtonIndex ? destructiveColor : defaultColor;
129130
const iconSource = icons != null ? icons[i] : null;
130131

131132
optionViews.push(

src/ActionSheet/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export default class ActionSheet extends React.Component<Props, State> {
107107
icons,
108108
tintIcons,
109109
destructiveButtonIndex,
110+
destructiveColor,
110111
textStyle,
111112
tintColor,
112113
title,
@@ -142,6 +143,7 @@ export default class ActionSheet extends React.Component<Props, State> {
142143
icons={icons}
143144
tintIcons={tintIcons === undefined ? true : tintIcons}
144145
destructiveButtonIndex={destructiveButtonIndex}
146+
destructiveColor={destructiveColor}
145147
onSelect={this._onSelect}
146148
startIndex={0}
147149
length={optionsArray.length}

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ export interface ActionSheetOptions extends ActionSheetIOSOptions {
2828
containerStyle?: ViewStyle;
2929
separatorStyle?: ViewStyle;
3030
useModal?: boolean;
31+
destructiveColor?: string;
3132
}

0 commit comments

Comments
 (0)