﻿using Xamarin.Forms;
using static VeridianDynamics.Views.Styles;

namespace VeridianDynamics.Views
{
    public class CardView : ContentView // TODO ResponsiveContentView
    {
        #region Constructors

        // TODO Bind to page directly inside DataTemplate instead of passing in page as argument
        // Sized controls don't work in this scope.  Use alternate binding instead.
        public CardView(BasePage page)
        {
            CardLayout.SetBinding(PaddingProperty,
                new Binding("LayoutPadding",
                    source: page));
            CardLayout.SetBinding(StackLayout.SpacingProperty,
                new Binding("LayoutSpacing",
                    source: page));

            var cardFrame = new Frame
            {
                Content = CardLayout,
                HasShadow = true,
                OutlineColor = Color.Black,
                Padding = new Thickness(3)
            };

            Content = cardFrame;
        }

        #endregion

        #region Public

        public void AddRow(View view)
        {
            CardLayout.Children.Add(view);
        }

        #endregion

        #region Private

        private StackLayout CardLayout { get; } = new StackLayout
        {
            BackgroundColor = CardBackgroundColor,
            Orientation = StackOrientation.Vertical
        };

        #endregion
    }
}