Side menu navigation solution for Android platform
======================================================
NavigationFragmentLayout is layout which containes logic for contain and navigate fragments. It contains list of fragment with icon and title, account icon and title and fragments container with navigation bar. Navigation bar contains 2 buttons: left and right side. Left side button open and close fragments list visibility. Right button does not have any action, it’s only do call event by click.
Typeface ItemTypeface - text typeface of fragments list item;
void SetupNavigation(List
public class NavigationModel
{
public int Id { get; set; }
public string Title { get; set; }
public Drawable Icon { get; set; }
public bool Selected { get; set; }
public NavigationModel(int id, string title, Drawable icon)
{
Id = id;
Title = title;
Icon = icon;
}
}
public class NavigationFragmentModel
{
public NavigationModel NavigationModel { get; set; }
public Fragment Fragment { get; set; }
public NavigationFragmentModel(NavigationModel navigationModel, Fragment fragment)
{
NavigationModel = navigationModel;
Fragment = fragment;
}
}
Sample of NavigationFragmentLayout customization in main Activity
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);
var navigation = FindViewById<NavigationFragmentLayout>(Resource.Id.navigation_container);
navigation.SetupNavigation(GenerateMenuFragmentModels(), FragmentManager);
navigation.FragmentActionBarColor = Color.ParseColor("#3DC0C6");
navigation.FragmentBackgroundColor = Color.ParseColor("#3DC0C6");
navigation.LeftIconColor = Color.ParseColor("#3D3D45");
navigation.RightIconColor = Color.ParseColor("#3D3D45");
navigation.TitleTypeface = Typeface.CreateFromAsset(Assets, "Fonts/dincondensedc.otf");
navigation.ItemTypeface = Typeface.CreateFromAsset(Assets, "Fonts/BodoniBook.ttf");
navigation.AccountTextColor = Color.White;
}
private List<NavigationFragmentModel> GenerateMenuFragmentModels()
{
return new List<NavigationFragmentModel>()
{
new NavigationFragmentModel(new NavigationModel(1, "Search", BaseContext.GetDrawable(Resource.Drawable.search)), new SearchFragment()),
new NavigationFragmentModel(new NavigationModel(2, "Home", BaseContext.GetDrawable(Resource.Drawable.home)), new HomeFragment()),
new NavigationFragmentModel(new NavigationModel(3, "Scale", BaseContext.GetDrawable(Resource.Drawable.percent)), new ScaleFragment()),
new NavigationFragmentModel(new NavigationModel(4, "Catalog", BaseContext.GetDrawable(Resource.Drawable.grid)), new CatalogFragment()),
new NavigationFragmentModel(new NavigationModel(5, "Orders", BaseContext.GetDrawable(Resource.Drawable.wallet)), new OrdersFragment()),
new NavigationFragmentModel(new NavigationModel(6, "Info", BaseContext.GetDrawable(Resource.Drawable.information)), new InformationFragment()),
new NavigationFragmentModel(new NavigationModel(7, "Settings", BaseContext.GetDrawable(Resource.Drawable.settings)), new SettingsFragment()),
};
}
Sample of activity_main.axml of main Activity
<?xml version="1.0" encoding="utf-8"?>
<EOSNavigation.NavigationFragmentLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/navigation_container"
android:layout_width="match_parent"
android:layout_height="match_parent"></EOSNavigation.NavigationFragmentLayout>