Skip to content

Commit 790463e

Browse files
committed
iOS Home Indicator hidden implemented
1 parent 7dbe853 commit 790463e

File tree

22 files changed

+108
-1
lines changed

22 files changed

+108
-1
lines changed

src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ bool shouldReceive(UIGestureRecognizer g, UITouch t)
198198

199199
UpdatePanGesture();
200200
UpdateApplyShadow(((FlyoutPage)Element).OnThisPlatform().GetApplyShadow());
201+
UpdatePrefersHomeIndicatorAutoHiddenOnDetailPage();
201202
}
202203

203204
public override void ViewWillTransitionToSize(CoreGraphics.CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
@@ -364,6 +365,8 @@ void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
364365
UpdateBackground();
365366
else if (e.PropertyName == PlatformConfiguration.iOSSpecific.FlyoutPage.ApplyShadowProperty.PropertyName)
366367
UpdateApplyShadow(((FlyoutPage)Element).OnThisPlatform().GetApplyShadow());
368+
else if (e.PropertyName == PlatformConfiguration.iOSSpecific.Page.PrefersHomeIndicatorAutoHiddenProperty.PropertyName)
369+
UpdatePrefersHomeIndicatorAutoHiddenOnDetailPage();
367370
}
368371

369372
void LayoutChildren(bool animated)
@@ -551,6 +554,7 @@ void UpdateFlyoutPageContainers()
551554
detailRenderer.ViewController.View.Superview.BackgroundColor = Microsoft.Maui.Graphics.Colors.Black.ToPlatform();
552555

553556
ToggleAccessibilityElementsHidden();
557+
UpdatePrefersHomeIndicatorAutoHiddenOnDetailPage();
554558
}
555559

556560
void UpdateLeftBarButton()
@@ -573,6 +577,13 @@ void UpdateApplyShadow(bool value)
573577
_applyShadow = value;
574578
}
575579

580+
void UpdatePrefersHomeIndicatorAutoHiddenOnDetailPage()
581+
{
582+
bool isHomeIndicatorHidden = ((FlyoutPage)Element).OnThisPlatform().PrefersHomeIndicatorAutoHidden();
583+
((FlyoutPage)Element).Detail.OnThisPlatform().SetPrefersHomeIndicatorAutoHidden(isHomeIndicatorHidden);
584+
ChildViewControllerForHomeIndicatorAutoHidden.SetNeedsUpdateOfHomeIndicatorAutoHidden();
585+
}
586+
576587
public override UIViewController ChildViewControllerForStatusBarHidden()
577588
{
578589
if (((FlyoutPage)Element).Detail?.Handler is IPlatformViewHandler nvh)

src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,10 @@ void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
498498
{
499499
UpdateHideNavigationBarSeparator();
500500
}
501+
else if (e.PropertyName == PrefersHomeIndicatorAutoHiddenProperty.PropertyName)
502+
{
503+
UpdateHomeIndicatorAutoHidden();
504+
}
501505
}
502506

503507
void ValidateNavbarExists(Page newCurrentPage)
@@ -508,6 +512,14 @@ void ValidateNavbarExists(Page newCurrentPage)
508512
View.InvalidateMeasure(Element);
509513
}
510514

515+
void UpdateHomeIndicatorAutoHidden()
516+
{
517+
if (Element == null)
518+
return;
519+
520+
SetNeedsUpdateOfHomeIndicatorAutoHidden();
521+
}
522+
511523
void UpdateHideNavigationBarSeparator()
512524
{
513525
bool shouldHide = NavPage.OnThisPlatform().HideNavigationBarSeparator();

src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellFlyoutRenderer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance)
4444

4545
UIViewController IShellFlyoutRenderer.ViewController => this;
4646

47+
public override bool PrefersHomeIndicatorAutoHidden => Detail.PrefersHomeIndicatorAutoHidden;
48+
4749
void IShellFlyoutRenderer.AttachFlyout(IShellContext context, UIViewController content)
4850
{
4951
Context = context;

src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellRenderer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.Extensions.Logging;
66
using Microsoft.Maui.Controls.Platform;
77
using Microsoft.Maui.Controls.Platform.Compatibility;
8+
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
89
using Microsoft.Maui.Graphics;
910
using UIKit;
1011

@@ -21,6 +22,9 @@ public ShellRenderer()
2122

2223
}
2324

25+
public override bool PrefersHomeIndicatorAutoHidden
26+
=> Shell?.CurrentPage?.OnThisPlatform()?.PrefersHomeIndicatorAutoHidden() ?? false;
27+
2428
#region IShellContext
2529

2630
bool IShellContext.AllowFlyoutGesture

src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Threading.Tasks;
77
using System.Windows.Input;
88
using Foundation;
9+
using Microsoft.Maui.Controls.Handlers.Compatibility;
910
using Microsoft.Maui.Controls.Internals;
1011
using ObjCRuntime;
1112
using UIKit;
@@ -221,6 +222,12 @@ public override void ViewDidLoad()
221222
}
222223

223224

225+
public override void ViewDidAppear(bool animated)
226+
{
227+
base.ViewDidAppear(animated);
228+
if (_context is ShellRenderer shellRenderer)
229+
shellRenderer.ViewController.SetNeedsUpdateOfHomeIndicatorAutoHidden();
230+
}
224231

225232
void IDisconnectable.Disconnect()
226233
{

src/Controls/src/Core/Compatibility/Handlers/TabbedPage/iOS/TabbedRenderer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public void SetElement(VisualElement element)
8888
UpdateBarTextColor();
8989
UpdateSelectedTabColors();
9090
UpdateBarTranslucent();
91+
UpdatePrefersHomeIndicatorAutoHiddenOnPages();
9192
}
9293

9394
public UIViewController ViewController
@@ -209,6 +210,7 @@ void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
209210
if (controller == null)
210211
return;
211212

213+
SetNeedsUpdateOfHomeIndicatorAutoHidden();
212214
SelectedViewController = controller;
213215
}
214216
else if (e.PropertyName == TabbedPage.BarBackgroundColorProperty.PropertyName)
@@ -271,6 +273,7 @@ void UpdatePrefersHomeIndicatorAutoHiddenOnPages()
271273
for (var i = 0; i < ViewControllers.Length; i++)
272274
{
273275
Tabbed.GetPageByIndex(i).OnThisPlatform().SetPrefersHomeIndicatorAutoHidden(isHomeIndicatorHidden);
276+
ViewControllers[i].SetNeedsUpdateOfHomeIndicatorAutoHidden();
274277
}
275278
}
276279

src/Controls/src/Core/ContentPage/ContentPage.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#nullable disable
22

33
using System;
4+
using System.ComponentModel;
45
using Microsoft.Maui.Graphics;
56
using Microsoft.Maui.HotReload;
67
using Microsoft.Maui.Layouts;
@@ -37,6 +38,15 @@ public bool HideSoftInputOnTapped
3738
public ContentPage()
3839
{
3940
this.NavigatedTo += (_, _) => UpdateHideSoftInputOnTapped();
41+
this.PropertyChanged += ContentPage_PropertyChanged;
42+
}
43+
44+
private void ContentPage_PropertyChanged(object sender, PropertyChangedEventArgs e)
45+
{
46+
if (e.PropertyName == PlatformConfiguration.iOSSpecific.Page.PrefersHomeIndicatorAutoHiddenProperty.PropertyName)
47+
{
48+
Handler?.UpdateValue(nameof(IHomeIndicatorAutoHiddenView.IsHomeIndicatorAutoHidden));
49+
}
4050
}
4151

4252
protected override void OnBindingContextChanged()

src/Controls/src/Core/Page/Page.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Microsoft.Maui.Controls
1818
/// </summary>
1919
/// <remarks><see cref = "Page" /> is primarily a base class for more useful derived types. Objects that are derived from the <see cref="Page"/> class are most prominently used as the top level UI element in .NET MAUI applications. In addition to their role as the main pages of applications, <see cref="Page"/> objects and their descendants can be used with navigation classes, such as <see cref="NavigationPage"/> or <see cref="FlyoutPage"/>, among others, to provide rich user experiences that conform to the expected behaviors on each platform.
2020
/// </remarks>
21-
public partial class Page : VisualElement, ILayout, IPageController, IElementConfiguration<Page>, IPaddingElement, ISafeAreaView, ISafeAreaView2, IView, ITitledElement, IToolbarElement
21+
public partial class Page : VisualElement, ILayout, IPageController, IElementConfiguration<Page>, IPaddingElement, ISafeAreaView, ISafeAreaView2, IView, ITitledElement, IToolbarElement, IHomeIndicatorAutoHiddenView
2222
{
2323
/// <summary>
2424
/// The identifier used by the internal messaging system to set <see cref="IsBusy"/>.
@@ -207,6 +207,8 @@ public bool IgnoresContainerArea
207207
/// <inheritdoc/>
208208
bool ISafeAreaView.IgnoreSafeArea => !On<PlatformConfiguration.iOS>().UsingSafeArea();
209209

210+
bool IHomeIndicatorAutoHiddenView.IsHomeIndicatorAutoHidden => On<PlatformConfiguration.iOS>().PrefersHomeIndicatorAutoHidden();
211+
210212
/// <inheritdoc/>
211213
Thickness ISafeAreaView2.SafeAreaInsets
212214
{

src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommand.get -> S
7272
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommand.set -> void
7373
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommandParameter.get -> object!
7474
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommandParameter.set -> void
75+
override Microsoft.Maui.Controls.Handlers.Compatibility.ShellRenderer.PrefersHomeIndicatorAutoHidden.get -> bool
76+
override Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutRenderer.PrefersHomeIndicatorAutoHidden.get -> bool
77+
override Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.ViewDidAppear(bool animated) -> void
7578
static readonly Microsoft.Maui.Controls.KeyboardAccelerator.KeyProperty -> Microsoft.Maui.Controls.BindableProperty!
7679
static readonly Microsoft.Maui.Controls.KeyboardAccelerator.ModifiersProperty -> Microsoft.Maui.Controls.BindableProperty!
7780
static readonly Microsoft.Maui.Controls.DragGestureRecognizer.CanDragProperty -> Microsoft.Maui.Controls.BindableProperty!

src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ static readonly Microsoft.Maui.Controls.PointerGestureRecognizer.PointerPressedC
8282
static readonly Microsoft.Maui.Controls.PointerGestureRecognizer.PointerPressedCommandProperty -> Microsoft.Maui.Controls.BindableProperty!
8383
static readonly Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommandParameterProperty -> Microsoft.Maui.Controls.BindableProperty!
8484
static readonly Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommandProperty -> Microsoft.Maui.Controls.BindableProperty!
85+
override Microsoft.Maui.Controls.Handlers.Compatibility.ShellRenderer.PrefersHomeIndicatorAutoHidden.get -> bool
86+
override Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutRenderer.PrefersHomeIndicatorAutoHidden.get -> bool
87+
override Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.ViewDidAppear(bool animated) -> void
8588
virtual Microsoft.Maui.Controls.DragEventArgs.GetPosition(Microsoft.Maui.Controls.Element? relativeTo) -> Microsoft.Maui.Graphics.Point?
8689
virtual Microsoft.Maui.Controls.DragStartingEventArgs.GetPosition(Microsoft.Maui.Controls.Element? relativeTo) -> Microsoft.Maui.Graphics.Point?
8790
virtual Microsoft.Maui.Controls.DropEventArgs.GetPosition(Microsoft.Maui.Controls.Element? relativeTo) -> Microsoft.Maui.Graphics.Point?

0 commit comments

Comments
 (0)