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

Created on 9 Jun 2019  路  13Comments  路  Source: luberda-molinet/FFImageLoading

Description

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

Screenshots


image

Reproduction Link / Code

<!-- Your Pages --> <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>

Most helpful comment

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));
        }
    }
}

All 13 comments

SvgImageSource.FromFile etc

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

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 any updates about this isseu? The icon doesn't appear for me too. Thanks!

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

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.

Any updates?

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));
        }
    }
}

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

@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

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

Was this page helpful?
0 / 5 - 0 ratings