Skip to content

Commit

Permalink
replace call-sites inside ALert.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sasurau4 committed May 23, 2019
1 parent b6dca5b commit 2b5b22f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 7 additions & 1 deletion Libraries/Alert/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ class Alert {
);

const callback = type;
if (!RCTAlertManager) {
return;
}
RCTAlertManager.alertWithArgs(
{
title: title || '',
type: 'plain-text',
defaultValue: message,
defaultValue: message || '',
},
(id, value) => {
callback(value);
Expand Down Expand Up @@ -160,6 +163,9 @@ class Alert {
});
}
if (!RCTAlertManager) {
return;
}
RCTAlertManager.alertWithArgs(
{
title: title || '',
Expand Down
13 changes: 8 additions & 5 deletions Libraries/Alert/NativeAlertManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import type {TurboModule} from 'RCTExport';
import * as TurboModuleRegistry from 'TurboModuleRegistry';

type Button = {|
text: string,
onPress: () => void,
style: string,
text?: string,
onPress?: () => void,
style?: string,
|};

type Args = {|
title: string,
message?: string,
buttons: Array<Button>,
buttons?: Array<Button>,
type?: string,
defaultValue?: string,
cancelButtonKey?: string,
Expand All @@ -28,7 +28,10 @@ type Args = {|
|};

export interface Spec extends TurboModule {
+alertWithArgs: (args: Args, callback: () => void) => void;
+alertWithArgs: (
args: Args,
callback: (id: number, value: string) => void,
) => void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('AlertManager');

0 comments on commit 2b5b22f

Please sign in to comment.