+++ /dev/null
-using System;
-using Xamarin.Forms.Internals;
-using Xamarin.Forms.Platform;
-
-namespace Xamarin.Forms
-{
- [RenderWith(typeof(_DatePickerRenderer))]
- public class DatePicker : View, IFontElement, ITextElement, IElementConfiguration<DatePicker>
- {
- public static readonly BindableProperty FormatProperty = BindableProperty.Create(nameof(Format), typeof(string), typeof(DatePicker), "d");
-
- public static readonly BindableProperty DateProperty = BindableProperty.Create(nameof(Date), typeof(DateTime), typeof(DatePicker), default(DateTime), BindingMode.TwoWay,
- coerceValue: CoerceDate,
- propertyChanged: DatePropertyChanged,
- defaultValueCreator: (bindable) => DateTime.Today);
-
- public static readonly BindableProperty MinimumDateProperty = BindableProperty.Create(nameof(MinimumDate), typeof(DateTime), typeof(DatePicker), new DateTime(1900, 1, 1),
- validateValue: ValidateMinimumDate, coerceValue: CoerceMinimumDate);
-
- public static readonly BindableProperty MaximumDateProperty = BindableProperty.Create(nameof(MaximumDate), typeof(DateTime), typeof(DatePicker), new DateTime(2100, 12, 31),
- validateValue: ValidateMaximumDate, coerceValue: CoerceMaximumDate);
-
- public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
-
- public static readonly BindableProperty FontFamilyProperty = FontElement.FontFamilyProperty;
-
- public static readonly BindableProperty FontSizeProperty = FontElement.FontSizeProperty;
-
- public static readonly BindableProperty FontAttributesProperty = FontElement.FontAttributesProperty;
-
- readonly Lazy<PlatformConfigurationRegistry<DatePicker>> _platformConfigurationRegistry;
-
- public DatePicker()
- {
- _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<DatePicker>>(() => new PlatformConfigurationRegistry<DatePicker>(this));
- }
-
- public DateTime Date
- {
- get { return (DateTime)GetValue(DateProperty); }
- set { SetValue(DateProperty, value); }
- }
-
- public string Format
- {
- get { return (string)GetValue(FormatProperty); }
- set { SetValue(FormatProperty, value); }
- }
-
- public DateTime MaximumDate
- {
- get { return (DateTime)GetValue(MaximumDateProperty); }
- set { SetValue(MaximumDateProperty, value); }
- }
-
- public DateTime MinimumDate
- {
- get { return (DateTime)GetValue(MinimumDateProperty); }
- set { SetValue(MinimumDateProperty, value); }
- }
-
- public Color TextColor
- {
- get { return (Color)GetValue(TextElement.TextColorProperty); }
- set { SetValue(TextElement.TextColorProperty, value); }
- }
-
- public double CharacterSpacing { get; set; }
-
- public FontAttributes FontAttributes
- {
- get { return (FontAttributes)GetValue(FontAttributesProperty); }
- set { SetValue(FontAttributesProperty, value); }
- }
-
- public string FontFamily
- {
- get { return (string)GetValue(FontFamilyProperty); }
- set { SetValue(FontFamilyProperty, value); }
- }
-
- [TypeConverter(typeof(FontSizeConverter))]
- public double FontSize
- {
- get { return (double)GetValue(FontSizeProperty); }
- set { SetValue(FontSizeProperty, value); }
- }
-
- void IFontElement.OnFontFamilyChanged(string oldValue, string newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- void IFontElement.OnFontSizeChanged(double oldValue, double newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- void IFontElement.OnFontChanged(Font oldValue, Font newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- double IFontElement.FontSizeDefaultValueCreator() =>
- Device.GetNamedSize(NamedSize.Default, (DatePicker)this);
-
- void IFontElement.OnFontAttributesChanged(FontAttributes oldValue, FontAttributes newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- public event EventHandler<DateChangedEventArgs> DateSelected;
-
- static object CoerceDate(BindableObject bindable, object value)
- {
- var picker = (DatePicker)bindable;
- DateTime dateValue = ((DateTime)value).Date;
-
- if (dateValue > picker.MaximumDate)
- dateValue = picker.MaximumDate;
-
- if (dateValue < picker.MinimumDate)
- dateValue = picker.MinimumDate;
-
- return dateValue;
- }
-
- static object CoerceMaximumDate(BindableObject bindable, object value)
- {
- DateTime dateValue = ((DateTime)value).Date;
- var picker = (DatePicker)bindable;
- if (picker.Date > dateValue)
- picker.Date = dateValue;
-
- return dateValue;
- }
-
- static object CoerceMinimumDate(BindableObject bindable, object value)
- {
- DateTime dateValue = ((DateTime)value).Date;
- var picker = (DatePicker)bindable;
- if (picker.Date < dateValue)
- picker.Date = dateValue;
-
- return dateValue;
- }
-
- static void DatePropertyChanged(BindableObject bindable, object oldValue, object newValue)
- {
- var datePicker = (DatePicker)bindable;
- EventHandler<DateChangedEventArgs> selected = datePicker.DateSelected;
-
- if (selected != null)
- selected(datePicker, new DateChangedEventArgs((DateTime)oldValue, (DateTime)newValue));
- }
-
- static bool ValidateMaximumDate(BindableObject bindable, object value)
- {
- return ((DateTime)value).Date >= ((DatePicker)bindable).MinimumDate.Date;
- }
-
- static bool ValidateMinimumDate(BindableObject bindable, object value)
- {
- return ((DateTime)value).Date <= ((DatePicker)bindable).MaximumDate.Date;
- }
-
- public IPlatformElementConfiguration<T, DatePicker> On<T>() where T : IConfigPlatform
- {
- return _platformConfigurationRegistry.Value.On<T>();
- }
-
- void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
- {
- }
-
- void ITextElement.OnCharacterSpacingPropertyChanged(double oldValue, double newValue)
- {
- }
-
- }
-}
\ No newline at end of file
+++ /dev/null
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Collections.Specialized;
-using System.ComponentModel;
-using System.Runtime.CompilerServices;
-using Xamarin.Forms.Internals;
-using Xamarin.Forms.Platform;
-
-namespace Xamarin.Forms
-{
- [RenderWith(typeof(_PickerRenderer))]
- public class Picker : View, IFontElement, ITextElement, IElementConfiguration<Picker>
- {
- public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
-
- public static readonly BindableProperty TitleProperty =
- BindableProperty.Create(nameof(Title), typeof(string), typeof(Picker), default(string));
-
- public static readonly BindableProperty TitleColorProperty =
- BindableProperty.Create(nameof(TitleColor), typeof(Color), typeof(Picker), default(Color));
-
- public static readonly BindableProperty SelectedIndexProperty =
- BindableProperty.Create(nameof(SelectedIndex), typeof(int), typeof(Picker), -1, BindingMode.TwoWay,
- propertyChanged: OnSelectedIndexChanged, coerceValue: CoerceSelectedIndex);
-
- public static readonly BindableProperty ItemsSourceProperty =
- BindableProperty.Create(nameof(ItemsSource), typeof(IList), typeof(Picker), default(IList),
- propertyChanged: OnItemsSourceChanged);
-
- public static readonly BindableProperty SelectedItemProperty =
- BindableProperty.Create(nameof(SelectedItem), typeof(object), typeof(Picker), null, BindingMode.TwoWay,
- propertyChanged: OnSelectedItemChanged);
-
- public static readonly BindableProperty FontFamilyProperty = FontElement.FontFamilyProperty;
-
- public static readonly BindableProperty FontSizeProperty = FontElement.FontSizeProperty;
-
- public static readonly BindableProperty FontAttributesProperty = FontElement.FontAttributesProperty;
-
- readonly Lazy<PlatformConfigurationRegistry<Picker>> _platformConfigurationRegistry;
-
- public Picker()
- {
- ((INotifyCollectionChanged)Items).CollectionChanged += OnItemsCollectionChanged;
- _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Picker>>(() => new PlatformConfigurationRegistry<Picker>(this));
- }
- public FontAttributes FontAttributes
- {
- get { return (FontAttributes)GetValue(FontAttributesProperty); }
- set { SetValue(FontAttributesProperty, value); }
- }
-
- public string FontFamily
- {
- get { return (string)GetValue(FontFamilyProperty); }
- set { SetValue(FontFamilyProperty, value); }
- }
-
- [TypeConverter(typeof(FontSizeConverter))]
- public double FontSize
- {
- get { return (double)GetValue(FontSizeProperty); }
- set { SetValue(FontSizeProperty, value); }
- }
-
- void IFontElement.OnFontFamilyChanged(string oldValue, string newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- void IFontElement.OnFontSizeChanged(double oldValue, double newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- void IFontElement.OnFontChanged(Font oldValue, Font newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- double IFontElement.FontSizeDefaultValueCreator() =>
- Device.GetNamedSize(NamedSize.Default, (Picker)this);
-
- void IFontElement.OnFontAttributesChanged(FontAttributes oldValue, FontAttributes newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- public IList<string> Items { get; } = new LockableObservableListWrapper();
-
- public IList ItemsSource
- {
- get { return (IList)GetValue(ItemsSourceProperty); }
- set { SetValue(ItemsSourceProperty, value); }
- }
-
- public int SelectedIndex
- {
- get { return (int)GetValue(SelectedIndexProperty); }
- set { SetValue(SelectedIndexProperty, value); }
- }
-
- public object SelectedItem
- {
- get { return GetValue(SelectedItemProperty); }
- set { SetValue(SelectedItemProperty, value); }
- }
-
- public Color TextColor
- {
- get { return (Color)GetValue(TextElement.TextColorProperty); }
- set { SetValue(TextElement.TextColorProperty, value); }
- }
-
- public double CharacterSpacing
- {
- get { return (double)GetValue(TextElement.CharacterSpacingProperty); }
- set { SetValue(TextElement.CharacterSpacingProperty, value); }
- }
-
- public string Title
- {
- get { return (string)GetValue(TitleProperty); }
- set { SetValue(TitleProperty, value); }
- }
-
- public Color TitleColor
- {
- get { return (Color)GetValue(TitleColorProperty); }
- set { SetValue(TitleColorProperty, value); }
- }
-
- BindingBase _itemDisplayBinding;
- public BindingBase ItemDisplayBinding {
- get { return _itemDisplayBinding; }
- set {
- if (_itemDisplayBinding == value)
- return;
-
- OnPropertyChanging();
- var oldValue = value;
- _itemDisplayBinding = value;
- OnItemDisplayBindingChanged(oldValue, _itemDisplayBinding);
- OnPropertyChanged();
- }
- }
-
- public event EventHandler SelectedIndexChanged;
-
- static readonly BindableProperty s_displayProperty =
- BindableProperty.Create("Display", typeof(string), typeof(Picker), default(string));
-
- string GetDisplayMember(object item)
- {
- if (ItemDisplayBinding == null)
- return item.ToString();
-
- ItemDisplayBinding.Apply(item, this, s_displayProperty);
- ItemDisplayBinding.Unapply();
- return (string)GetValue(s_displayProperty);
- }
-
- static object CoerceSelectedIndex(BindableObject bindable, object value)
- {
- var picker = (Picker)bindable;
- return picker.Items == null ? -1 : ((int)value).Clamp(-1, picker.Items.Count - 1);
- }
-
- void OnItemDisplayBindingChanged(BindingBase oldValue, BindingBase newValue)
- {
- ResetItems();
- }
-
- void OnItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- var oldIndex = SelectedIndex;
- var newIndex = SelectedIndex = SelectedIndex.Clamp(-1, Items.Count - 1);
- // If the index has not changed, still need to change the selected item
- if (newIndex == oldIndex)
- UpdateSelectedItem(newIndex);
- }
-
- static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue)
- {
- ((Picker)bindable).OnItemsSourceChanged((IList)oldValue, (IList)newValue);
- }
-
- void OnItemsSourceChanged(IList oldValue, IList newValue)
- {
- var oldObservable = oldValue as INotifyCollectionChanged;
- if (oldObservable != null)
- oldObservable.CollectionChanged -= CollectionChanged;
-
- var newObservable = newValue as INotifyCollectionChanged;
- if (newObservable != null) {
- newObservable.CollectionChanged += CollectionChanged;
- }
-
- if (newValue != null) {
- ((LockableObservableListWrapper)Items).IsLocked = true;
- ResetItems();
- } else {
- ((LockableObservableListWrapper)Items).InternalClear();
- ((LockableObservableListWrapper)Items).IsLocked = false;
- }
- }
-
- void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- switch (e.Action) {
- case NotifyCollectionChangedAction.Add:
- AddItems(e);
- break;
- case NotifyCollectionChangedAction.Remove:
- RemoveItems(e);
- break;
- default: //Move, Replace, Reset
- ResetItems();
- break;
- }
- }
- void AddItems(NotifyCollectionChangedEventArgs e)
- {
- int index = e.NewStartingIndex < 0 ? Items.Count : e.NewStartingIndex;
- foreach (object newItem in e.NewItems)
- ((LockableObservableListWrapper)Items).InternalInsert(index++, GetDisplayMember(newItem));
- }
-
- void RemoveItems(NotifyCollectionChangedEventArgs e)
- {
- int index = e.OldStartingIndex < Items.Count ? e.OldStartingIndex : Items.Count;
- foreach (object _ in e.OldItems)
- ((LockableObservableListWrapper)Items).InternalRemoveAt(index--);
- }
-
- void ResetItems()
- {
- if (ItemsSource == null)
- return;
- ((LockableObservableListWrapper)Items).InternalClear();
- foreach (object item in ItemsSource)
- ((LockableObservableListWrapper)Items).InternalAdd(GetDisplayMember(item));
- UpdateSelectedItem(SelectedIndex);
- }
-
- static void OnSelectedIndexChanged(object bindable, object oldValue, object newValue)
- {
- var picker = (Picker)bindable;
- picker.UpdateSelectedItem(picker.SelectedIndex);
- picker.SelectedIndexChanged?.Invoke(bindable, EventArgs.Empty);
- }
-
- static void OnSelectedItemChanged(BindableObject bindable, object oldValue, object newValue)
- {
- var picker = (Picker)bindable;
- picker.UpdateSelectedIndex(newValue);
- }
-
- void UpdateSelectedIndex(object selectedItem)
- {
- if (ItemsSource != null) {
- SelectedIndex = ItemsSource.IndexOf(selectedItem);
- return;
- }
- SelectedIndex = Items.IndexOf(selectedItem);
- }
-
- void UpdateSelectedItem(int index)
- {
- if (index == -1) {
- SelectedItem = null;
- return;
- }
-
- if (ItemsSource != null) {
- SelectedItem = ItemsSource [index];
- return;
- }
-
- SelectedItem = Items [index];
- }
-
- public IPlatformElementConfiguration<T, Picker> On<T>() where T : IConfigPlatform
- {
- return _platformConfigurationRegistry.Value.On<T>();
- }
-
- void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
- {
- }
-
- void ITextElement.OnCharacterSpacingPropertyChanged(double oldValue, double newValue)
- {
- }
-
- }
-}
\ No newline at end of file
+++ /dev/null
-using System;
-using Xamarin.Forms.Internals;
-using Xamarin.Forms.Platform;
-
-namespace Xamarin.Forms
-{
- [RenderWith(typeof(_TimePickerRenderer))]
- public class TimePicker : View, IFontElement, ITextElement, IElementConfiguration<TimePicker>
- {
- public static readonly BindableProperty FormatProperty = BindableProperty.Create(nameof(Format), typeof(string), typeof(TimePicker), "t");
-
- public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
-
- public static readonly BindableProperty TimeProperty = BindableProperty.Create(nameof(Time), typeof(TimeSpan), typeof(TimePicker), new TimeSpan(0), BindingMode.TwoWay, (bindable, value) =>
- {
- var time = (TimeSpan)value;
- return time.TotalHours < 24 && time.TotalMilliseconds >= 0;
- });
-
- public static readonly BindableProperty FontFamilyProperty = FontElement.FontFamilyProperty;
-
- public static readonly BindableProperty FontSizeProperty = FontElement.FontSizeProperty;
-
- public static readonly BindableProperty FontAttributesProperty = FontElement.FontAttributesProperty;
-
- readonly Lazy<PlatformConfigurationRegistry<TimePicker>> _platformConfigurationRegistry;
-
- public TimePicker()
- {
- _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<TimePicker>>(() => new PlatformConfigurationRegistry<TimePicker>(this));
- }
-
- public string Format
- {
- get { return (string)GetValue(FormatProperty); }
- set { SetValue(FormatProperty, value); }
- }
-
- public Color TextColor
- {
- get { return (Color)GetValue(TextElement.TextColorProperty); }
- set { SetValue(TextElement.TextColorProperty, value); }
- }
-
- public double CharacterSpacing { get; set; }
-
- public TimeSpan Time
- {
- get { return (TimeSpan)GetValue(TimeProperty); }
- set { SetValue(TimeProperty, value); }
- }
-
- public FontAttributes FontAttributes
- {
- get { return (FontAttributes)GetValue(FontAttributesProperty); }
- set { SetValue(FontAttributesProperty, value); }
- }
-
- public string FontFamily
- {
- get { return (string)GetValue(FontFamilyProperty); }
- set { SetValue(FontFamilyProperty, value); }
- }
-
- [TypeConverter(typeof(FontSizeConverter))]
- public double FontSize
- {
- get { return (double)GetValue(FontSizeProperty); }
- set { SetValue(FontSizeProperty, value); }
- }
-
- void IFontElement.OnFontFamilyChanged(string oldValue, string newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- void IFontElement.OnFontSizeChanged(double oldValue, double newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- void IFontElement.OnFontChanged(Font oldValue, Font newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- double IFontElement.FontSizeDefaultValueCreator() =>
- Device.GetNamedSize(NamedSize.Default, (TimePicker)this);
-
- void IFontElement.OnFontAttributesChanged(FontAttributes oldValue, FontAttributes newValue) =>
- InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
-
- public IPlatformElementConfiguration<T, TimePicker> On<T>() where T : IConfigPlatform
- {
- return _platformConfigurationRegistry.Value.On<T>();
- }
-
- void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
- {
- }
-
- void ITextElement.OnCharacterSpacingPropertyChanged(double oldValue, double newValue)
- {
- }
-
- }
-}
\ No newline at end of file
typeof(Slider),
typeof(Stepper),
typeof(Switch),
- typeof(DatePicker),
- typeof(TimePicker),
typeof(Entry),
typeof(Editor),
typeof(ActivityIndicator),
typeof(CarouselView),
typeof(CollectionView),
typeof(ListView),
- typeof(Picker),
typeof(TableView),
typeof(TextCell),
typeof(ImageCell),
+++ /dev/null
-using System;
-
-namespace Xamarin.Forms.Platform.Tizen.Native
-{
- /// <summary>
- /// Event arguments for <see cref="DatePicker.DateChanged"/> event.
- /// </summary>
- public class DateChangedEventArgs : EventArgs
- {
- /// <summary>
- /// The date that the user entered.
- /// </summary>
- public DateTime NewDate { get; }
-
- /// <summary>
- /// Creates a new <see cref="DateChangedEventArgs"/> object that represents a change from <paramref name="oldDate"/> to <paramref name="newDate"/>.
- /// </summary>
- /// <param name="oldDate">Old date of <see cref="DatePicker"/>.</param>
- /// <param name="newDate">Current date of <see cref="DatePicker"/>.</param>
- public DateChangedEventArgs(DateTime newDate)
- {
- NewDate = newDate;
- }
- }
-}
+++ /dev/null
-using System;
-using ElmSharp;
-
-namespace Xamarin.Forms.Platform.Tizen.Native
-{
- public enum DateTimePickerMode
- {
- Date,
- Time
- }
-
- public class DateTimePicker : DateTimeSelector
- {
- const string TimeFormat = "%d/%b/%Y %I:%M %p";
- const string TimeLayoutStyle = "time_layout";
-
- const string DateFormat = "%d/%b/%Y";
- const string DateLayoutStyle = "date_layout";
-
- DateTimePickerMode _mode = DateTimePickerMode.Date;
-
- public DateTimePicker(EvasObject parent) : base(parent)
- {
- UpdateMode();
- }
-
- protected DateTimePicker() : base()
- {
- }
-
- public DateTimePickerMode Mode
- {
- get { return _mode; }
- set
- {
- if (_mode != value)
- {
- _mode = value;
- UpdateMode();
- }
- }
- }
-
- public TimeSpan Time
- {
- get
- {
- return DateTime.TimeOfDay;
- }
- set
- {
- DateTime -= DateTime.TimeOfDay;
- DateTime += value;
- }
- }
-
- protected virtual void UpdateMode()
- {
- if (Mode == DateTimePickerMode.Date)
- {
- Style = DateLayoutStyle;
- Format = DateFormat;
- }
- else
- {
- Style = TimeLayoutStyle;
- Format = TimeFormat;
- }
- }
- }
-}
+++ /dev/null
-using System;
-using ElmSharp;
-using EButton = ElmSharp.Button;
-
-namespace Xamarin.Forms.Platform.Tizen.Native
-{
- public class DateTimePickerDialog : Dialog, IDateTimeDialog
- {
- EvasObject _parent;
- /// <summary>
- /// Creates a dialog window.
- /// </summary>
- public DateTimePickerDialog(EvasObject parent) : base(parent)
- {
- _parent = parent;
- Initialize();
- }
-
- public DateTimePicker Picker { get; protected set; }
-
- /// <summary>
- /// Occurs when the date of this dialog has changed.
- /// </summary>
- public event EventHandler<DateChangedEventArgs> DateTimeChanged;
-
- protected virtual DateTimePicker CreatePicker(EvasObject parent)
- {
- return new DateTimePicker(parent);
- }
-
- void Initialize()
- {
- Picker = CreatePicker(_parent);
- Picker.Show();
- Content = Picker;
-
- //TODO need to add internationalization support
- PositiveButton = new EButton(_parent) { Text = "Set" };
- PositiveButton.Clicked += (s, e) =>
- {
- Confirm();
- };
-
- //TODO need to add internationalization support
- NegativeButton = new EButton(_parent) { Text = "Cancel" };
- NegativeButton.Clicked += (s, e) =>
- {
- Hide();
- };
- BackButtonPressed += (object s, EventArgs e) =>
- {
- Hide();
- };
-
- // TODO This is Tizen TV Limitation.
- // UX is defined and the focus move processing is complete, it should be removed(After Tizen 5.0)
- if (Device.Idiom == TargetIdiom.TV)
- {
- KeyDown += (s, e) =>
- {
- if (e.KeyName == "Return")
- {
- if (Picker != null && Picker.IsFocused)
- {
- Confirm();
- e.Flags |= EvasEventFlag.OnHold;
- }
- }
- };
- }
- }
-
- void Confirm()
- {
- DateTimeChanged?.Invoke(this, new DateChangedEventArgs(Picker.DateTime));
- Hide();
- }
- }
-}
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using ElmSharp;
-
-namespace Xamarin.Forms.Platform.Tizen.Native
-{
- public interface IDateTimeDialog
- {
- string Title { get; set; }
- DateTimePicker Picker { get; }
- event EventHandler<DateChangedEventArgs> DateTimeChanged;
- void Show();
- void Hide();
- void Unrealize();
- }
-}
+++ /dev/null
-using System;
-using ElmSharp;
-using ElmSharp.Wearable;
-using ELayout = ElmSharp.Layout;
-using EButton = ElmSharp.Button;
-
-namespace Xamarin.Forms.Platform.Tizen.Native.Watch
-{
- public class WatchDataTimePickerDialog : Popup, IDateTimeDialog
- {
- ELayout _surfaceLayout;
- ELayout _datetimeLayout;
- CircleSurface _surface;
- EButton _doneButton;
- Box _container;
- string _title;
-
- public WatchDataTimePickerDialog(EvasObject parent) : base(parent)
- {
- AlignmentX = -1;
- AlignmentY = -1;
- WeightX = 1.0;
- WeightY = 1.0;
- Style = "circle";
-
- _container = new Box(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 };
- _container.BackgroundColor = ElmSharp.Color.Blue;
- _container.SetLayoutCallback(OnContainerLayout);
-
- _datetimeLayout = new ELayout(parent);
- _surfaceLayout = new ELayout(parent);
-
- _container.PackEnd(_datetimeLayout);
- _container.PackEnd(_surfaceLayout);
-
- _datetimeLayout.SetTheme("layout", "circle", "datetime");
- _surface = new CircleSurface(_surfaceLayout);
-
- WatchPicker = new WatchDateTimePicker(parent, _surface);
- WatchPicker.Show();
- _datetimeLayout.SetContent(WatchPicker);
-
- _doneButton = new Button(parent)
- {
- Text = "Set",
- Style = "bottom",
- };
- _datetimeLayout.SetPartContent("elm.swallow.btn", _doneButton);
- _doneButton.Clicked += OnDoneClicked;
-
- ((IRotaryActionWidget)WatchPicker.CircleSelector).Activate();
-
- _datetimeLayout.Show();
- _surfaceLayout.Show();
- _container.Show();
-
- SetContent(_container);
- BackButtonPressed += OnBackButtonPressed;
- }
-
- public string Title
- {
- get => _title;
- set
- {
- _title = value;
- _datetimeLayout.SetPartText("elm.text", _title);
- }
- }
-
- public DateTimePicker Picker => WatchPicker;
- protected WatchDateTimePicker WatchPicker { get; }
-
- public event EventHandler<DateChangedEventArgs> DateTimeChanged;
-
- void OnContainerLayout()
- {
- _surfaceLayout.Geometry = _container.Geometry;
- _datetimeLayout.Geometry = _container.Geometry;
- }
-
- void OnDoneClicked(object sender, EventArgs e)
- {
- System.Console.WriteLine("Done clicked");
- System.Console.WriteLine("Picker.DateTime - {0} ", Picker.DateTime);
- DateTimeChanged?.Invoke(this, new DateChangedEventArgs(Picker.DateTime));
- Hide();
- }
-
- void OnBackButtonPressed(object sender, EventArgs e)
- {
- Hide();
- }
- }
-}
+++ /dev/null
-using System;
-using ElmSharp;
-using ElmSharp.Wearable;
-
-namespace Xamarin.Forms.Platform.Tizen.Native.Watch
-{
- public class WatchDateTimePicker : DateTimePicker
- {
- readonly CircleSurface _surface;
- public WatchDateTimePicker(EvasObject parent, CircleSurface surface) : base()
- {
- _surface = surface;
- Realize(parent);
- UpdateMode();
- }
-
- public CircleDateTimeSelector CircleSelector { get; private set; }
-
- protected override void UpdateMode()
- {
- if (Mode == DateTimePickerMode.Date)
- {
- Style = "datepicker/circle";
- }
- else
- {
- Style = "timepicker/circle";
- }
- }
-
- protected override IntPtr CreateHandle(EvasObject parent)
- {
- CircleSelector = new CircleDateTimeSelector(parent, _surface);
- if (CircleSelector.RealHandle != CircleSelector.Handle)
- {
- RealHandle = CircleSelector.RealHandle;
- }
- return CircleSelector.Handle;
- }
- }
-}
[assembly: ExportRenderer(typeof(Button), typeof(ButtonRenderer))]
[assembly: ExportRenderer(typeof(Image), typeof(ImageRenderer))]
[assembly: ExportRenderer(typeof(Slider), typeof(SliderRenderer))]
-[assembly: ExportRenderer(typeof(Picker), typeof(PickerRenderer))]
[assembly: ExportRenderer(typeof(Frame), typeof(FrameRenderer))]
[assembly: ExportRenderer(typeof(Stepper), typeof(StepperRenderer))]
-[assembly: ExportRenderer(typeof(DatePicker), typeof(DatePickerRenderer))]
-[assembly: ExportRenderer(typeof(TimePicker), typeof(TimePickerRenderer))]
[assembly: ExportRenderer(typeof(ProgressBar), typeof(ProgressBarRenderer))]
[assembly: ExportRenderer(typeof(Switch), typeof(SwitchRenderer))]
[assembly: ExportRenderer(typeof(ListView), typeof(ListViewRenderer))]
+++ /dev/null
-using System;
-using Xamarin.Forms.Platform.Tizen.Native;
-using WatchDataTimePickerDialog = Xamarin.Forms.Platform.Tizen.Native.Watch.WatchDataTimePickerDialog;
-
-namespace Xamarin.Forms.Platform.Tizen
-{
- public class DatePickerRenderer : ViewRenderer<DatePicker, EditfieldEntry>
- {
- //TODO need to add internationalization support
- const string DialogTitle = "Choose Date";
- Lazy<IDateTimeDialog> _lazyDialog;
-
- public DatePickerRenderer()
- {
- RegisterPropertyHandler(DatePicker.DateProperty, UpdateDate);
- RegisterPropertyHandler(DatePicker.FormatProperty, UpdateDate);
- RegisterPropertyHandler(DatePicker.TextColorProperty, UpdateTextColor);
- RegisterPropertyHandler(DatePicker.FontAttributesProperty, UpdateFontAttributes);
- RegisterPropertyHandler(DatePicker.FontFamilyProperty, UpdateFontFamily);
- RegisterPropertyHandler(DatePicker.FontSizeProperty, UpdateFontSize);
- }
-
- protected virtual IDateTimeDialog CreateDialog()
- {
- if (Device.Idiom == TargetIdiom.Watch)
- {
- return new WatchDataTimePickerDialog(Forms.NativeParent);
- }
- else
- {
- return new DateTimePickerDialog(Forms.NativeParent);
- }
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs<DatePicker> e)
- {
- if (Control == null)
- {
- var entry = new Native.EditfieldEntry(Forms.NativeParent)
- {
- IsSingleLine = true,
- HorizontalTextAlignment = Native.TextAlignment.Center,
- InputPanelShowByOnDemand = true,
- };
- entry.SetVerticalTextAlignment("elm.text", 0.5);
- entry.TextBlockFocused += OnTextBlockFocused;
- SetNativeControl(entry);
-
- _lazyDialog = new Lazy<IDateTimeDialog>(() =>
- {
- var dialog = CreateDialog();
- dialog.Title = DialogTitle;
- dialog.DateTimeChanged += OnDateTimeChanged;
- return dialog;
- });
- }
- base.OnElementChanged(e);
- }
-
- protected override Size MinimumSize()
- {
- return Control.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- Control.TextBlockFocused -= OnTextBlockFocused;
- }
- if (_lazyDialog.IsValueCreated)
- {
- _lazyDialog.Value.DateTimeChanged -= OnDateTimeChanged;
- _lazyDialog.Value.Unrealize();
- }
- }
- base.Dispose(disposing);
- }
-
- void OnTextBlockFocused(object sender, EventArgs e)
- {
- // For EFL Entry, the event will occur even if it is currently disabled.
- // If the problem is resolved, no conditional statement is required.
- if (Element.IsEnabled)
- {
- var dialog = _lazyDialog.Value;
- dialog.Picker.DateTime = Element.Date;
- dialog.Picker.MaximumDateTime = Element.MaximumDate;
- dialog.Picker.MinimumDateTime = Element.MinimumDate;
- // You need to call Show() after ui thread occupation because of EFL problem.
- // Otherwise, the content of the popup will not receive focus.
- Device.BeginInvokeOnMainThread(() => dialog.Show());
- }
- }
-
- void OnDateTimeChanged(object sender, Native.DateChangedEventArgs dcea)
- {
- Element.Date = dcea.NewDate;
- Control.Text = dcea.NewDate.ToString(Element.Format);
- }
-
- void UpdateDate()
- {
- Control.Text = Element.Date.ToString(Element.Format);
- }
-
- void UpdateTextColor()
- {
- Control.TextColor = Element.TextColor.ToNative();
- }
-
- void UpdateFontSize()
- {
- Control.FontSize = Element.FontSize;
- }
-
- void UpdateFontFamily()
- {
- Control.FontFamily = Element.FontFamily;
- }
-
- void UpdateFontAttributes()
- {
- Control.FontAttributes = Element.FontAttributes;
- }
- }
-}
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using Xamarin.Forms.Platform.Tizen.Native;
-using Xamarin.Forms.Platform.Tizen.Native.Watch;
-using ElmSharp;
-
-namespace Xamarin.Forms.Platform.Tizen
-{
- public class PickerRenderer : ViewRenderer<Picker, EditfieldEntry>
- {
- List _list;
- Dialog _dialog;
- Dictionary<ListItem, int> _itemToItemNumber = new Dictionary<ListItem, int>();
-
- public PickerRenderer()
- {
- RegisterPropertyHandler(Picker.SelectedIndexProperty, UpdateSelectedIndex);
- RegisterPropertyHandler(Picker.TextColorProperty, UpdateTextColor);
- RegisterPropertyHandler(Picker.FontSizeProperty, UpdateFontSize);
- RegisterPropertyHandler(Picker.FontFamilyProperty, UpdateFontFamily);
- RegisterPropertyHandler(Picker.FontAttributesProperty, UpdateFontAttributes);
- RegisterPropertyHandler(Picker.TitleProperty, UpdateTitle);
- RegisterPropertyHandler(Picker.TitleColorProperty, UpdateTitleColor);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- Control.TextBlockFocused -= OnTextBlockFocused;
- if (Device.Idiom == TargetIdiom.TV)
- {
- Control.LayoutFocused -= OnLayoutFocused;
- Control.LayoutUnfocused -= OnLayoutUnfocused;
- }
- CleanView();
- }
- }
- base.Dispose(disposing);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
- {
- if (Control == null)
- {
- var entry = new EditfieldEntry(Forms.NativeParent)
- {
- IsSingleLine = true,
- InputPanelShowByOnDemand = true,
- };
- entry.SetVerticalTextAlignment("elm.text", 0.5);
- entry.HorizontalTextAlignment = Native.TextAlignment.Center;
- entry.TextBlockFocused += OnTextBlockFocused;
-
- if (Device.Idiom == TargetIdiom.TV)
- {
- entry.LayoutFocused += OnLayoutFocused;
- entry.LayoutUnfocused += OnLayoutUnfocused;
- }
-
- SetNativeControl(entry);
- }
- base.OnElementChanged(e);
- }
-
- void UpdateSelectedIndex()
- {
- Control.Text = (Element.SelectedIndex == -1 || Element.Items == null ?
- "" : Element.Items[Element.SelectedIndex]);
- }
-
- void UpdateTextColor()
- {
- Control.TextColor = Element.TextColor.ToNative();
- }
-
- void UpdateFontSize()
- {
- Control.FontSize = Element.FontSize;
- }
-
- void UpdateFontFamily()
- {
- Control.FontFamily = Element.FontFamily;
- }
-
- void UpdateFontAttributes()
- {
- Control.FontAttributes = Element.FontAttributes;
- }
-
- void UpdateTitle()
- {
- Control.Placeholder = Element.Title;
- }
-
- void UpdateTitleColor()
- {
- Control.PlaceholderColor = Element.TitleColor.ToNative();
- }
-
- void OnLayoutFocused(object sender, EventArgs e)
- {
- Control.FontSize = Control.FontSize * 1.5;
- }
-
- void OnLayoutUnfocused(object sender, EventArgs e)
- {
- Control.FontSize = Control.FontSize / 1.5;
- }
-
- void OnTextBlockFocused(object sender, EventArgs e)
- {
- // For EFL Entry, the event will occur even if it is currently disabled.
- // If the problem is resolved, no conditional statement is required.
- if (Element.IsEnabled)
- {
- int i = 0;
- if (Device.Idiom == TargetIdiom.Watch)
- {
- _dialog = new WatchDialog(Forms.NativeParent, false);
- }
- else
- {
- _dialog = new Dialog(Forms.NativeParent);
- }
- _dialog.AlignmentX = -1;
- _dialog.AlignmentY = -1;
- _dialog.Title = Element.Title;
- _dialog.TitleColor = Element.TitleColor.ToNative();
- _dialog.Dismissed += OnDialogDismissed;
- _dialog.BackButtonPressed += (object senders, EventArgs es) =>
- {
- _dialog.Dismiss();
- };
-
- _list = new List(_dialog);
- foreach (var s in Element.Items)
- {
- ListItem item = _list.Append(s);
- _itemToItemNumber[item] = i;
- i++;
- }
- _list.ItemSelected += OnItemSelected;
- _dialog.Content = _list;
-
- // You need to call Show() after ui thread occupation because of EFL problem.
- // Otherwise, the content of the popup will not receive focus.
- Device.BeginInvokeOnMainThread(() =>
- {
- _dialog.Show();
- _list.Show();
- });
- }
- }
-
- void OnItemSelected(object senderObject, EventArgs ev)
- {
- Element.SetValueFromRenderer(Picker.SelectedIndexProperty, _itemToItemNumber[(senderObject as List).SelectedItem]);
- _dialog.Dismiss();
- }
-
- void OnDialogDismissed(object sender, EventArgs e)
- {
- CleanView();
- }
-
- void CleanView()
- {
- if (null != _list)
- {
- _list.Unrealize();
- _itemToItemNumber.Clear();
- _list = null;
- }
- if (null != _dialog)
- {
- _dialog.Unrealize();
- _dialog = null;
- }
- }
- }
-}
+++ /dev/null
-using System;
-using System.Globalization;
-using Xamarin.Forms.Platform.Tizen.Native;
-using WatchDataTimePickerDialog = Xamarin.Forms.Platform.Tizen.Native.Watch.WatchDataTimePickerDialog;
-
-namespace Xamarin.Forms.Platform.Tizen
-{
- public class TimePickerRenderer : ViewRenderer<TimePicker, EditfieldEntry>
- {
- //TODO need to add internationalization support
- const string DialogTitle = "Choose Time";
- static readonly string s_defaultFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;
-
- TimeSpan _time = DateTime.Now.TimeOfDay;
- Lazy<IDateTimeDialog> _lazyDialog;
-
- public TimePickerRenderer()
- {
- RegisterPropertyHandler(TimePicker.FormatProperty, UpdateFormat);
- RegisterPropertyHandler(TimePicker.TimeProperty, UpdateTime);
- RegisterPropertyHandler(TimePicker.TextColorProperty, UpdateTextColor);
- RegisterPropertyHandler(TimePicker.FontAttributesProperty, UpdateFontAttributes);
- RegisterPropertyHandler(TimePicker.FontFamilyProperty, UpdateFontFamily);
- RegisterPropertyHandler(TimePicker.FontSizeProperty, UpdateFontSize);
- }
-
- protected virtual IDateTimeDialog CreateDialog()
- {
- if (Device.Idiom == TargetIdiom.Watch)
- {
- return new WatchDataTimePickerDialog(Forms.NativeParent);
- }
- else
- {
- return new DateTimePickerDialog(Forms.NativeParent);
- }
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs<TimePicker> e)
- {
- if (Control == null)
- {
- var entry = new Native.EditfieldEntry(Forms.NativeParent)
- {
- IsSingleLine = true,
- HorizontalTextAlignment = Native.TextAlignment.Center,
- InputPanelShowByOnDemand = true,
- };
- entry.SetVerticalTextAlignment("elm.text", 0.5);
- entry.TextBlockFocused += OnTextBlockFocused;
- SetNativeControl(entry);
-
- _lazyDialog = new Lazy<IDateTimeDialog>(() => {
- var dialog = CreateDialog();
- dialog.Picker.Mode = DateTimePickerMode.Time;
- dialog.Title = DialogTitle;
- dialog.DateTimeChanged += OnDialogTimeChanged;
- return dialog;
- });
- }
- base.OnElementChanged(e);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- Control.TextBlockFocused -= OnTextBlockFocused;
- }
- if (_lazyDialog.IsValueCreated)
- {
- _lazyDialog.Value.DateTimeChanged -= OnDialogTimeChanged;
- _lazyDialog.Value.Unrealize();
- }
- }
-
- base.Dispose(disposing);
- }
-
- protected override Size MinimumSize()
- {
- return Control.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
- }
-
- void OnTextBlockFocused(object o, EventArgs e)
- {
- // For EFL Entry, the event will occur even if it is currently disabled.
- // If the problem is resolved, no conditional statement is required.
- if (Element.IsEnabled)
- {
- var dialog = _lazyDialog.Value;
- dialog.Picker.Time = Element.Time;
- // You need to call Show() after ui thread occupation because of EFL problem.
- // Otherwise, the content of the popup will not receive focus.
- Device.BeginInvokeOnMainThread(() => dialog.Show());
- }
- }
-
- void OnDialogTimeChanged(object sender, Native.DateChangedEventArgs dcea)
- {
- Element.SetValueFromRenderer(TimePicker.TimeProperty, dcea.NewDate.TimeOfDay);
- UpdateTime();
- }
-
- void UpdateFormat()
- {
- UpdateTimeAndFormat();
- }
-
- void UpdateTextColor()
- {
- Control.TextColor = Element.TextColor.ToNative();
- }
-
- void UpdateTime()
- {
- _time = Element.Time;
- UpdateTimeAndFormat();
- }
-
- void UpdateFontSize()
- {
- Control.FontSize = Element.FontSize;
- }
-
- void UpdateFontFamily()
- {
- Control.FontFamily = Element.FontFamily;
- }
-
- void UpdateFontAttributes()
- {
- Control.FontAttributes = Element.FontAttributes;
- }
-
- void UpdateTimeAndFormat()
- {
- // Xamarin using DateTime formatting (https://developer.xamarin.com/api/property/Xamarin.Forms.TimePicker.Format/)
- Control.Text = new DateTime(_time.Ticks).ToString(Element.Format ?? s_defaultFormat);
- }
- }
-}
Registered.Register(typeof(Button), () => new ButtonRenderer());
Registered.Register(typeof(Image), () => new ImageRenderer());
Registered.Register(typeof(Slider), () => new SliderRenderer());
- Registered.Register(typeof(Picker), () => new PickerRenderer());
Registered.Register(typeof(Frame), () => new FrameRenderer());
Registered.Register(typeof(Stepper), () => new StepperRenderer());
- Registered.Register(typeof(DatePicker), () => new DatePickerRenderer());
- Registered.Register(typeof(TimePicker), () => new TimePickerRenderer());
Registered.Register(typeof(ProgressBar), () => new ProgressBarRenderer());
Registered.Register(typeof(Switch), () => new SwitchRenderer());
Registered.Register(typeof(ListView), () => new ListViewRenderer());
{
}
- internal class _DatePickerRenderer
- {
- }
-
- internal class _TimePickerRenderer
- {
- }
-
- internal class _PickerRenderer
- {
- }
-
internal class _StepperRenderer
{
}