Пример #1
0
 public static void UpdateMaximumDate(this MauiDatePicker platformDatePicker, IDatePicker datePicker, UIDatePicker?picker)
 {
     if (picker != null)
     {
         picker.MaximumDate = datePicker.MaximumDate.ToNSDate();
     }
 }
Пример #2
0
 public static void UpdateMaximumDate(this MauiDatePicker platformDatePicker, IDatePicker datePicker, DatePickerDialog?datePickerDialog)
 {
     if (datePickerDialog != null)
     {
         datePickerDialog.DatePicker.MaxDate = (long)datePicker.MaximumDate.ToUniversalTime().Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds;
     }
 }
Пример #3
0
 public static void UpdateMinimumDate(this MauiDatePicker nativeDatePicker, IDatePicker datePicker, UIDatePicker?picker)
 {
     if (picker != null)
     {
         picker.MinimumDate = datePicker.MinimumDate.ToNSDate();
     }
 }
Пример #4
0
        public static void UpdateDate(this MauiDatePicker platformDatePicker, IDatePicker datePicker, UIDatePicker?picker)
        {
            if (picker != null && picker.Date.ToDateTime().Date != datePicker.Date.Date)
            {
                picker.SetDate(datePicker.Date.ToNSDate(), false);
            }

            platformDatePicker.Text = datePicker.Date.ToString(datePicker.Format);

            platformDatePicker.UpdateCharacterSpacing(datePicker);
        }
Пример #5
0
        public static void UpdateTextColor(this MauiDatePicker platformDatePicker, IDatePicker datePicker)
        {
            var textColor = datePicker.TextColor;

            if (textColor != null)
            {
                if (PlatformInterop.CreateEditTextColorStateList(platformDatePicker.TextColors, textColor.ToPlatform()) is ColorStateList c)
                {
                    platformDatePicker.SetTextColor(c);
                }
            }
        }
Пример #6
0
        public static void UpdateTextColor(this MauiDatePicker platformDatePicker, IDatePicker datePicker)
        {
            var textColor = datePicker.TextColor;

            if (textColor != null)
            {
                var androidColor = textColor.ToPlatform();
                if (!platformDatePicker.TextColors.IsOneColor(ColorStates.EditText, androidColor))
                {
                    platformDatePicker.SetTextColor(ColorStateListExtensions.CreateEditText(androidColor));
                }
            }
        }
Пример #7
0
        public static void UpdateTextColor(this MauiDatePicker platformDatePicker, IDatePicker datePicker, UIColor?defaultTextColor)
        {
            var textColor = datePicker.TextColor;

            if (textColor == null)
            {
                platformDatePicker.TextColor = defaultTextColor;
            }
            else
            {
                platformDatePicker.TextColor = textColor.ToPlatform();
            }

            // HACK This forces the color to update; there's probably a more elegant way to make this happen
            platformDatePicker.UpdateDate(datePicker);
        }
Пример #8
0
        public static void UpdateTextColor(this MauiDatePicker nativeDatePicker, IDatePicker datePicker, ColorStateList?defaultTextColor)
        {
            var textColor = datePicker.TextColor;

            if (textColor == null)
            {
                if (defaultTextColor != null)
                {
                    nativeDatePicker.SetTextColor(defaultTextColor);
                }
            }
            else
            {
                var androidColor = textColor.ToNative();
                if (!nativeDatePicker.TextColors.IsOneColor(ColorStates.EditText, androidColor))
                {
                    nativeDatePicker.SetTextColor(ColorStateListExtensions.CreateEditText(androidColor));
                }
            }
        }
Пример #9
0
        public static void UpdateDate(this MauiDatePicker platformDatePicker, IDatePicker datePicker, UIDatePicker?picker)
        {
            if (picker != null && picker.Date.ToDateTime().Date != datePicker.Date.Date)
            {
                picker.SetDate(datePicker.Date.ToNSDate(), false);
            }

            string format = datePicker.Format ?? string.Empty;

            // Can't use VirtualView.Format because it won't display the correct format if the region and language are set differently
            if (picker != null && string.IsNullOrWhiteSpace(format) || format.Equals("d", StringComparison.OrdinalIgnoreCase))
            {
                NSDateFormatter dateFormatter = new NSDateFormatter
                {
                    TimeZone = NSTimeZone.FromGMT(0)
                };

                if (format.Equals("D", StringComparison.Ordinal) == true)
                {
                    dateFormatter.DateStyle = NSDateFormatterStyle.Long;
                    var strDate = dateFormatter.StringFor(picker?.Date);
                    platformDatePicker.Text = strDate;
                }
                else
                {
                    dateFormatter.DateStyle = NSDateFormatterStyle.Short;
                    var strDate = dateFormatter.StringFor(picker?.Date);
                    platformDatePicker.Text = strDate;
                }
            }
            else if (format.Contains('/', StringComparison.Ordinal))
            {
                platformDatePicker.Text = datePicker.Date.ToString(format, CultureInfo.InvariantCulture);
            }
            else
            {
                platformDatePicker.Text = datePicker.Date.ToString(format);
            }

            platformDatePicker.UpdateCharacterSpacing(datePicker);
        }
Пример #10
0
 public static void UpdateFormat(this MauiDatePicker platformDatePicker, IDatePicker datePicker)
 {
     platformDatePicker.SetText(datePicker);
 }
Пример #11
0
 internal static void SetText(this MauiDatePicker platformDatePicker, IDatePicker datePicker)
 {
     platformDatePicker.Text = datePicker.Date.ToString(datePicker.Format);
 }
Пример #12
0
 public static void UpdateTextAlignment(this MauiDatePicker nativeDatePicker, IDatePicker datePicker)
 {
     // TODO: Update TextAlignment based on the EffectiveFlowDirection property.
 }
Пример #13
0
 public static void UpdateMaximumDate(this MauiDatePicker platformDatePicker, IDatePicker datePicker, UIDatePicker?picker)
 {
     picker?.UpdateMaximumDate(datePicker);
 }
Пример #14
0
 public static void UpdateFormat(this MauiDatePicker nativeDatePicker, IDatePicker datePicker)
 {
     nativeDatePicker.UpdateDate(datePicker, null);
 }
Пример #15
0
 public static void UpdateMaximumDate(this MauiDatePicker nativeDatePicker, IDatePicker datePicker)
 {
     nativeDatePicker.UpdateMaximumDate(datePicker, null);
 }
Пример #16
0
 public static void UpdateFormat(this MauiDatePicker nativeDatePicker, IDatePicker datePicker)
 {
     nativeDatePicker.SetText(datePicker);
 }
Пример #17
0
 public static void UpdateMaximumDate(this MauiDatePicker platformDatePicker, IDatePicker datePicker)
 {
     platformDatePicker.UpdateMaximumDate(datePicker, null);
 }
Пример #18
0
 public static void UpdateTextColor(this MauiDatePicker platformDatePicker, IDatePicker datePicker) =>
 UpdateTextColor(platformDatePicker, datePicker, null);
Пример #19
0
 public static void UpdateFormat(this MauiDatePicker platformDatePicker, IDatePicker datePicker)
 {
     platformDatePicker.UpdateDate(datePicker, null);
 }
Пример #20
0
 public static void UpdateTextColor(this MauiDatePicker nativeDatePicker, IDatePicker datePicker)
 {
     nativeDatePicker.UpdateTextColor(datePicker, null);
 }