Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,36 @@ public void onClick(DialogInterface dialog, int which) {
task.success(false);
}
});

alertBuilder.create().show();
}
});
});
}


public static void prompt(final ForgeTask task, @ForgeParam("title") final String title, @ForgeParam("body") final String body) {
task.performUI(new Runnable() {
@Override
public void run() {
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(ForgeApp.getActivity());
alertBuilder.setTitle(title);
alertBuilder.setMessage(body);

final EditText input = new EditText(this);
alertBuilder.setView(input);

alertBuilder.setCancelable(false);
alertBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
task.success(input.getText());
}
});

alertBuilder.create().show();
}
});
}

public static void toast(final ForgeTask task, @ForgeParam("body") final String body) {
task.performUI(new Runnable() {
@Override
Expand Down
11 changes: 11 additions & 0 deletions inspector/ios-inspector/ForgeModule/notification_API.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ + (void)confirm:(ForgeTask*)task title:(NSString*)title body:(NSString*)body pos
[[[UIAlertView alloc] initWithTitle:title message:body cancelButtonItem:negativeBtn otherButtonItems:positiveBtn, nil] show];
}

+ (void)prompt:(ForgeTask*)task title:(NSString*)title body:(NSString*)body {
RIButtonItem *ok = [RIButtonItem item];
ok.label = @"OK";
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:body cancelButtonItem:ok otherButtonItems:nil];
UITextField *input = [alertView textFieldAtIndex:0];
ok.action = ^{
[task success:input.text];
};
[alertView show];
}

+ (void)toast:(ForgeTask*)task body:(NSString*)body {
[PCToastMessage toastWithDuration:5.0 andText:body inView:[[[ForgeApp sharedApp] viewController] view]];
[task success:nil];
Expand Down
6 changes: 6 additions & 0 deletions module/javascript/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ forge['notification'] = {
negative: negative
}, success, error);
},
'prompt': function (title, body, success, error) {
forge.internal.call("notification.prompt", {
title: title,
body: body
}, success, error);
},
'toast': function (body, success, error) {
forge.internal.call("notification.toast", {
body: body
Expand Down