diff --git a/src/Controls/src/Core/Page/Page.cs b/src/Controls/src/Core/Page/Page.cs index 3f690538fdce..510eddce4fb3 100644 --- a/src/Controls/src/Core/Page/Page.cs +++ b/src/Controls/src/Core/Page/Page.cs @@ -56,6 +56,7 @@ public partial class Page : VisualElement, ILayout, IPageController, IElementCon public static readonly BindableProperty BackgroundImageSourceProperty = BindableProperty.Create(nameof(BackgroundImageSource), typeof(ImageSource), typeof(Page), default(ImageSource)); /// Bindable property for . + [Obsolete("Page.IsBusy has been deprecated and will be removed in .NET 11")] public static readonly BindableProperty IsBusyProperty = BindableProperty.Create(nameof(IsBusy), typeof(bool), typeof(Page), false, propertyChanged: (bo, o, n) => ((Page)bo).OnPageBusyChanged()); /// Bindable property for . @@ -128,6 +129,7 @@ public ImageSource IconImageSource /// /// Setting to on multiple pages at once will cause the global activity indicator to run until all are set back to . It is the developer's responsibility to unset the flag before cleaning up a page. /// + [Obsolete("Page.IsBusy has been deprecated and will be removed in .NET 11")] public bool IsBusy { get { return (bool)GetValue(IsBusyProperty); } @@ -655,6 +657,7 @@ public void SendAppearing() _hasAppeared = true; +#pragma warning disable CS0618 // TODO: Remove this API in .NET 11. Issue Link: https://github.com/dotnet/maui/issues/30155 if (IsBusy) { if (IsPlatformEnabled) @@ -662,6 +665,7 @@ public void SendAppearing() else _pendingActions.Add(() => Window.AlertManager.RequestPageBusy(this, true)); } +#pragma warning restore CS0618 // Type or member is obsolete OnAppearing(); Appearing?.Invoke(this, EventArgs.Empty); @@ -684,8 +688,10 @@ public void SendDisappearing() _hasAppeared = false; +#pragma warning disable CS0618 // TODO: Remove this API in .NET 11. Issue Link: https://github.com/dotnet/maui/issues/30155 if (IsBusy) Window.AlertManager.RequestPageBusy(this, false); +#pragma warning restore CS0618 // Type or member is obsolete var pageContainer = this as IPageContainer; pageContainer?.CurrentPage?.SendDisappearing(); @@ -746,7 +752,9 @@ void OnPageBusyChanged() { if (!_hasAppeared) return; +#pragma warning disable CS0618 // TODO: Remove this API in .NET 11. Issue Link: https://github.com/dotnet/maui/issues/30155 Window.AlertManager.RequestPageBusy(this, IsBusy); +#pragma warning restore CS0618 // Type or member is obsolete } void OnToolbarItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) diff --git a/src/Controls/src/Core/Platform/AlertManager/AlertManager.Android.cs b/src/Controls/src/Core/Platform/AlertManager/AlertManager.Android.cs index 0d6a4961c941..c2079e7ca66a 100644 --- a/src/Controls/src/Core/Platform/AlertManager/AlertManager.Android.cs +++ b/src/Controls/src/Core/Platform/AlertManager/AlertManager.Android.cs @@ -44,6 +44,7 @@ internal AlertRequestHelper(Activity context, IMauiContext mauiContext) public IMauiContext MauiContext { get; } + // TODO: This method is obsolete in .NET 10 and will be removed in .NET11. public partial void OnPageBusy(Page sender, bool enabled) { // Verify that the page making the request is part of this activity diff --git a/src/Controls/src/Core/Platform/AlertManager/AlertManager.Standard.cs b/src/Controls/src/Core/Platform/AlertManager/AlertManager.Standard.cs index 6eeffec49b7b..f482979910a8 100644 --- a/src/Controls/src/Core/Platform/AlertManager/AlertManager.Standard.cs +++ b/src/Controls/src/Core/Platform/AlertManager/AlertManager.Standard.cs @@ -18,6 +18,7 @@ public partial void OnAlertRequested(Page sender, AlertArguments arguments) { } public partial void OnPromptRequested(Page sender, PromptArguments arguments) { } + // TODO: This method is obsolete in .NET 10 and will be removed in .NET 11. public partial void OnPageBusy(Page sender, bool enabled) { } } } diff --git a/src/Controls/src/Core/Platform/AlertManager/AlertManager.Windows.cs b/src/Controls/src/Core/Platform/AlertManager/AlertManager.Windows.cs index d48b2eb2cdba..c2daaba09c22 100644 --- a/src/Controls/src/Core/Platform/AlertManager/AlertManager.Windows.cs +++ b/src/Controls/src/Core/Platform/AlertManager/AlertManager.Windows.cs @@ -32,6 +32,7 @@ internal AlertRequestHelper(Window virtualView, UI.Xaml.Window platformView) public UI.Xaml.Window PlatformView { get; } + // TODO: This method is obsolete in .NET 10 and will be removed in .NET11. public partial void OnPageBusy(Page sender, bool enabled) { // TODO: Wrap the pages in a Canvas, and dynamically add a ProgressBar diff --git a/src/Controls/src/Core/Platform/AlertManager/AlertManager.cs b/src/Controls/src/Core/Platform/AlertManager/AlertManager.cs index b6d9c87db0ab..4b88d36cf7d9 100644 --- a/src/Controls/src/Core/Platform/AlertManager/AlertManager.cs +++ b/src/Controls/src/Core/Platform/AlertManager/AlertManager.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.DependencyInjection; +using System; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Maui.Controls.Internals; @@ -58,6 +59,7 @@ public void RequestAlert(Page page, AlertArguments arguments) => public void RequestPrompt(Page page, PromptArguments arguments) => _subscription?.OnPromptRequested(page, arguments); + [Obsolete("This method is obsolete in .NET 10 and will be removed in .NET11.")] public void RequestPageBusy(Page page, bool isBusy) => _subscription?.OnPageBusy(page, isBusy); @@ -71,6 +73,7 @@ internal interface IAlertManagerSubscription void OnPromptRequested(Page sender, PromptArguments arguments); + [Obsolete("This method is obsolete in .NET 10 and will be removed in .NET11.")] void OnPageBusy(Page sender, bool enabled); } @@ -82,6 +85,7 @@ internal partial class AlertRequestHelper : IAlertManagerSubscription public partial void OnPromptRequested(Page sender, PromptArguments arguments); + [Obsolete("This method is obsolete in .NET 10 and will be removed in .NET11.")] public partial void OnPageBusy(Page sender, bool enabled); } } diff --git a/src/Controls/src/Core/Platform/AlertManager/AlertManager.iOS.cs b/src/Controls/src/Core/Platform/AlertManager/AlertManager.iOS.cs index 08b0e89ba4e0..fae501b1516c 100644 --- a/src/Controls/src/Core/Platform/AlertManager/AlertManager.iOS.cs +++ b/src/Controls/src/Core/Platform/AlertManager/AlertManager.iOS.cs @@ -35,6 +35,7 @@ internal AlertRequestHelper(Window virtualView, UIWindow platformView) public UIWindow PlatformView { get; } + // TODO: This method is obsolete in .NET 10 and will be removed in .NET 11. public partial void OnPageBusy(Page sender, bool enabled) { _busyCount = Math.Max(0, enabled ? _busyCount + 1 : _busyCount - 1); diff --git a/src/Controls/tests/DeviceTests/Elements/Page/PageTests.cs b/src/Controls/tests/DeviceTests/Elements/Page/PageTests.cs index 458bb8836fea..a83300901f88 100644 --- a/src/Controls/tests/DeviceTests/Elements/Page/PageTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Page/PageTests.cs @@ -87,7 +87,9 @@ await CreateHandlerAndAddToWindow(page, async (handler) => public async Task UsingIsBusyNoCrash() { var page = new ContentPage(); +#pragma warning disable CS0618 // TODO: Remove this API in .NET 11. Issue Link: https://github.com/dotnet/maui/issues/30155 page.IsBusy = true; +#pragma warning restore CS0618 // Type or member is obsolete await CreateHandlerAndAddToWindow(page, (handler) => {