dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

Custom view as FlyoutIcon in Shell #22530

Open MattePozzy opened 6 months ago

MattePozzy commented 6 months ago

Description

Hi, I need to add a dot at the hamburger menu in a Shell app. So what I think is use the BadgeView control of Syncfusion to do this, but it require a view to attach the dot:

<badge:SfBadgeView HorizontalOptions="Center" VerticalOptions="Center" BadgeText="20">
        <badge:SfBadgeView.Content>
            <Button Text="Primary" WidthRequest="120"  HeightRequest="60"/>
        </badge:SfBadgeView.Content>
</badge:SfBadgeView>

that produces:

image

but the Shell's FlyoutIconicon property accept only an Imagesourceas value.

There is a way to archieve what I need to do?

Thank you.

EDIT: I have also tried to modify the ShellItem but the UI doesn't refresh:

public static void UpdateIconMenu(string title, string materialIcon, string resourceColor)
{
    int indx = Shell.Current.Items.ToList().FindIndex(x => string.Equals(x.Title, title, StringComparison.InvariantCultureIgnoreCase));
    if (indx > -1)
    {
        Color color = Utility.GetResources<Color>(resourceColor);
        Shell.Current.Items[indx].FlyoutIcon = BaseMenu.IconaMenu(materialIcon, color);
    }
}

Just for testing I have tried to add an element, but the UI doesn't refresh:

ShellItem elem = Shell.Current.Items[indx];
Shell.Current.Items.Add(elem);

EDIT 2: Same behaviour with the top menu icon. I have tried to change the icon and its color, but the UI doesn't refresh.

public static void ChangeHamburger()
{
    Color color = Utility.GetResources<Color>("Rosso");
    Shell.Current.FlyoutIcon = BaseMenu.IconaMenu(MaterialFontIcons.Abacus, color);
}

Steps to Reproduce

No response

Link to public reproduction project repository

repo

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 6 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

MattePozzy commented 5 months ago

Repository added.

ninachen03 commented 5 months ago

I can repro this issue on Visual Studio 17.11.0 Preview 2.1 (8.0.60 & 8.0.21).