Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing XML Docs #3083

Merged
merged 2 commits into from
Feb 24, 2024
Merged
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
11 changes: 11 additions & 0 deletions src/Maui/Prism.Maui/AppModel/IApplicationLifecycleAware.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
namespace Prism.AppModel;


/// <summary>
/// Defines methods for responding to application lifecycle events.
/// </summary>
public interface IApplicationLifecycleAware
{
/// <summary>
/// Called when the application resumes from a suspended state.
/// </summary>
void OnResume();

/// <summary>
/// Called when the application enters a sleep or suspended state.
/// </summary>
void OnSleep();
}
10 changes: 10 additions & 0 deletions src/Maui/Prism.Maui/AppModel/IPageLifecycleAware.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
namespace Prism.AppModel;

/// <summary>
/// Interface that defines lifecycle events for pages.
/// </summary>
public interface IPageLifecycleAware
{
/// <summary>
/// Called when the page is appearing.
/// </summary>
void OnAppearing();

/// <summary>
/// Called when the page is disappearing.
/// </summary>
void OnDisappearing();
}
4 changes: 4 additions & 0 deletions src/Maui/Prism.Maui/Behaviors/MultiPageActiveAwareBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

namespace Prism.Behaviors;

/// <summary>
/// Provides behaviors for types of <see cref="MultiPage{T}"/>
/// </summary>
/// <typeparam name="T">The typeof <see cref="Page"/>.</typeparam>
public class MultiPageActiveAwareBehavior<T> : BehaviorBase<MultiPage<T>> where T : Page
{
/// <inheritDoc/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using System.ComponentModel;
using Prism.Common;
using Prism.Extensions;
using PropertyChangingEventArgs = Microsoft.Maui.Controls.PropertyChangingEventArgs;

namespace Prism.Behaviors;

/// <summary>
/// Provides activation and deactivation for <see cref="IActiveAware"/> ViewModels that may be set as the CurrentPage.
/// </summary>
public class NavigationPageActiveAwareBehavior : BehaviorBase<NavigationPage>
{
/// <inheritDoc/>
protected override void OnAttachedTo(NavigationPage bindable)
{
bindable.PropertyChanged += NavigationPage_PropertyChanged;
Expand All @@ -21,6 +24,7 @@ private void OnParentChanged(object sender, EventArgs e)
SetActiveAware();
}

/// <inheritDoc/>
protected override void OnDetachingFrom(NavigationPage bindable)
{
bindable.PropertyChanged -= NavigationPage_PropertyChanged;
Expand Down
5 changes: 5 additions & 0 deletions src/Maui/Prism.Maui/Behaviors/PageLifeCycleAwareBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@

namespace Prism.Behaviors;

/// <summary>
/// Provides lifecycle events for <see cref="Page"/> and <see cref="IPageLifecycleAware"/> ViewModels.
/// </summary>
public class PageLifeCycleAwareBehavior : BehaviorBase<Page>
{
/// <inheritdoc />
protected override void OnAttachedTo(Page bindable)
{
base.OnAttachedTo(bindable);
bindable.Appearing += OnAppearing;
bindable.Disappearing += OnDisappearing;
}

/// <inheritdoc />
protected override void OnDetachingFrom(Page bindable)
{
base.OnDetachingFrom(bindable);
Expand Down
2 changes: 2 additions & 0 deletions src/Maui/Prism.Maui/Behaviors/PageScopeBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ namespace Prism.Behaviors;
/// </summary>
public sealed class PageScopeBehavior : BehaviorBase<Page>
{
/// <inheritdoc />
protected override void OnAttachedTo(Page page)
{
base.OnAttachedTo(page);
// Ensure the scope gets created and NavigationService is created
Navigation.Xaml.Navigation.GetNavigationService(page);
}

/// <inheritdoc />
protected override void OnDetachingFrom(Page page)
{
base.OnDetachingFrom(page);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Prism.Behaviors;

/// <summary>
/// Provides <see cref="IActiveAware"/> support for the children of the <see cref="TabbedPage"/>
/// </summary>
public class TabbedPageActiveAwareBehavior : MultiPageActiveAwareBehavior<Page>
{
}
15 changes: 13 additions & 2 deletions src/Maui/Prism.Maui/Dialogs/DialogViewRegistry.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
using Prism.Ioc;
using Prism.Mvvm;
using Prism.Mvvm;

namespace Prism.Dialogs;

/// <summary>
/// Implementation of a view registry specifically for dialog views.
/// </summary>
public class DialogViewRegistry : ViewRegistryBase, IDialogViewRegistry
{
/// <summary>
/// Initializes a new instance of the <see cref="DialogViewRegistry"/> class with the specified view registrations.
/// </summary>
/// <param name="registrations">The collection of view registrations to manage.</param>
public DialogViewRegistry(IEnumerable<ViewRegistration> registrations)
: base(ViewType.Dialog, registrations)
{
}

/// <summary>
/// Configures a dialog view with the specified context and container provider.
/// </summary>
/// <param name="bindable">The bindable object representing the dialog view to configure.</param>
/// <param name="container">The container provider to use for resolving dependencies.</param>
protected override void ConfigureView(BindableObject bindable, IContainerProvider container)
{
}
Expand Down
3 changes: 3 additions & 0 deletions src/Maui/Prism.Maui/Dialogs/IDialogViewRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Prism.Dialogs;

/// <summary>
/// Interface that defines a registry for managing views specific to dialogs.
/// </summary>
public interface IDialogViewRegistry : IViewRegistry
{
}
9 changes: 9 additions & 0 deletions src/Maui/Prism.Maui/Dialogs/KnownDialogParameters.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@

namespace Prism.Dialogs;

/// <summary>
/// Provides well-known parameter names used for configuring dialogs.
/// </summary>
public static class KnownDialogParameters
{
/// <summary>
/// Parameter name used to control whether a dialog should close when the background is tapped.
/// </summary>
public const string CloseOnBackgroundTapped = "closeOnBackgroundTapped";

/// <summary>
/// Parameter name used to pass additional custom parameters to a dialog.
/// </summary>
public const string XamlParam = "xamlParam";
}
104 changes: 98 additions & 6 deletions src/Maui/Prism.Maui/Dialogs/Xaml/DialogLayout.cs
Original file line number Diff line number Diff line change
@@ -1,78 +1,170 @@
namespace Prism.Dialogs.Xaml;
namespace Prism.Dialogs.Xaml;

/// <summary>
/// Provides attached properties for customizing the layout and behavior of dialogs in .NET MAUI.
/// </summary>
public static class DialogLayout
{
/// <summary>
/// Gets the key for specifying or retrieving popup overlay style from Application Resources.
/// </summary>
public const string PopupOverlayStyle = "PrismDialogMaskStyle";

/// <summary>
/// Attached property that specifies the desired relative width of the dialog.
/// </summary>
public static readonly BindableProperty RelativeWidthRequestProperty =
BindableProperty.CreateAttached("RelativeWidthRequest", typeof(double?), typeof(DialogLayout), null);

/// <summary>
/// Gets the value of the RelativeWidthRequest attached property from the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to get the property value from.</param>
/// <returns>The value of the RelativeWidthRequest property, or null if not set.</returns>
public static double? GetRelativeWidthRequest(BindableObject bindable) =>
(double?)bindable.GetValue(RelativeWidthRequestProperty);

/// <summary>
/// Sets the value of the RelativeWidthRequest attached property on the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to set the property value on.</param>
/// <param name="value">The desired relative width of the dialog.</param>
public static void SetRelativeWidthRequest(BindableObject bindable, double? value) =>
bindable.SetValue(RelativeWidthRequestProperty, value);

/// <summary>
/// Attached property that specifies the desired relative height of the dialog.
/// </summary>
public static readonly BindableProperty RelativeHeightRequestProperty =
BindableProperty.CreateAttached("RelativeHeightRequest", typeof(double?), typeof(DialogLayout), null);

/// <summary>
/// Gets the value of the RelativeHeightRequest attached property from the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to get the property value from.</param>
/// <returns>The value of the RelativeHeightRequest property, or null if not set.</returns>
public static double? GetRelativeHeightRequest(BindableObject bindable) =>
(double?)bindable.GetValue(RelativeHeightRequestProperty);

/// <summary>
/// Sets the value of the RelativeHeightRequest attached property on the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to set the property value on.</param>
/// <param name="value">The desired relative height of the dialog.</param>
public static void SetRelativeHeightRequest(BindableObject bindable, double? value) =>
bindable.SetValue(RelativeHeightRequestProperty, value);

/// <summary>
/// Attached property that specifies the layout bounds of the dialog within its parent.
/// </summary>
public static readonly BindableProperty LayoutBoundsProperty =
BindableProperty.CreateAttached("LayoutBounds", typeof(Rect), typeof(DialogLayout), new Rect(0.5, 0.5, -1, -1));

/// <summary>
/// Gets the value of the LayoutBounds attached property from the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to get the property value from.</param>
/// <returns>The layout bounds of the dialog.</returns>
public static Rect GetLayoutBounds(BindableObject bindable) =>
(Rect)bindable.GetValue(LayoutBoundsProperty);

/// <summary>
/// Sets the value of the LayoutBounds attached property on the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to set the property value on.</param>
/// <param name="value">The desired layout bounds for the dialog.</param>
public static void SetLayoutBounds(BindableObject bindable, Rect value) =>
bindable.SetValue(LayoutBoundsProperty, value);

/// <summary>
/// Attached property that specifies the style to apply to the dialog mask (background overlay).
/// </summary>
public static readonly BindableProperty MaskStyleProperty =
BindableProperty.CreateAttached("MaskStyle", typeof(Style), typeof(DialogLayout), null);

/// <summary>
/// Gets the style applied to the dialog mask (background overlay) from the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to get the mask style from.</param>
/// <returns>The style applied to the dialog mask, or null if not set.</returns>
public static Style GetMaskStyle(BindableObject bindable) =>
(Style)bindable.GetValue(MaskStyleProperty);

/// <summary>
/// Sets the style to be applied to the dialog mask (background overlay) on the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to set the mask style on.</param>
/// <param name="value">The style to apply to the dialog mask.</param>
public static void SetMaskStyle(BindableObject bindable, Style value) =>
bindable.SetValue(MaskStyleProperty, value);

/// <summary>
/// Attached property that specifies the View to be used as the dialog mask (background overlay).
/// </summary>
public static readonly BindableProperty MaskProperty =
BindableProperty.CreateAttached("Mask", typeof(View), typeof(DialogLayout), null);

/// <summary>
/// Gets the View used as the dialog mask (background overlay) from the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to get the mask view from.</param>
/// <returns>The View used as the dialog mask, or null if not set.</returns>
public static View GetMask(BindableObject bindable) =>
(View)bindable.GetValue(MaskProperty);

/// <summary>
/// Sets the View to be used as the dialog mask (background overlay) on the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to set the mask view on.</param>
/// <param name="value">The View to use as the dialog mask.</param>
public static void SetMask(BindableObject bindable, View value) =>
bindable.SetValue(MaskProperty, value);

/// <summary>
/// Attached property that specifies whether a dialog should use a mask (background overlay).
/// </summary>
public static readonly BindableProperty UseMaskProperty =
BindableProperty.CreateAttached("UseMask", typeof(bool?), typeof(DialogLayout), null);

/// <summary>
/// Gets whether a mask is used for the dialog from the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to get the mask usage from.</param>
/// <returns>True if a mask is used for the dialog, false if not, or null if not explicitly set.</returns>
public static bool? GetUseMask(BindableObject bindable)
{
var value = bindable.GetValue(UseMaskProperty);
if (value is bool boolean)
return boolean;

return true;
// Default to using a mask if not explicitly set
return bindable.GetValue(UseMaskProperty) is bool boolean ? boolean : true;
}

/// <summary>
/// Sets whether a mask should be used for the dialog on the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to set the mask usage on.</param>
/// <param name="value">True to use a mask for the dialog, false to not use a mask, or null to use the default behavior.</param>
public static void SetUseMask(BindableObject bindable, bool? value) =>
bindable.SetValue(UseMaskProperty, value);

/// <summary>
/// Attached property that specifies whether the dialog should close when the background is tapped.
/// </summary>
public static readonly BindableProperty CloseOnBackgroundTappedProperty =
BindableProperty.CreateAttached("CloseOnBackgroundTapped", typeof(bool?), typeof(DialogLayout), null);

/// <summary>
/// Gets whether the dialog closes when the background is tapped from the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to get the close-on-background-tap behavior from.</param>
/// <returns>True if the dialog closes on background tap, false if not, or null if not explicitly set.</returns>
public static bool? GetCloseOnBackgroundTapped(BindableObject bindable) =>
(bool?)bindable.GetValue(CloseOnBackgroundTappedProperty);

/// <summary>
/// Sets whether the dialog should close when the background is tapped on the specified BindableObject.
/// </summary>
/// <param name="bindable">The BindableObject to set the close-on-background-tap behavior on.</param>
/// <param name="value">True to close the dialog on background tap, false to not close on background tap, or null to use the default behavior.</param>
public static void SetCloseOnBackgroundTapped(BindableObject bindable, bool? value) =>
bindable.SetValue(CloseOnBackgroundTappedProperty, value);

}
Loading
Loading