Skip to content

Commit e15e32f

Browse files
Merge branch 'master' into patch-1
2 parents 2b423da + c449bee commit e15e32f

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

DropdownAlert.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ export default class DropdownAlert extends Component {
131131
inactiveStatusBarStyle: StatusBarDefaultBarStyle,
132132
inactiveStatusBarBackgroundColor: StatusBarDefaultBackgroundColor,
133133
updateStatusBar: true,
134-
useNativeDriver: IS_IOS,
135134
isInteraction: undefined,
135+
useNativeDriver: true,
136136
elevation: 1,
137137
zIndex: null,
138138
sensitivity: 20,
@@ -158,6 +158,7 @@ export default class DropdownAlert extends Component {
158158
startDelta: props.startDelta,
159159
endDelta: props.endDelta,
160160
topValue: 0,
161+
payload: {},
161162
};
162163
this.types = {
163164
INFO: 'info',
@@ -174,6 +175,9 @@ export default class DropdownAlert extends Component {
174175
if (this._closeTimeoutId != null) {
175176
clearTimeout(this._closeTimeoutId);
176177
}
178+
if (this.state.isOpen) {
179+
this.closeDirectly();
180+
}
177181
}
178182
createPanResponder = () => {
179183
this._panResponder = PanResponder.create({
@@ -204,7 +208,7 @@ export default class DropdownAlert extends Component {
204208
},
205209
});
206210
};
207-
alertWithType = (type, title, message, interval) => {
211+
alertWithType = (type, title, message, payload, interval) => {
208212
if (validateType(type) == false) {
209213
return;
210214
}
@@ -221,6 +225,7 @@ export default class DropdownAlert extends Component {
221225
message: message,
222226
title: title,
223227
topValue: 0,
228+
payload: payload,
224229
});
225230
if (this.state.isOpen == false) {
226231
this.setState({
@@ -255,6 +260,7 @@ export default class DropdownAlert extends Component {
255260
title: title,
256261
isOpen: true,
257262
topValue: 0,
263+
payload: payload,
258264
});
259265
}
260266
self.animate(1);
@@ -271,6 +277,14 @@ export default class DropdownAlert extends Component {
271277
);
272278
}
273279
};
280+
resetStatusBarColor = () => {
281+
if (this.props.updateStatusBar) {
282+
if (IS_ANDROID) {
283+
StatusBar.setBackgroundColor(this.props.inactiveStatusBarBackgroundColor, true);
284+
}
285+
StatusBar.setBarStyle(this.props.inactiveStatusBarStyle, true);
286+
}
287+
}
274288
close = action => {
275289
if (action == undefined) {
276290
action = 'programmatic';
@@ -284,15 +298,11 @@ export default class DropdownAlert extends Component {
284298
clearTimeout(this._closeTimeoutId);
285299
}
286300
this.animate(0);
287-
if (this.props.updateStatusBar) {
288-
if (IS_ANDROID) {
289-
StatusBar.setBackgroundColor(this.props.inactiveStatusBarBackgroundColor, true);
290-
}
291-
StatusBar.setBarStyle(this.props.inactiveStatusBarStyle, true);
292-
}
301+
this.resetStatusBarColor();
293302
setTimeout(
294303
function() {
295304
if (this.state.isOpen) {
305+
this.resetStatusBarColor();
296306
this.setState({
297307
isOpen: false,
298308
});
@@ -302,6 +312,7 @@ export default class DropdownAlert extends Component {
302312
title: this.state.title,
303313
message: this.state.message,
304314
action: action, // !!! How the alert was closed: automatic, programmatic, tap, pan or cancel
315+
payload: this.state.payload,
305316
};
306317
onClose(data);
307318
}
@@ -319,12 +330,7 @@ export default class DropdownAlert extends Component {
319330
this.setState({
320331
isOpen: false,
321332
});
322-
if (this.props.updateStatusBar) {
323-
if (IS_ANDROID) {
324-
StatusBar.setBackgroundColor(this.props.inactiveStatusBarBackgroundColor, true);
325-
}
326-
StatusBar.setBarStyle(this.props.inactiveStatusBarStyle, true);
327-
}
333+
this.resetStatusBarColor();
328334
}
329335
}
330336
animate = toValue => {

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export default class App extends Component {
7171
* [DropdownHolder example #1](https://gist.github.com/testshallpass/d76c656874e417bef4e0e6a63fc492af)
7272
* [DropdownHolder example #2](https://gist.github.com/testshallpass/6c6c867269348c485a1e0d6ae3f55e90)
7373
* [Redux + router flux example](https://gist.github.com/testshallpass/13f047205d1b966f55340b8962fe99c0)
74+
* Repo: [react-native-dropdownalert-router-sample](https://github.com/mitsuruog/react-native-dropdownalert-router-sample) Thanks @mitsuruog and @articolo
7475

7576
### Props
7677

index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export interface DropdownAlertProps {
6868
type: DropdownAlertType,
6969
title: string,
7070
message: string,
71-
interval?: number
71+
payload?: object,
72+
interval?: number,
7273
): void
7374
}

0 commit comments

Comments
 (0)