using Xamarin.Forms;

namespace Pixiview.UI.Theme
{
    public class ThemeBase : ResourceDictionary
    {
        public const string TitleButton = nameof(TitleButton);
        public const string TitleLabel = nameof(TitleLabel);

        public const string StatusBarStyle = nameof(StatusBarStyle);
        public const string WindowColor = nameof(WindowColor);
        public const string TextColor = nameof(TextColor);
        public const string SubTextColor = nameof(SubTextColor);
        public const string MainColor = nameof(MainColor);
        public const string MainTextColor = nameof(MainTextColor);
        public const string SubColor = nameof(SubColor);

        public const string IconLightFontFamily = nameof(IconLightFontFamily);
        public const string IconRegularFontFamily = nameof(IconRegularFontFamily);
        public const string IconSolidFontFamily = nameof(IconSolidFontFamily);
        public const string IconLeft = nameof(IconLeft);
        public const string FontSizeTitle = nameof(FontSizeTitle);
        public const string FontSizeTitleIcon = nameof(FontSizeTitleIcon);
        //public const string Horizon10 = nameof(Horizon10);

        protected void InitResources()
        {
            Add(FontSizeTitle, StyleDefinition.FontSizeTitle);
            Add(FontSizeTitleIcon, StyleDefinition.FontSizeTitleIcon);
            //Add(Horizon10, StyleDefinition.Horizon10);

            if (App.ExtraResources != null)
            {
                foreach (var kv in App.ExtraResources)
                {
                    Add(kv.Key, kv.Value);
                }
            }

            Add(TitleLabel, new Style(typeof(Label))
            {
                Setters =
                {
                    new Setter { Property = View.VerticalOptionsProperty, Value = LayoutOptions.Center },
                    new Setter { Property = View.HorizontalOptionsProperty, Value = LayoutOptions.Fill },
                    new Setter { Property = Label.HorizontalTextAlignmentProperty, Value = TextAlignment.Center },
                    new Setter { Property = Label.FontSizeProperty, Value = StyleDefinition.FontSizeTitle },
                    new Setter { Property = Label.TextColorProperty, Value = this[MainTextColor] }
                }
            });
            Add(TitleButton, new Style(typeof(Button))
            {
                Setters =
                {
                    new Setter { Property = Button.BorderWidthProperty, Value = 0.0 },
                    new Setter { Property = VisualElement.BackgroundColorProperty, Value = Color.Transparent },
                    new Setter { Property = Button.FontFamilyProperty, Value = this[IconSolidFontFamily] },
                    new Setter { Property = Button.FontSizeProperty, Value = StyleDefinition.FontSizeTitleIcon },
                    new Setter { Property = Button.TextColorProperty, Value = this[MainTextColor] }
                }
            });
        }
    }
}
