Skip to content
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

Can only ignore iOS Safe Area when navigation bar is hidden #17022

Closed
davidortinau opened this issue Aug 27, 2023 · 6 comments · Fixed by #19204
Closed

Can only ignore iOS Safe Area when navigation bar is hidden #17022

davidortinau opened this issue Aug 27, 2023 · 6 comments · Fixed by #19204
Assignees
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter fixed-in-8.0.7 fixed-in-9.0.100-preview.1.9973 migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@davidortinau
Copy link
Contributor

davidortinau commented Aug 27, 2023

Description

Porting an Xamarin.Forms app to .NET MAUI, I found that the old safe area code doesn't work as expected in .NET MAUI. I found the recommendation to use IgnoreSafeArea="True" on the layout, however this didn't do anything until...

I did a repro in a blank app and hid the navigation bar.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="PlayItSUnsafe.MainPage"
             xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
             ios:Page.UseSafeArea="False"
             BackgroundColor="Red"
             Shell.NavBarIsVisible="False"
             >


        <Grid Background="#333333"
            IgnoreSafeArea="True"
            RowDefinitions="300,*"
            >
            <BoxView Grid.Row="0"
                BackgroundColor="MediumPurple"
                />
            
            <Image Source="dotnet_bot.png" />

            <Label Text="Hello, world!" Grid.Row="1"
            TextColor="White"
                HorizontalOptions="Center"
                VerticalOptions="Center" />
        </Grid>

</ContentPage>

PlayItUnsafe.zip
Screenshot 2023-08-27 at 2 36 29 PM

This AppDelegate code should (used to) make the nav bar bg transparent to create this look.

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    {
        base.FinishedLaunching(application, launchOptions);
            
        UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
        UINavigationBar.Appearance.ShadowImage = new UIImage();
        UINavigationBar.Appearance.BackgroundColor = UIColor.Clear;
        UINavigationBar.Appearance.TintColor = UIColor.White;
        UINavigationBar.Appearance.BarTintColor = UIColor.Clear;
        UINavigationBar.Appearance.Translucent = true;

        return true;
    }

The SmartHotel360 app uses FlyoutPage and the sample repro uses Shell. Both should work.

Steps to Reproduce

run the sample from the zip and/or the repo linked. Show/hide the navigation bar. In both cases the content should be at the very top of the device screen, not at the bottom of the nav bar.

Link to public reproduction project repository

https://github.com/davidortinau/SmartHotel360-Mobile/blob/upgrade-step-1/Source/SmartHotel.Clients/SmartHotel.Clients.iOS/AppDelegate.cs

Version with bug

8.0.0-preview.7.8842
Also tested latest 7.0

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

16.4

Did you find any workaround?

Not without abandoning the existing implementation with ToolbarItem and flyout menu button etc.

Relevant log output

No response

@davidortinau davidortinau added the t/bug Something isn't working label Aug 27, 2023
@PureWeen PureWeen added migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/iOS 🍎 labels Aug 27, 2023
@rmarinho rmarinho added this to the Backlog milestone Aug 28, 2023
@ghost
Copy link

ghost commented Aug 28, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@davidortinau
Copy link
Contributor Author

Update, I whittled the code in SmartHotel360 down to the bare implementation. It's a FlyoutPage, iOS translucent platform specific, and the at nav bar code. No Safe Area info is used.

public App()
	{
		InitializeComponent();

		var detail = new NavigationPage(new MainPage())
		{
			BarBackgroundColor = Colors.Transparent,
			BarTextColor = Colors.White
		};
		detail.On<iOS>().EnableTranslucentNavigationBar();

		MainPage = new FlyoutPage()
		{
			Flyout = new ContentPage(){Title = "Menu"},
			Detail = detail
		};

	}
Screenshot 2023-08-28 at 9 53 26 AM

App1XF.zip

PlayItUnsafe.zip

If I ignore safe area with the platform specific and IgnoreSafeArea on the page Grid, the content moves up slightly, but still not in the safe area under the nav bar.

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:iOsSpecific="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
             iOsSpecific:Page.UseSafeArea="False"
             x:Class="PlayItSUnsafe.MainPage"
             BackgroundColor="Red"
             Title="Main">
        <Grid Background="#333333"
            IgnoreSafeArea="True"
            RowDefinitions="300,*"
            >
Screenshot 2023-08-28 at 10 00 08 AM

@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Sep 4, 2023
@XamlTest
Copy link

XamlTest commented Sep 4, 2023

Verified this on Visual Studio Enterprise 17.8.0 Preview 1.0. Repro on iOS 16.4 .NET 8 with below Project:
PlayItUnsafe.zip

@Eilon Eilon added the area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter label Sep 7, 2023
@mikeparker104 mikeparker104 added the partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with label Sep 28, 2023
@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Oct 3, 2023
@samhouts samhouts modified the milestones: Backlog, .NET 8 SR1 Oct 5, 2023
@tj-devel709 tj-devel709 self-assigned this Oct 23, 2023
@tj-devel709
Copy link
Member

Hi @davidortinau, I am trying out different parts of this issue!

Inside current main, looks like the Shell Flyout menu gives the desired behavior if I am understanding correctly
image

Was there an example of this behavior that you were expecting in the past on Shell ?

@davidortinau
Copy link
Contributor Author

@tj-devel709 the issue I'm showing does NOT use Shell. The PlayItUnsafe solution uses FlyoutPage > NavigationPage > ContentPage.

@Denny966
Copy link

Got the same issue with a grid inside a content page

@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Jan 24, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter fixed-in-8.0.7 fixed-in-9.0.100-preview.1.9973 migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

9 participants