Skip to content

Commit

Permalink
feat(action-sheet): Make title optional (#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Mar 1, 2022
1 parent bfa2a38 commit 2018f78
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ public void setupDialog(Dialog dialog, int style) {
LinearLayout layout = new LinearLayout(getContext());
layout.setOrientation(LinearLayout.VERTICAL);
layout.setPadding(layoutPaddingPx16, layoutPaddingPx16, layoutPaddingPx16, layoutPaddingPx16);
TextView ttv = new TextView(getContext());
ttv.setTextColor(Color.parseColor("#757575"));
ttv.setPadding(layoutPaddingPx8, layoutPaddingPx8, layoutPaddingPx8, layoutPaddingPx8);
ttv.setText(title);
layout.addView(ttv);
if (title != null) {
TextView ttv = new TextView(getContext());
ttv.setTextColor(Color.parseColor("#757575"));
ttv.setPadding(layoutPaddingPx8, layoutPaddingPx8, layoutPaddingPx8, layoutPaddingPx8);
ttv.setText(title);
layout.addView(ttv);
}

for (int i = 0; i < options.length; i++) {
final int optionIndex = i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ public class ActionSheetPlugin extends Plugin {
public void showActions(final PluginCall call) {
String title = call.getString("title");
JSArray options = call.getArray("options");
if (title == null) {
call.reject("Must supply a title");
return;
}
if (options == null) {
call.reject("Must supply options");
return;
Expand Down
2 changes: 1 addition & 1 deletion action-sheet/ios/Plugin/ActionSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import UIKit

@objc public class ActionSheet: NSObject {

@objc public func buildActionSheet(title: String, message: String, actions: [UIAlertAction]) -> UIAlertController {
@objc public func buildActionSheet(title: String?, message: String?, actions: [UIAlertAction]) -> UIAlertController {
let controller = UIAlertController(title: title, message: message, preferredStyle: .actionSheet)
for action in actions {
controller.addAction(action)
Expand Down
7 changes: 2 additions & 5 deletions action-sheet/ios/Plugin/ActionSheetPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ public class ActionSheetPlugin: CAPPlugin {
private let implementation = ActionSheet()

@objc func showActions(_ call: CAPPluginCall) {
guard let title = call.options["title"] as? String else {
call.reject("title must be provided")
return
}
let message = call.options["message"] as? String ?? ""
let title = call.options["title"] as? String
let message = call.options["message"] as? String

let options = call.getArray("options", JSObject.self) ?? []
var alertActions = [UIAlertAction]()
Expand Down
2 changes: 1 addition & 1 deletion action-sheet/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface ShowActionsOptions {
*
* @since 1.0.0
*/
title: string;
title?: string;

/**
* A message to show under the title.
Expand Down

0 comments on commit 2018f78

Please sign in to comment.