using Android.Content;
using Android.Graphics.Drawables;
using Billing.Droid.Renderers;
using Billing.UI;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(OptionPicker), typeof(OptionPickerRenderer))]
namespace Billing.Droid.Renderers
{
    public class OptionPickerRenderer : PickerRenderer
    {
        public OptionPickerRenderer(Context context) : base(context)
        {
        }

        protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
        {
            base.OnElementChanged(e);

            var control = Control;
            if (e.NewElement != null && control != null)
            {
                var drawable = new ColorDrawable(e.NewElement.BackgroundColor.ToAndroid());
                control.SetBackground(drawable);
            }
        }
    }
}
