using Android.Content;
using Payesh.App.Droid.Renders;
using Payesh.App.Renders;
using Microsoft.Maui;
using Microsoft.Maui.Controls;

[assembly: ExportRenderer(typeof(ExtendedLabel), typeof(ExtendedLabelRenderer))]
namespace Payesh.App.Droid.Renders
{

    public class ExtendedLabelRenderer : Platform.Android.LabelRenderer
    {
        public ExtendedLabelRenderer(Context context) : base(context)
        {
        }

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

            if (Element is ExtendedLabel el)
            {
                if (el.JustifyText)
                {
                    if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
                        Control.JustificationMode = Android.Text.JustificationMode.InterWord;

                }
            }
        }
    }

}