using Billing.iOS.Renderers;
using Billing.UI;
using System.ComponentModel;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(TintImage), typeof(TintImageRenderer))]
namespace Billing.iOS.Renderers
{
    public class TintImageRenderer : ImageRenderer
    {

        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName == nameof(TintImage.PrimaryColor) && Control != null && Element is TintImage image)
            {
                Control.TintColor = image.PrimaryColor?.ToUIColor();
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
        {
            base.OnElementChanged(e);

            if (Control != null && Element is TintImage image)
            {
                Control.TintColor = image.PrimaryColor?.ToUIColor();
            }
        }
    }
}