Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.ComponentModel;
using System.Linq;
using Foundation;
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
using Microsoft.Maui.Graphics;
using ObjCRuntime;
using UIKit;
Expand Down Expand Up @@ -399,6 +400,7 @@ void OnDisplayedPageChanged(Page page)
{
_displayedPage.PropertyChanged += OnDisplayedPagePropertyChanged;
UpdateTabBarHidden();
UpdateLargeTitles();
}
}

Expand All @@ -408,6 +410,31 @@ void OnDisplayedPagePropertyChanged(object sender, PropertyChangedEventArgs e)
UpdateTabBarHidden();
}


void UpdateLargeTitles()
{
var page = _displayedPage;
if (page is null || !OperatingSystem.IsIOSVersionAtLeast(11))
return;

var largeTitleDisplayMode = page.OnThisPlatform().LargeTitleDisplay();

if (SelectedViewController is UINavigationController navigationController)
{
navigationController.NavigationBar.PrefersLargeTitles = largeTitleDisplayMode == LargeTitleDisplayMode.Always;
var top = navigationController.TopViewController;
if (top is not null)
{
top.NavigationItem.LargeTitleDisplayMode = largeTitleDisplayMode switch
{
LargeTitleDisplayMode.Always => UINavigationItemLargeTitleDisplayMode.Always,
LargeTitleDisplayMode.Automatic => UINavigationItemLargeTitleDisplayMode.Automatic,
_ => UINavigationItemLargeTitleDisplayMode.Never
};
}
}
}

void RemoveRenderer(IShellSectionRenderer renderer)
{
if (_sectionRenderers.Remove(renderer.ViewController))
Expand Down Expand Up @@ -441,6 +468,7 @@ IShellSectionRenderer RendererForViewController(UIViewController viewController)
public override void ViewWillLayoutSubviews()
{
UpdateTabBarHidden();
UpdateLargeTitles();
base.ViewWillLayoutSubviews();
}

Expand Down
17 changes: 17 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue12156.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
x:Class="Maui.Controls.Sample.Issues.Issue12156">

<ShellContent Title="Home">
<ContentPage ios:Page.LargeTitleDisplay="Always">
<Label
Text="Issue 12156"
AutomationId="Label"
VerticalOptions="Center"
HorizontalOptions="Center"/>
</ContentPage>
</ShellContent>

</Shell>
10 changes: 10 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue12156.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 12156, "iOS Page.LargeTitleDisplay does not work on iOS", PlatformAffected.iOS)]
public partial class Issue12156 : Shell
{
public Issue12156()
{
InitializeComponent();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_WINDOWS
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue12156 : _IssuesUITest
{
public Issue12156(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "iOS Page.LargeTitleDisplay does not work on iOS";

[Test]
[Category(UITestCategories.TitleView)]
public void LargeTitleDisplayWorks()
{
App.WaitForElement("Label");
VerifyScreenshot();
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading