My custom ShellRenderer to make TabBar icons bigger is crashing app

iooovoltsiooovolts ✭✭Member ✭✭

I am trying to make my TabBar icons bigger and my code below crashes the application. This is my first time using custom renderers so I am not even entirely sure of what I am doing. But I looked up Java examples to try and do a C# equivalent. If anyone has a better alternative I would love to hear it, also if there is any material you think I could read which would make me better with understanding custom renderers please direct me to it! My code is below

Custom Renderer to make TabBar icons bigger

[assembly: ExportRenderer(typeof(AppShell), typeof(TabBarShellRenderer))]
namespace Nizz.Droid.Renderers
{
    public class TabBarShellRenderer : ShellRenderer
    {
        public TabBarShellRenderer(Context context) : base(context)
        {

        }

        protected override IShellTabLayoutAppearanceTracker CreateTabLayoutAppearanceTracker(ShellSection shellSection)
        {
            return new MyTabLayoutAppearanceTracker(this);
        }

        internal class MyTabLayoutAppearanceTracker : IShellTabLayoutAppearanceTracker
        {
            private TabBarShellRenderer _tabBarShellRenderer;
            public MyTabLayoutAppearanceTracker(TabBarShellRenderer tabBarShellRenderer)
            {
                _tabBarShellRenderer = tabBarShellRenderer;
            }

            public void SetAppearance(TabLayout tabLayout, ShellAppearance appearance)
            {
                tabLayout.GetChildAt(1).SetPadding(10, 10, 10, 10);
            }

            public void ResetAppearance(TabLayout tabLayout)
            {
                throw new System.NotImplementedException();
            }

            public void Dispose()
            {
                throw new System.NotImplementedException();
            }
        }
    }
}
Sign In or Register to comment.