using Billing.UI;
using Xamarin.Forms;

namespace Billing.Themes
{
    public abstract class BaseTheme : ResourceDictionary
    {
        public const string CascadiaFontRegular = nameof(CascadiaFontRegular);
        public const string CascadiaFontBold = nameof(CascadiaFontBold);
        public const string RobotoCondensedFontRegular = nameof(RobotoCondensedFontRegular);
        public const string RobotoCondensedFontBold = nameof(RobotoCondensedFontBold);

        public const string WindowBackgroundColor = nameof(WindowBackgroundColor);
        public const string OptionTintColor = nameof(OptionTintColor);
        public const string PromptBackgroundColor = nameof(PromptBackgroundColor);
        public const string PrimaryColor = nameof(PrimaryColor);
        public const string SecondaryColor = nameof(SecondaryColor);
        public const string TabBarBackgroundColor = nameof(TabBarBackgroundColor);
        public const string TabBarTitleColor = nameof(TabBarTitleColor);
        public const string TabBarUnselectedColor = nameof(TabBarUnselectedColor);
        public const string OutRangeDayColor = nameof(OutRangeDayColor);
        public const string TextColor = nameof(TextColor);
        public const string SecondaryTextColor = nameof(SecondaryTextColor);
        public const string RedColor = nameof(RedColor);

        protected abstract Color PrimaryMauiColor { get; }
        protected abstract Color SecondaryMauiColor { get; }

        protected void InitResources()
        {
            var robotoRegularFontFamily = Definition.GetRobotoCondensedRegularFontFamily();
            Add(CascadiaFontRegular, Definition.GetCascadiaRegularFontFamily());
            Add(CascadiaFontBold, Definition.GetCascadiaBoldFontFamily());
            Add(RobotoCondensedFontRegular, Definition.GetRobotoCondensedRegularFontFamily());
            Add(RobotoCondensedFontBold, Definition.GetRobotoCondensedBoldFontFamily());

            Add(PrimaryColor, PrimaryMauiColor);
            Add(SecondaryColor, SecondaryMauiColor);
            Add(TabBarTitleColor, PrimaryMauiColor);

            Add(new Style(typeof(Label))
            {
                Setters =
                {
                    new Setter { Property = Label.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(Label)) },
                    new Setter { Property = Label.TextColorProperty, Value = PrimaryMauiColor },
                    new Setter { Property = Label.FontFamilyProperty, Value = robotoRegularFontFamily }
                }
            });
            Add(new Style(typeof(OptionEntry))
            {
                Setters =
                {
                    new Setter { Property = Entry.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(Entry)) },
                    new Setter { Property = Entry.FontFamilyProperty, Value = robotoRegularFontFamily }
                }
            });
            Add(new Style(typeof(OptionEditor))
            {
                Setters =
                {
                    new Setter { Property = Editor.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(Entry)) },
                    new Setter { Property = Editor.FontFamilyProperty, Value = robotoRegularFontFamily }
                }
            });
            Add(new Style(typeof(Button))
            {
                Setters =
                {
                    new Setter { Property = Button.TextColorProperty, Value = SecondaryMauiColor },
                    new Setter { Property = Button.FontFamilyProperty, Value = robotoRegularFontFamily },
                    new Setter { Property = VisualElement.BackgroundColorProperty, Value = PrimaryMauiColor },
                    new Setter { Property = Button.PaddingProperty, Value = new Thickness(14, 10) }
                }
            });
            Add(new Style(typeof(TintImage))
            {
                Setters =
                {
                    new Setter { Property = TintImage.PrimaryColorProperty, Value = PrimaryMauiColor }
                }
            });
        }
    }
}