diff options
author | darkleem <cdark.lim@samsung.com> | 2017-05-26 09:30:32 +0900 |
---|---|---|
committer | Kangho Hur <kangho.hur@samsung.com> | 2017-07-10 11:11:26 +0900 |
commit | 8d3e646ab6dcb8ce13058cd182cd61540573e30b (patch) | |
tree | 32a7627307e677b0dcb43f98ebcbdeb66fb917bc | |
parent | 6ab530cd1629ad44c9cc9b88c7c282329281d4b4 (diff) | |
download | xamarin-forms-8d3e646ab6dcb8ce13058cd182cd61540573e30b.tar.gz xamarin-forms-8d3e646ab6dcb8ce13058cd182cd61540573e30b.tar.bz2 xamarin-forms-8d3e646ab6dcb8ce13058cd182cd61540573e30b.zip |
Fix a object that trigger a view in DatePicker/TimePicker
- TCAPI-2421
Change-Id: Ieffe8c1dc970dc70a519aa17e6494e32dc58c44d
Signed-off-by: darkleem <cdark.lim@samsung.com>
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs | 30 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs | 27 |
2 files changed, 37 insertions, 20 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs index f7aef30f..fefadcc7 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs @@ -1,12 +1,13 @@ using System; -using EColor = ElmSharp.Color; +using ELayout = ElmSharp.Layout; namespace Xamarin.Forms.Platform.Tizen { - public class DatePickerRenderer : ViewRenderer<DatePicker, Native.Button> + public class DatePickerRenderer : ViewRenderer<DatePicker, ELayout> { //TODO need to add internationalization support const string DialogTitle = "Choose Date"; + Native.Entry _realControl = null; public DatePickerRenderer() { @@ -19,24 +20,32 @@ namespace Xamarin.Forms.Platform.Tizen { if (Control == null) { - var button = new Native.Button(Forms.Context.MainWindow); - SetNativeControl(button); + var layout = new ELayout(Forms.Context.MainWindow); + layout.SetTheme("layout", "editfield", "singleline"); + _realControl = new Native.Entry(layout) + { + IsSingleLine = true, + HorizontalTextAlignment = Native.TextAlignment.Center, + }; + _realControl.AllowFocus(false); + layout.SetPartContent("elm.swallow.content", _realControl); + SetNativeControl(layout); } if (e.OldElement != null) { - Control.Clicked -= ButtonClickedHandler; + _realControl.Clicked -= ClickedHandler; } if (e.NewElement != null) { - Control.Clicked += ButtonClickedHandler; + _realControl.Clicked += ClickedHandler; } base.OnElementChanged(e); } - void ButtonClickedHandler(object sender, EventArgs e) + void ClickedHandler(object sender, EventArgs e) { Native.DateTimePickerDialog dialog = new Native.DateTimePickerDialog(Forms.Context.MainWindow) { @@ -52,7 +61,7 @@ namespace Xamarin.Forms.Platform.Tizen void DialogDateTimeChangedHandler(object sender, Native.DateChangedEventArgs dcea) { Element.Date = dcea.NewDate; - Control.Text = dcea.NewDate.ToString(Element.Format); + _realControl.Text = dcea.NewDate.ToString(Element.Format); } void DialogDismissedHandler(object sender, EventArgs e) @@ -64,13 +73,12 @@ namespace Xamarin.Forms.Platform.Tizen void UpdateDate() { - Control.Text = Element.Date.ToString(Element.Format); + _realControl.Text = Element.Date.ToString(Element.Format); } void UpdateTextColor() { - Control.TextColor = Element.TextColor.ToNative(); + _realControl.TextColor = Element.TextColor.ToNative(); } - } } diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs index 68e697ed..547f9312 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs @@ -1,10 +1,10 @@ using System; using System.Globalization; -using EColor = ElmSharp.Color; +using ELayout = ElmSharp.Layout; namespace Xamarin.Forms.Platform.Tizen { - public class TimePickerRenderer : ViewRenderer<TimePicker, Native.Button> + public class TimePickerRenderer : ViewRenderer<TimePicker, ELayout> { //TODO need to add internationalization support const string DialogTitle = "Choose Time"; @@ -14,6 +14,7 @@ namespace Xamarin.Forms.Platform.Tizen string _format; TimeSpan _time; + Native.Entry _realControl; public TimePickerRenderer() { @@ -26,13 +27,21 @@ namespace Xamarin.Forms.Platform.Tizen { if (Control == null) { - var button = new Native.Button(Forms.Context.MainWindow); - SetNativeControl(button); + var layout = new ELayout(Forms.Context.MainWindow); + layout.SetTheme("layout", "editfield", "singleline"); + _realControl = new Native.Entry(layout) + { + IsSingleLine = true, + HorizontalTextAlignment = Native.TextAlignment.Center, + }; + _realControl.AllowFocus(false); + layout.SetPartContent("elm.swallow.content", _realControl); + SetNativeControl(layout); } if (e.OldElement != null) { - Control.Clicked -= ButtonClickedHandler; + _realControl.Clicked -= ClickedHandler; } if (e.NewElement != null) @@ -41,13 +50,13 @@ namespace Xamarin.Forms.Platform.Tizen _format = s_defaultFormat; UpdateTimeAndFormat(); - Control.Clicked += ButtonClickedHandler; + _realControl.Clicked += ClickedHandler; } base.OnElementChanged(e); } - void ButtonClickedHandler(object o, EventArgs e) + void ClickedHandler(object o, EventArgs e) { Native.DateTimePickerDialog dialog = new Native.DateTimePickerDialog(Forms.Context.MainWindow) { @@ -81,7 +90,7 @@ namespace Xamarin.Forms.Platform.Tizen void UpdateTextColor() { - Control.TextColor = Element.TextColor.ToNative(); + _realControl.TextColor = Element.TextColor.ToNative(); } void UpdateTime() @@ -93,7 +102,7 @@ namespace Xamarin.Forms.Platform.Tizen void UpdateTimeAndFormat() { // Xamarin using DateTime formatting (https://developer.xamarin.com/api/property/Xamarin.Forms.TimePicker.Format/) - Control.Text = new DateTime(_time.Ticks).ToString(_format); + _realControl.Text = new DateTime(_time.Ticks).ToString(_format); } } } |