FFImageLoading icon indicating copy to clipboard operation
FFImageLoading copied to clipboard

Question: Using an SVG with Shell's Tab Icon?

Open kieronlanning opened this issue 5 years ago • 14 comments

Description

How can I set an SVG to the new Shell's Tab Icon property?

Screenshots

image

Reproduction Link / Code

    <TabBar>
        <Tab Title="Home">
            <Tab.Icon>
                <ffimageloadingsvg:SvgCachedImage Source="home.svg" />
            </Tab.Icon>
            <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
        </Tab>
        <Tab Title="About" Icon="tab_about.png">
            <ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
        </Tab>
    </TabBar>

kieronlanning avatar Jun 09 '19 14:06 kieronlanning

SvgImageSource.FromFile etc

daniel-luberda avatar Jun 09 '19 14:06 daniel-luberda

@daniel-luberda Thanks! I'm new to Xamarin... is that something I do in Xaml or code?

kieronlanning avatar Jun 09 '19 15:06 kieronlanning

Updated to bind to a view model now, but the icon doesn't appear.

I've also included the same icon on the page (as content) using the same code, and it's fine.

image

Tried a variety of things to make sure it's picking up the correct file and content, and it's fine on page, but not in the Tab Icon.

image

kieronlanning avatar Jun 10 '19 14:06 kieronlanning

@kieronlanning any updates about this isseu? The icon doesn't appear for me too. Thanks!

candidodmv avatar Jul 22 '19 19:07 candidodmv

@candidodmv It's on the Xamarin backlog: https://github.com/xamarin/Xamarin.Forms/issues/6477

kieronlanning avatar Jul 22 '19 19:07 kieronlanning

I did some research:

Android is using IImageViewHandler and IImageSourceHandler - FFImageLoading implements both, but FFImageLoadingImageSourceHandler is ignored and cannot be registered. Shell tabs are relying on IImageSourceHandler, that's why no icons are displayed.

This issue could be resolved by simply adding an InitImageSourceHandler routine for Android, similar to iOS.

@daniel-luberda I would go for a PR if that makes sense for you.

Dresel avatar Oct 24 '19 09:10 Dresel

Any updates?

Denn1Ro avatar Mar 24 '20 15:03 Denn1Ro

using FFImageLoading.Forms.Platform;
using FFImageLoading.Svg.Forms;

// FFImageLoading.Forms.Platform
namespace Application.Droid
{
    public static class SvgImageRegister
    {
        public static void Init()
        {
            Xamarin.Forms.Internals.Registrar.Registered.Register(typeof(SvgImageSource), typeof(FFImageLoadingImageSourceHandler));
        }
    }
}

elaurentin avatar May 22 '20 07:05 elaurentin

Is there any update on this issue, when will be fixed? Thanks in advance! @daniel-luberda

tothattila97 avatar Jul 01 '20 16:07 tothattila97

@candidodmv It's on the Xamarin backlog: xamarin/Xamarin.Forms#6477

Xamarin says it is an issue on FF side:

This is not a Xamarin Forms issue, FFImageLoading does not register IImageSourceHandler for Android (see comment).

from: https://github.com/xamarin/Xamarin.Forms/issues/6477#issuecomment-545823706

NightOwlCoder avatar Jul 17 '20 00:07 NightOwlCoder

you can use a tabbed page like this: https://docs.microsoft.com/it-it/samples/xamarin/xamarin-forms-samples/navigation-tabbedpagewithsvgtabicons/

AmarildoLena avatar Nov 15 '20 11:11 AmarildoLena

you can use a tabbed page like this: https://docs.microsoft.com/it-it/samples/xamarin/xamarin-forms-samples/navigation-tabbedpagewithsvgtabicons/

This is not using Xamarin Shell

harris1717 avatar Dec 10 '20 19:12 harris1717

See my post on May 22nd, same as @Dresel already pointed out. Call SvgImageRegister.Init()

elaurentin avatar Dec 10 '20 19:12 elaurentin

you can use a tabbed page like this: https://docs.microsoft.com/it-it/samples/xamarin/xamarin-forms-samples/navigation-tabbedpagewithsvgtabicons/

This is not using Xamarin

If still struggling use a workaround to draw with skiasharp: https://github.com/taublast/xamarinshell

taublast avatar Nov 07 '22 14:11 taublast