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

Shell TitleView on iOS not occupying requested height #18060

Closed
ESO-ST opened this issue Oct 16, 2023 · 4 comments · Fixed by #20795
Closed

Shell TitleView on iOS not occupying requested height #18060

ESO-ST opened this issue Oct 16, 2023 · 4 comments · Fixed by #20795
Assignees
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout fixed-in-8.0.10 fixed-in-9.0.0-preview.2.10293 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/needs-attention Issue has more information and needs another look t/bug Something isn't working
Milestone

Comments

@ESO-ST
Copy link

ESO-ST commented Oct 16, 2023

Description

Using the handler below to remove white space around the TitleView, the Shell TitleView does not occupy the requested height, unless we change tabs.
Example in the screenshots attached if we navigate from "General" to "Crew" the title view height adjusts itself and now occupies the right height.

using Microsoft.Maui.Controls.Platform.Compatibility;
using UIKit;

namespace CustomShellTitleView;

internal class CustomShellNavBarAppearanceTracker : IShellNavBarAppearanceTracker
{
    readonly IShellContext _context;
    readonly IShellNavBarAppearanceTracker _baseTracker;

    public CustomShellNavBarAppearanceTracker(IShellContext context, IShellNavBarAppearanceTracker baseTracker)
    {
        _context = context;
        _baseTracker = baseTracker;
    }

    public void Dispose() => _baseTracker.Dispose();

    public void ResetAppearance(UINavigationController controller) => _baseTracker.ResetAppearance(controller);

    public void SetAppearance(UINavigationController controller, ShellAppearance appearance) => _baseTracker.SetAppearance(controller, appearance);

    public void SetHasShadow(UINavigationController controller, bool hasShadow) => _baseTracker.SetHasShadow(controller, hasShadow);

    public void UpdateLayout(UINavigationController controller)
    {
        UIView titleView = Shell.GetTitleView(_context.Shell.CurrentPage).Handler.PlatformView as UIView;

        UIView parentView = GetParentByType(titleView, typeof(UIKit.UIControl));

        if (parentView != null)
        {
            NSLayoutConstraint.Create(parentView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, parentView.Superview, NSLayoutAttribute.Leading, 1.0f, 0.0f).Active = true;
            NSLayoutConstraint.Create(parentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, parentView.Superview, NSLayoutAttribute.Trailing, 1.0f, 0.0f).Active = true;
            NSLayoutConstraint.Create(parentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, parentView.Superview, NSLayoutAttribute.Bottom, 1.0f, 0.0f).Active = true;
            NSLayoutConstraint.Create(parentView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, parentView.Superview, NSLayoutAttribute.Top, 1.0f, 0.0f).Active = true;
        }
        _baseTracker.UpdateLayout(controller);
    }

    static UIView GetParentByType(UIView view, Type type)
    {
        UIView currentView = view;

        while (currentView != null)
        {
            if (currentView.GetType().UnderlyingSystemType == type)
                break;

            currentView = currentView.Superview;
        }

        return currentView;
    }
}

bad
good

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.0-rc.2.9373

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

No response

Did you find any workaround?

change tabs; pages that have no tabs have no workaround.

Relevant log output

No response

@ESO-ST ESO-ST added the t/bug Something isn't working label Oct 16, 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 Oct 16, 2023
@jsuarezruiz jsuarezruiz added platform/iOS 🍎 area-controls-shell Shell Navigation, Routes, Tabs, Flyout labels Oct 17, 2023
@PureWeen PureWeen added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Oct 18, 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 20, 2023
@BenBtg
Copy link
Contributor

BenBtg commented Dec 5, 2023

This is still an issue in GA.

@jsuarezruiz
Copy link
Contributor

This is still an issue in GA.

@BenBtg Could you attach a repro sample? Tried to reproduce on main without success.
image

@jsuarezruiz jsuarezruiz added the s/needs-info Issue needs more info from the author label Feb 14, 2024
@ghost
Copy link

ghost commented Feb 14, 2024

Hi @ESO-ST. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@BenBtg
Copy link
Contributor

BenBtg commented Feb 14, 2024

@jsuarezruiz yes I can help get you access to a private repo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout fixed-in-8.0.10 fixed-in-9.0.0-preview.2.10293 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/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

7 participants