Coder Social home page Coder Social logo

Comments (9)

hellyab avatar hellyab commented on August 23, 2024 1

I am setting the Icon using FontImageSource and it works just fine.
Followed this article by @jamesmontemagno to add the Font Icons to my project.
<flex:FlexButton.Icon> <FontImageSource Glyph="&#xe902;" FontFamily="{StaticResource MaterialFontFamily}"/> </flex:FlexButton.Icon>

from flexbutton.

acaliaro avatar acaliaro commented on August 23, 2024

this should be a dream!

from flexbutton.

acaliaro avatar acaliaro commented on August 23, 2024

I try for this... can I?

from flexbutton.

robinmanuelthiel avatar robinmanuelthiel commented on August 23, 2024

Yeah, please feel free do. Would love to see a PR on this. I was looking at font-awesome. Ping me here if you need any help or code explanations!

from flexbutton.

acaliaro avatar acaliaro commented on August 23, 2024

do you think is it possible to use https://github.com/jsmarcus/Iconize

from flexbutton.

robinmanuelthiel avatar robinmanuelthiel commented on August 23, 2024

It would be possible to leverage Jeremy's work for sure. But I want to keep the dependencies of this library as few as possible. So I would prefer to implement it as shown here: https://forums.xamarin.com/discussion/31530/fontawesome-label-heres-how

from flexbutton.

acaliaro avatar acaliaro commented on August 23, 2024

@robinmanuelthiel is it now possible to use Icon Fonts?

from flexbutton.

julianpaulozzi avatar julianpaulozzi commented on August 23, 2024

If you want to display only the icon with Iconize this behavior should work:

    public class FlexButtonFontIcon
    {
        public static readonly BindableProperty IconProperty =
            BindableProperty.Create(
                @"Icon",
                typeof(string), 
                typeof(FlexButtonFontIcon), 
                default(string),
                propertyChanged: IconPropertyChanged);
        
        public static void SetIcon(BindableObject view, string value)
        {
            view.SetValue(IconProperty, value);
        }

        public static string GetIcon(BindableObject view)
        {
            return (string)view.GetValue(IconProperty);
        }

        private static void IconPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
        {
            var iconKey = newvalue as string;
            if (!(bindable is FlexButton view) || string.IsNullOrWhiteSpace(iconKey))
                return;
            
            var icon = Iconize.FindIconForKey(iconKey);
            if (icon != null)
            {
                var iconModule = Iconize.FindModuleOf(icon);
                view.FontFamily = $"{iconModule.FontPath}#{iconModule.FontName}";
                view.Text = $"{icon.Character}";
            }
        }
    }

Then just add on button:

<flex:FlexButton local:FlexButtonFontIcon.Icon="icon-name" FontSize="26"/>

from flexbutton.

acaliaro avatar acaliaro commented on August 23, 2024

WoW

from flexbutton.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.