Skip to content

Commit

Permalink
Re-added the UI dispatcher component for Android and Windows (iOS to …
Browse files Browse the repository at this point in the history
…come) and re-added the app dialog service.
  • Loading branch information
jamesmcroft committed Jul 15, 2018
1 parent 54e59ae commit 9482d16
Show file tree
Hide file tree
Showing 22 changed files with 1,194 additions and 12 deletions.
412 changes: 412 additions & 0 deletions MADE.App.Views.Dialogs/AppDialog.cs

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions MADE.App.Views.Dialogs/Buttons/DialogButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DialogButton.cs" company="MADE Apps">
// Copyright (c) MADE Apps.
// </copyright>
// <summary>
// Defines a button to be used within a application system alert dialog.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace MADE.App.Views.Dialogs.Buttons
{
/// <summary>
/// Defines a button to be used within a application system alert dialog.
/// </summary>
public class DialogButton
{
/// <summary>
/// Initializes a new instance of the <see cref="DialogButton"/> class.
/// </summary>
/// <param name="type">
/// The type of button.
/// </param>
public DialogButton(DialogButtonType type)
{
this.Type = type;
}

/// <summary>
/// Initializes a new instance of the <see cref="DialogButton"/> class with content text.
/// </summary>
/// <param name="type">
/// The type of button.
/// </param>
/// <param name="content">
/// The content text to display on the button.
/// </param>
public DialogButton(DialogButtonType type, string content)
{
this.Type = type;
this.Content = content;
}

/// <summary>
/// Initializes a new instance of the <see cref="DialogButton"/> class with content text and an invoke action.
/// </summary>
/// <param name="type">
/// The type of button.
/// </param>
/// <param name="content">
/// The content text to display on the button.
/// </param>
/// <param name="invokeAction">
/// The action to perform when the button is invoked.
/// </param>
public DialogButton(DialogButtonType type, string content, DialogButtonInvokedHandler invokeAction)
{
this.Type = type;
this.Content = content;
this.InvokeAction = invokeAction;
}

/// <summary>
/// Gets the type of button.
/// </summary>
public DialogButtonType Type { get; }

/// <summary>
/// Gets or sets the content text to display on the button.
/// </summary>
public string Content { get; set; }

/// <summary>
/// Gets or sets the action to perform when the button is invoked.
/// </summary>
public DialogButtonInvokedHandler InvokeAction { get; set; }

/// <summary>
/// Invokes the specified <see cref="InvokeAction"/>.
/// </summary>
public void Invoke()
{
this.InvokeAction?.Invoke(this);
}
}
}
19 changes: 19 additions & 0 deletions MADE.App.Views.Dialogs/Buttons/DialogButtonInvokedHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DialogButtonInvokedHandler.cs" company="MADE Apps">
// Copyright (c) MADE Apps.
// </copyright>
// <summary>
// The event handler for handling when a dialog button has been invoked.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace MADE.App.Views.Dialogs.Buttons
{
/// <summary>
/// The event handler for handling when a dialog button has been invoked.
/// </summary>
/// <param name="button">
/// The button.
/// </param>
public delegate void DialogButtonInvokedHandler(DialogButton button);
}
32 changes: 32 additions & 0 deletions MADE.App.Views.Dialogs/Buttons/DialogButtonType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DialogButtonType.cs" company="MADE Apps">
// Copyright (c) MADE Apps.
// </copyright>
// <summary>
// Defines values associated with the type of a dialog button.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace MADE.App.Views.Dialogs.Buttons
{
/// <summary>
/// Defines values associated with the type of a dialog button.
/// </summary>
public enum DialogButtonType
{
/// <summary>
/// The button is neutral and can be used to perform any action.
/// </summary>
Neutral,

/// <summary>
/// The button is positive and can be used to perform positive actions, such as saving.
/// </summary>
Positive,

/// <summary>
/// The button is negative and can be used to perform negative actions, such as cancelling.
/// </summary>
Negative
}
}
190 changes: 190 additions & 0 deletions MADE.App.Views.Dialogs/IAppDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IAppDialog.cs" company="MADE Apps">
// Copyright (c) MADE Apps.
// </copyright>
// <summary>
// Defines an interface for handling application system alert dialogs.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace MADE.App.Views.Dialogs
{
using System;
using System.Threading.Tasks;

using MADE.App.Views.Dialogs.Buttons;

/// <summary>
/// Defines an interface for handling application system alert dialogs.
/// </summary>
public interface IAppDialog
{
/// <summary>
/// Shows an application system alert dialog with the specified message.
/// </summary>
/// <param name="message">
/// The message to display.
/// </param>
void Show(string message);

/// <summary>
/// Shows an application system alert dialog with the specified message and dialog buttons.
/// </summary>
/// <param name="message">
/// The message to display.
/// </param>
/// <param name="buttons">
/// The button definitions for performing actions.
/// </param>
void Show(string message, params DialogButton[] buttons);

/// <summary>
/// Shows an application system alert dialog with the specified message, cancellation action and dialog buttons.
/// </summary>
/// <param name="message">
/// The message to display.
/// </param>
/// <param name="cancelAction">
/// The action to perform when the dialog has been cancelled/dismissed.
/// </param>
/// <param name="buttons">
/// The button definitions for performing actions.
/// </param>
void Show(string message, Action cancelAction, params DialogButton[] buttons);

/// <summary>
/// Shows an application system alert dialog with the specified title and message.
/// </summary>
/// <param name="title">
/// The title to display.
/// </param>
/// <param name="message">
/// The message to display.
/// </param>
void Show(string title, string message);

/// <summary>
/// Shows an application system alert dialog with the specified title, message and dialog buttons.
/// </summary>
/// <param name="title">
/// The title to display.
/// </param>
/// <param name="message">
/// The message to display.
/// </param>
/// <param name="buttons">
/// The button definitions for performing actions.
/// </param>
void Show(string title, string message, params DialogButton[] buttons);

/// <summary>
/// Shows an application system alert dialog with the specified title, message, cancellation action and dialog buttons.
/// </summary>
/// <param name="title">
/// The title to display.
/// </param>
/// <param name="message">
/// The message to display.
/// </param>
/// <param name="cancelAction">
/// The action to perform when the dialog has been cancelled/dismissed.
/// </param>
/// <param name="buttons">
/// The button definitions for performing actions.
/// </param>
void Show(string title, string message, Action cancelAction, params DialogButton[] buttons);

/// <summary>
/// Shows an application system alert dialog with the specified message.
/// </summary>
/// <param name="message">
/// The message to display.
/// </param>
/// <returns>
/// An asynchronous operation.
/// </returns>
Task ShowAsync(string message);

/// <summary>
/// Shows an application system alert dialog with the specified message and dialog buttons.
/// </summary>
/// <param name="message">
/// The message to display.
/// </param>
/// <param name="buttons">
/// The button definitions for performing actions.
/// </param>
/// <returns>
/// An asynchronous operation.
/// </returns>
Task ShowAsync(string message, params DialogButton[] buttons);

/// <summary>
/// Shows an application system alert dialog with the specified message, cancellation action and dialog buttons.
/// </summary>
/// <param name="message">
/// The message to display.
/// </param>
/// <param name="cancelAction">
/// The action to perform when the dialog has been cancelled/dismissed.
/// </param>
/// <param name="buttons">
/// The button definitions for performing actions.
/// </param>
/// <returns>
/// An asynchronous operation.
/// </returns>
Task ShowAsync(string message, Action cancelAction, params DialogButton[] buttons);

/// <summary>
/// Shows an application system alert dialog with the specified title and message.
/// </summary>
/// <param name="title">
/// The title to display.
/// </param>
/// <param name="message">
/// The message to display.
/// </param>
/// <returns>
/// An asynchronous operation.
/// </returns>
Task ShowAsync(string title, string message);

/// <summary>
/// Shows an application system alert dialog with the specified title, message and dialog buttons.
/// </summary>
/// <param name="title">
/// The title to display.
/// </param>
/// <param name="message">
/// The message to display.
/// </param>
/// <param name="buttons">
/// The button definitions for performing actions.
/// </param>
/// <returns>
/// An asynchronous operation.
/// </returns>
Task ShowAsync(string title, string message, params DialogButton[] buttons);

/// <summary>
/// Shows an application system alert dialog with the specified title, message, cancellation action and dialog buttons.
/// </summary>
/// <param name="title">
/// The title to display.
/// </param>
/// <param name="message">
/// The message to display.
/// </param>
/// <param name="cancelAction">
/// The action to perform when the dialog has been cancelled/dismissed.
/// </param>
/// <param name="buttons">
/// The button definitions for performing actions.
/// </param>
/// <returns>
/// An asynchronous operation.
/// </returns>
Task ShowAsync(string title, string message, Action cancelAction, params DialogButton[] buttons);
}
}
Loading

0 comments on commit 9482d16

Please sign in to comment.