using System;
using System.Globalization;
using Aurora.Design.Components.TabView;
using Xamarin.Forms;

namespace Aurora.Design.Converters
{
    class SelectedTabHeaderToTabBackgroundColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool isCurrentTabSelected = false;
            if (!string.IsNullOrWhiteSpace(value?.ToString()))
                bool.TryParse(value.ToString(), out isCurrentTabSelected);

            if (parameter is TabViewControl tvc && isCurrentTabSelected)
            {
                return tvc.HeaderSelectionUnderlineColor;
            }
            else
            {
                return Color.Transparent;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
