Skip to content

Commit

Permalink
center categories tab layout on android
Browse files Browse the repository at this point in the history
  • Loading branch information
gwalus committed May 21, 2024
1 parent e27ece5 commit cc57b46
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 28 deletions.
12 changes: 10 additions & 2 deletions src/Dollet.Presentation/Maui/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
using Microcharts.Maui;
using Microsoft.Extensions.Configuration;
using System.Reflection;
#if ANDROID
using Dollet.Platforms.Android.Renderers;
#endif

namespace Dollet
{
Expand All @@ -21,8 +24,13 @@ public static MauiApp CreateMauiApp()
fonts.AddFont("MaterialIcons-Regular.ttf", "MaterialIconsRegular");
})
.UseMicrocharts()
.UseMauiCommunityToolkit();

.UseMauiCommunityToolkit()
.ConfigureMauiHandlers(handlers =>
{
#if ANDROID
handlers.AddHandler(typeof(Shell), typeof(CustomShellRenderer));
#endif
});

FormHandler.RemoveBorders();

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Android.Content;
using Dollet.Platforms.Android.Trackers;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using Microsoft.Maui.Controls.Platform.Compatibility;

namespace Dollet.Platforms.Android.Renderers
{
public class CustomShellRenderer(Context context) : ShellRenderer(context)
{
protected override IShellTabLayoutAppearanceTracker CreateTabLayoutAppearanceTracker(ShellSection shellSection)
{
return new CustomTabLayoutAppearanceTracker(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Google.Android.Material.Tabs;
using Microsoft.Maui.Controls.Platform.Compatibility;

namespace Dollet.Platforms.Android.Trackers
{
public class CustomTabLayoutAppearanceTracker(IShellContext shellContext) : ShellTabLayoutAppearanceTracker(shellContext)
{
public override void SetAppearance(TabLayout tabLayout, ShellAppearance appearance)
{
base.SetAppearance(tabLayout, appearance);

tabLayout.TabMode = TabLayout.ModeFixed;
tabLayout.TabGravity = TabLayout.GravityFill;
}
}
}

0 comments on commit cc57b46

Please sign in to comment.