using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;

namespace Sonex.Client.Controls;

public sealed class PropertyBoxContentExpander : ContentControl
{
    private static readonly Style DefaultControlStyle = LoadDefaultStyle();

    public PropertyBoxContentExpander()
    {
        Style = DefaultControlStyle;
    }

    private static Style LoadDefaultStyle()
    {
        var dictionary = new ResourceDictionary
        {
            Source = new Uri("ms-appx:///Controls/PropertyBoxContentExpander.xaml")
        };

        return (Style)dictionary["PropertyBoxContentExpanderStyle"];
    }

    public string Title
    {
        get => (string)GetValue(TitleProperty);
        set => SetValue(TitleProperty, value);
    }

    public static readonly DependencyProperty TitleProperty =
        DependencyProperty.Register(
            nameof(Title),
            typeof(string),
            typeof(PropertyBoxContentExpander),
            new PropertyMetadata(string.Empty));

    public string Description
    {
        get => (string)GetValue(DescriptionProperty);
        set => SetValue(DescriptionProperty, value);
    }

    public static readonly DependencyProperty DescriptionProperty =
        DependencyProperty.Register(
            nameof(Description),
            typeof(string),
            typeof(PropertyBoxContentExpander),
            new PropertyMetadata(string.Empty));

    public UIElement? Icon
    {
        get => (UIElement?)GetValue(IconProperty);
        set => SetValue(IconProperty, value);
    }

    public static readonly DependencyProperty IconProperty =
        DependencyProperty.Register(
            nameof(Icon),
            typeof(UIElement),
            typeof(PropertyBoxContentExpander),
            new PropertyMetadata(null));



    public UIElement? Footer
    {
        get => (UIElement?)GetValue(FooterProperty);
        set => SetValue(FooterProperty, value);
    }

    public static readonly DependencyProperty FooterProperty =
        DependencyProperty.Register(
            nameof(Footer),
            typeof(UIElement),
            typeof(PropertyBoxContentExpander),
            new PropertyMetadata(null));


    public UIElement? Body
    {
        get => (UIElement?)GetValue(BodyProperty);
        set => SetValue(BodyProperty, value);
    }

    public static readonly DependencyProperty BodyProperty =
        DependencyProperty.Register(
            nameof(Body),
            typeof(UIElement),
            typeof(PropertyBoxContentExpander),
            new PropertyMetadata(null));

    public VerticalAlignment BodyVerticalAlignment
    {
        get => (VerticalAlignment)GetValue(BodyVerticalAlignmentProperty);
        set => SetValue(BodyVerticalAlignmentProperty, value);
    }

    public static readonly DependencyProperty BodyVerticalAlignmentProperty =
        DependencyProperty.Register(
            nameof(BodyVerticalAlignment),
            typeof(VerticalAlignment),
            typeof(PropertyBoxContentExpander),
            new PropertyMetadata(VerticalAlignment.Top));

    public HorizontalAlignment BodyHorizontalAlignment
    {
        get => (HorizontalAlignment)GetValue(BodyHorizontalAlignmentProperty);
        set => SetValue(BodyHorizontalAlignmentProperty, value);
    }

    public static readonly DependencyProperty BodyHorizontalAlignmentProperty =
        DependencyProperty.Register(
            nameof(BodyHorizontalAlignment),
            typeof(HorizontalAlignment),
            typeof(PropertyBoxContentExpander),
            new PropertyMetadata(HorizontalAlignment.Stretch));
}
