jsmarcus / Iconize

Use icon fonts in your Xamarin.Forms application!
Other
204 stars 71 forks source link

Must have a setup problem with Xamarin Forms #173

Closed Robotuner closed 4 years ago

Robotuner commented 4 years ago

Unable to get Plugin Iconize to work in a Xamarin Forms Project. My setup is based on https://devhub.io/repos/jsmarcus-Iconize

I am trying to install and use Xam.Plugin.Iconize and Xam.Plugin.Iconize.FontAwesome, but there must be something wrong with my setup. Visual Studio 2019 Xamarin Forms 4.4.0.991537 Xam.FormsPlugin.Iconize v1.0.10 Xam.Plugin.Iconize 3.5.0.129 Xam.Plugin.Iconize.FontAwesome 3.5.0.129

In project.Android/Assets I have: iconize-fontawesome-regular.otf iconize-fontawesom-solids.otf

These files are renamed from the downloaded file from fontAwesome site fontawesome-free-5.8.1-desktop.zip - Font Awesome 5 Free-Regular-400.otf Font Awesome 5 Free-Solid-900.otf

I have the above fonts in the Assets folder because I wanted to be able to access the FA fonts from Xamarin forms Label and button control specifying the font family. That works, but using the Iconize controls like:

<iconize:IconToolbarItem Icon="fas-check-square" IconColor="White" Command="{Binding PostCommand}" />    

is blank (nothing appears) and

<iconize:IconButton Text="fas-signal"/>

just returns the string "fas-sign" and "fas-signal"

Rest of the setup: App.xaml.cs App() { ... Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.FontAwesomeRegularModule()) .With(new Plugin.Iconize.Fonts.FontAwesomeSolidModule()); ... }

in project.Android/MainActivity.cs I have: OnCreate(Bundle bundle) { global::Xamarin.Forms.Forms.Init(this,bundle); Plugin.Iconize.Iconize.With(new Plugin.Iconize.fonts.FontAwesomeRegularModule()) .With(new Plugin.Iconize.Fonts.FontAwesomeSolidModule());

}

Am also getting the following message: Can not resolve reference: 'Plugin.Iconize.Droid', referenced by 'FormsPlugin.Iconize.Droid'

At first I didn't think FormsPlugin.Iconize was needed but saw that it is required for Xamarin Forms, . . .

Would appreciate it if anyone notices anything missing or flat out wrong. Thanks.

mlauth commented 4 years ago

@Robotuner I had exactly the same problem. Since I couldn't find another solution I tried to downgrade to version 3.5.0.123. It works. I hope for you as well.

Robotuner commented 4 years ago

Mlauth, thanks for commenting, I have found a better way around the issue. Basically, Since xamarin forms (I'm not entirely sure which version, but probably > 3.5) made the Icon attribute obsolete and replaced it with the IconImageSource (ToolBarItems, ContentPage) I no longer needed to use the Iconize library for tabbed pages and toolbarItems. For Tabbed Pages in XAML I did this:

`

` And for ToolbarItems I did this: ` ` Where I uses a c# class with constants to specify which FontAwesome file to use (regular or solid) and which letter to print.