maui icon indicating copy to clipboard operation
maui copied to clipboard

[iOS] Shell/NavigationPage TitleView

Open kubaflo opened this issue 11 months ago • 13 comments

Fixes https://github.com/dotnet/maui/issues/9333 Fixes https://github.com/dotnet/maui/issues/19231 Fixes https://github.com/dotnet/maui/issues/5063

Current behavior

Layout options have no effect on the title view. The content inside the titleView behaves as it has both HorizontalOptions and VerticalOptions set to Fill. Also, notice that there's a horizontal margin that cannot be removed even with setting the negative values to margin eg. Margin="-20,0" (https://github.com/dotnet/maui/issues/19231)

Currently

Screenshot 2024-03-02 at 14 58 41

Proposed behavior https://github.com/dotnet/maui/issues/5063

Utilizes our current LayoutOptions to indicate how you want a TitleView to layout on the screen and removes the default horizontal margin so that we can customize it.

<NavigationPage.TitleView>
    <HorizontalStackLayout BackgroundColor="red">
        <Label VerticalOptions="Center" Text="Navigation page's title"/>
        <Image Source="dotnet_bot.png" Scale="0.8"/>
    </HorizontalStackLayout>
</NavigationPage.TitleView>

Default - (horizontal and vertical options set to fill implicitly)

Screenshot 2024-03-02 at 15 00 41

HorizontalOptions="Start"

Screenshot 2024-03-02 at 15 02 14

HorizontalOptions="Center"

Screenshot 2024-03-02 at 15 04 44

HorizontalOptions="End"

Screenshot 2024-03-02 at 15 05 47

VerticalOptions="Start"

Screenshot 2024-03-02 at 15 09 49

VerticalOptions="Center"

Screenshot 2024-03-02 at 15 07 58

VerticalOptions="End"

Screenshot 2024-03-02 at 15 06 56

VerticalOptions="Start" HorizontalOptions="Start"

Screenshot 2024-03-02 at 15 15 30

VerticalOptions="Center" HorizontalOptions="Center"

Screenshot 2024-03-02 at 15 14 42

VerticalOptions="End" HorizontalOptions="End"

Screenshot 2024-03-02 at 15 15 07

Remarks

I didn't implement anything that changes the behavior when additional toolbar items are added. For example, if there's a back button the title view places itself to the right of this button. It is because I'm not sure what is the desired behavior. On one hand, it looks weird that when we want to center the title it is moved to the right, but on the other, it is the default iOS's behavior and I believe a future discussion should be made https://github.com/xamarin/Xamarin.Forms/issues/4848 Screenshot 2024-03-02 at 16 10 55

kubaflo avatar Mar 02 '24 15:03 kubaflo

Hey there @kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

ghost avatar Mar 02 '24 15:03 ghost

/azp run MAUI-UITests-public

jsuarezruiz avatar Mar 20 '24 16:03 jsuarezruiz

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Mar 20 '24 16:03 azure-pipelines[bot]

Oh my, never knew I'd see a fix from the issue I suffered from 4 years ago in X.F. days! Are there any plans to add it to .net 8 SR 4? (hopefully)

Pastajello avatar Mar 29 '24 15:03 Pastajello

/azp run

jsuarezruiz avatar Apr 19 '24 10:04 jsuarezruiz

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Apr 19 '24 10:04 azure-pipelines[bot]

can you retarget this for net9?

Yep, I think it is a good idea

kubaflo avatar Apr 30 '24 18:04 kubaflo

can you retarget this for net9?

Yep, I think it is a good idea

Is there no chance we can get this fix in a patch release for .NET 8? Preferably sooner than later? I'm wrestling with this issue at the moment and would really appreciate a fix but we only use LTS versions for production apps.

TheXenocide avatar May 31 '24 19:05 TheXenocide

I also can't use this code directly in our app because too many pieces are internal for me to drop this in as a replacement renderer.

TheXenocide avatar May 31 '24 19:05 TheXenocide

Will this be fixed sometime soon? We can't change the color of our navigation bar to anything but white without having unsightly gaps on either end.

nickl-martin avatar Jul 10 '24 01:07 nickl-martin