- Notifications
You must be signed in to change notification settings - Fork 1.9k
[Housekeeping] Refactor iOS large titles sample #33084
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
base: main
Are you sure you want to change the base?
Conversation
| 🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 33084Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 33084" |
There was a problem hiding this 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 |
| 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); |
Copilot AI Dec 10, 2025
There was a problem hiding this comment.
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 }| 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); | |
| } |
| var navPage = (Microsoft.Maui.Controls.NavigationPage)Parent; | ||
| navPage.On<iOS>().SetPrefersLargeTitles(true); |
Copilot AI Dec 10, 2025
There was a problem hiding this comment.
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 }| 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); | |
| } |
| Text = "CollectionView - Large title with SafeArea", | ||
| Command = new Command(async () => | ||
| { | ||
| var navPage = (Microsoft.Maui.Controls.NavigationPage)Parent; |
Copilot AI Dec 10, 2025
There was a problem hiding this comment.
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 }| Text = "Transparent NavBar - Content shows through", | ||
| Command = new Command(async () => | ||
| { | ||
| var navPage = (Microsoft.Maui.Controls.NavigationPage)Parent; |
Copilot AI Dec 10, 2025
There was a problem hiding this comment.
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 } src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSLargeTitlePage.xaml.cs Outdated Show resolved Hide resolved
src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSLargeTitlePage.xaml.cs Show resolved Hide resolved
| namespace Maui.Controls.Sample.Pages | ||
| namespace Maui.Controls.Sample.Pages; | ||
| | ||
| public partial class iOSLargeTitlePage : ContentPage |
Copilot AI Dec 10, 2025
There was a problem hiding this comment.
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:
- Remove the
partialmodifier and delete the XAML file if the page is fully code-based, or - 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.
| public partial class iOSLargeTitlePage : ContentPage | |
| public class iOSLargeTitlePage : ContentPage |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSLargeTitlePage.xaml.cs Outdated Show resolved Hide resolved
| @kubaflo can you check the comments? I think otherwise should be good, thanks! |
| /azp run MAUI-UITests-public |
| No pipelines are associated with this pull request. |
| /rebase |
8778624 to 1d49d0c Compare 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
1d49d0c to cf19b08 Compare | @jfversluis can you pls /azp again? I've removed unnecessary files and fixed compilation error which copilot did 😅 |
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