Open jm-parent opened 4 years ago
Can you include a use case?
@ske66 Sometimes it's useful because you can have confirm button in the top or in the middle of view with some specific UI. But I guess it's need separate API for such case because we need anyway to handle somehow setting of positive/negative answer. Something like this:
Current method, Confirm and Dismiss (if needed) button are present:
Task<bool?> ShowCustomContentAsync (View view, string message, string title = null, string confirmingText = "Ok", string dismissiveText = "Cancel", MaterialAlertDialogConfiguration configuration = null);
New method, no buttons, only TaskTask<bool?> ShowCustomContentAsync (View view, Task<bool> onCompletedTask, string message, string title = null, MaterialAlertDialogConfiguration configuration = null);
var completionTcs = new TaskCompletionSource<bool>();
var result = await ShowCustomContentAsync(new CustomView(completionTcs), completionTcs.Task,...);
We also can make a constraint to say that only View should implement this callback:
Task<bool?> ShowCustomContentAsync<TView>(TView view, string message, string title = null, MaterialAlertDialogConfiguration configuration = null) where TView : View, ICompletable;
Interface also can be implemented in several ways:
public interface ICompletable { EventHandler<bool> OnCompleted }
public interface ICompletable { Task<bool> OnCompletedTask { get; } }
🏗 Enhancement Proposal
Allowing MaterialDialog.Instance.ShowCustomContentAsync() to set confirmingText = Null , to hide the confirming Button.
The same way as dismissiveText do.
You can remove the negative button by passing null to the dismissiveText parameter.
Optional : Create MaterialDialog.Instance.ShowCustomContentAlertDialogAsync() , same as ShowCustomContentAsync , without buttons ;)
Pitch
Custom "ConfirmDialogs" are great. But Custom Alert Dialog are great too 🤙