-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Font Icons #308
Comments
We can add this as a feature but if you need it now then you can inherit the tabbed container. |
Thanks for the quick reply. I'll dig into creating my own tabbed container. If all goes well, I'll submit a PR. |
using System.Collections.Generic;
using FreshMvvm;
using Xamarin.Forms;
namespace RmedAgent3
{
//
public class MyTabbedNavigationContainer: FreshTabbedNavigationContainer
{
public Page AddTab<T>(string title, ImageSource imageSource, object data = null) where T : FreshBasePageModel
{
Page page = FreshPageModelResolver.ResolvePageModel<T>(data);
page.GetModel().CurrentNavigationServiceName = NavigationServiceName;
var tabs = TabbedPages as List<Page>;
tabs.Add(page);
Page page2 = MyCreateContainerPageSafe(page);
page2.Title = title;
if (imageSource != null && !imageSource.IsEmpty)
{
//page2.Icon = icon;
page2.IconImageSource = imageSource;
}
base.Children.Add(page2);
return page2;
}
public Page MyCreateContainerPageSafe(Page page)
{
if (page is NavigationPage || page is MasterDetailPage || page is TabbedPage)
{
return page;
}
return CreateContainerPage(page);
}
}
} usage: public App()
{
//RegisterSampleServices();
RegisterServices();
InitializeComponent();
//MainPage = new MainPage();
/*
var loginPage = FreshPageModelResolver.ResolvePageModel<LoginPageModel>();
MainPage = loginPage;
*/
var mainPage = new MyTabbedNavigationContainer();
mainPage.AddTab<HomePageModel>("Главная" , GetMaterialIconSource(MaterialIcons.Home));
mainPage.AddTab<HomePageModel>("Задания", GetMaterialIconSource(MaterialIcons.Inbox));
mainPage.AddTab<HomePageModel>("Заявки", GetMaterialIconSource(MaterialIcons.Assignment));
mainPage.AddTab<HomePageModel>("Сканер", GetMaterialIconSource(MaterialIcons.CenterFocusStrong));
mainPage.AddTab<HomePageModel>("Еще" , GetMaterialIconSource(MaterialIcons.MoreHoriz));
mainPage.On<Xamarin.Forms.PlatformConfiguration.Android>().SetToolbarPlacement(ToolbarPlacement.Bottom);
mainPage.BarTextColor = Color.White;
mainPage.BarBackgroundColor = App.GetColor("BrandColor");
mainPage.SelectedTabColor = Color.White;
mainPage.UnselectedTabColor = App.GetColor("UnselectedTabColor");
MainPage = mainPage;
}
public FontImageSource GetMaterialIconSource(string iconName)
{
return new FontImageSource()
{
FontFamily = (string) Application.Current.Resources["MaterialFont"]
, Glyph = iconName,
};
} result: |
@protokovich Thanks for posting this. I meant to do the same but had other priorities. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now that Xamarin supports font icons, would it be possible to support font icons in the tabbed navigation container? So, instead of passing an icon name, I'd like to be able to pass a font icon name for the tab icons. Looking for guidance on this.
The text was updated successfully, but these errors were encountered: