Skip to content

Conversation

@kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Dec 10, 2025

Replaces the old LargeTitlesPageiOS.cs with an enhanced iOSLargeTitlePage.xaml.cs implementation, providing improved UI and more comprehensive large title and navigation bar demonstrations. Removes the legacy page from OthersViewModel and updates the sample to use the new, feature-rich version.

Screen.Recording.2025-12-10.at.00.48.28.mov
Copilot AI review requested due to automatic review settings December 10, 2025 00:00
@github-actions
Copy link
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 33084

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 33084"
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the iOS large titles sample by replacing the legacy LargeTitlesPageiOS.cs with an enhanced iOSLargeTitlePage.xaml.cs implementation. The new version provides a more comprehensive demonstration of iOS large title features including display modes, navigation configuration, scrolling behavior, and transparent navigation bars.

  • Removes the old large titles page reference from OthersViewModel
  • Implements a feature-rich large titles demo with multiple interactive examples
  • Deletes the legacy LargeTitlesPageiOS.cs file

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
src/Controls/samples/Controls.Sample/ViewModels/OthersViewModel.cs Removes the legacy LargeTitlesPageiOS entry from the Others section
src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSLargeTitlePage.xaml.cs Complete reimplementation with enhanced UI demonstrations, including display modes, navigation configuration, scrolling behavior, and transparent navigation bar examples
src/Controls/samples/Controls.Sample/Pages/Others/LargeTitlesPageiOS.cs Deletes the old large titles page implementation
Comment on lines 77 to 81
var navPage = (Microsoft.Maui.Controls.NavigationPage)Parent;
navPage.On<iOS>().SetPrefersLargeTitles(!navPage.On<iOS>().PrefersLargeTitles());

// Refresh the page to show the change
Navigation.InsertPageBefore(new iOSLargeTitlePage(),this);
await Navigation.PopAsync(false);
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code casts Parent to NavigationPage without null checking. If Parent is null or not a NavigationPage, this will throw an InvalidCastException at runtime. Consider using a null-conditional pattern cast with a null check:

if (Parent is Microsoft.Maui.Controls.NavigationPage navPage) { navPage.On<iOS>().SetPrefersLargeTitles(!navPage.On<iOS>().PrefersLargeTitles()); // ... rest of code }
Suggested change
var navPage = (Microsoft.Maui.Controls.NavigationPage)Parent;
navPage.On<iOS>().SetPrefersLargeTitles(!navPage.On<iOS>().PrefersLargeTitles());
// Refresh the page to show the change
Navigation.InsertPageBefore(new iOSLargeTitlePage(),this);
await Navigation.PopAsync(false);
if (Parent is Microsoft.Maui.Controls.NavigationPage navPage)
{
navPage.On<iOS>().SetPrefersLargeTitles(!navPage.On<iOS>().PrefersLargeTitles());
// Refresh the page to show the change
Navigation.InsertPageBefore(new iOSLargeTitlePage(),this);
await Navigation.PopAsync(false);
}
Copilot uses AI. Check for mistakes.
var navPage = (Microsoft.Maui.Controls.NavigationPage)Parent;
navPage.On<iOS>().SetPrefersLargeTitles(true);
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code casts Parent to NavigationPage without null checking. If Parent is null or not a NavigationPage, this will throw an InvalidCastException at runtime. Consider using a pattern cast with a null check:

if (Parent is Microsoft.Maui.Controls.NavigationPage navPage) { navPage.On<iOS>().SetPrefersLargeTitles(true); // ... rest of code }
Suggested change
var navPage = (Microsoft.Maui.Controls.NavigationPage)Parent;
navPage.On<iOS>().SetPrefersLargeTitles(true);
if (Parent is Microsoft.Maui.Controls.NavigationPage navPage)
{
navPage.On<iOS>().SetPrefersLargeTitles(true);
}
Copilot uses AI. Check for mistakes.
Text = "CollectionView - Large title with SafeArea",
Command = new Command(async () =>
{
var navPage = (Microsoft.Maui.Controls.NavigationPage)Parent;
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code casts Parent to NavigationPage without null checking. If Parent is null or not a NavigationPage, this will throw an InvalidCastException at runtime. Consider using a pattern cast with a null check:

if (Parent is Microsoft.Maui.Controls.NavigationPage navPage) { navPage.On<iOS>().SetPrefersLargeTitles(true); // ... rest of code }
Copilot uses AI. Check for mistakes.
Text = "Transparent NavBar - Content shows through",
Command = new Command(async () =>
{
var navPage = (Microsoft.Maui.Controls.NavigationPage)Parent;
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code casts Parent to NavigationPage without null checking. If Parent is null or not a NavigationPage, this will throw an InvalidCastException at runtime. Consider using a pattern cast with a null check:

if (Parent is Microsoft.Maui.Controls.NavigationPage navPage) { navPage.On<iOS>().SetPrefersLargeTitles(true); // ... rest of code }
Copilot uses AI. Check for mistakes.
namespace Maui.Controls.Sample.Pages
namespace Maui.Controls.Sample.Pages;

public partial class iOSLargeTitlePage : ContentPage
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class is declared as partial but InitializeComponent() is never called, and the existing XAML file (iOSLargeTitlePage.xaml) references event handlers (OnButtonClicked, OnReturnButtonClicked) that don't exist in this code-behind. Either:

  1. Remove the partial modifier and delete the XAML file if the page is fully code-based, or
  2. Call InitializeComponent() and update the XAML to match the new implementation.

The current state will cause a runtime exception when the XAML tries to wire up non-existent event handlers.

Suggested change
public partial class iOSLargeTitlePage : ContentPage
public class iOSLargeTitlePage : ContentPage
Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kubaflo what is going on here? If there is no XAML file then why is it called xaml.cs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! It was called xaml.cs because there was a xaml file but hasn't been used. Fixed

@jfversluis
Copy link
Member

@kubaflo can you check the comments? I think otherwise should be good, thanks!

@jfversluis
Copy link
Member

jfversluis commented Dec 10, 2025

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

No pipelines are associated with this pull request.
@jfversluis
Copy link
Member

/rebase

Replaces the old LargeTitlesPageiOS.cs with an enhanced iOSLargeTitlePage.xaml.cs implementation, providing improved UI and more comprehensive large title and navigation bar demonstrations. Removes the legacy page from OthersViewModel and updates the sample to use the new, feature-rich version. Refactor iOS large titles sample and remove legacy page Replaces the old LargeTitlesPageiOS.cs with an enhanced iOSLargeTitlePage.xaml.cs implementation, providing improved UI and more comprehensive large title and navigation bar demonstrations. Removes the legacy page from OthersViewModel and updates the sample to use the new, feature-rich version. Apply suggestions from code review
@kubaflo kubaflo force-pushed the large-titles-samples-improvement branch from 1d49d0c to cf19b08 Compare December 11, 2025 14:52
@kubaflo
Copy link
Contributor Author

kubaflo commented Dec 11, 2025

@jfversluis can you pls /azp again? I've removed unnecessary files and fixed compilation error which copilot did 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution

2 participants