summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordarkleem <cdark.lim@samsung.com>2017-06-21 06:43:46 (GMT)
committerKangho Hur <kangho.hur@samsung.com>2017-07-10 02:11:27 (GMT)
commit217712866c28213ec574662eef9a65764577f15f (patch)
tree80d0e5afa360aaba833664c50c53663de76ea14f
parent535265c5ad415d89ea596385ac4d75436f957a3a (diff)
downloadxamarin-forms-217712866c28213ec574662eef9a65764577f15f.zip
xamarin-forms-217712866c28213ec574662eef9a65764577f15f.tar.gz
xamarin-forms-217712866c28213ec574662eef9a65764577f15f.tar.bz2
fix Date/TimePicker crash and handle issue
- TASK=TCAP-2529 - editfield style handle issue(opacity, enabled..) Change-Id: Ie07113aa5d1f625a6dcc69492d38c5ca1d98aad1 Signed-off-by: darkleem <cdark.lim@samsung.com>
-rw-r--r--Xamarin.Forms.Platform.Tizen/Native/EditfieldEntry.cs49
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs31
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs35
3 files changed, 81 insertions, 34 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Native/EditfieldEntry.cs b/Xamarin.Forms.Platform.Tizen/Native/EditfieldEntry.cs
new file mode 100644
index 0000000..0091d25
--- /dev/null
+++ b/Xamarin.Forms.Platform.Tizen/Native/EditfieldEntry.cs
@@ -0,0 +1,49 @@
+´╗┐using ElmSharp;
+using System;
+using ELayout = ElmSharp.Layout;
+
+namespace Xamarin.Forms.Platform.Tizen.Native
+{
+ public class EditfieldEntry : Native.Entry, IMeasurable
+ {
+ ELayout _editfieldLayout;
+ int _heightPadding = 0;
+
+ public EditfieldEntry(EvasObject parent) : base(parent)
+ {
+ }
+
+ protected override IntPtr CreateHandle(EvasObject parent)
+ {
+ var bg = new ELayout(parent);
+ bg.SetTheme("layout", "background", "default");
+ _editfieldLayout = new ELayout(parent);
+ _editfieldLayout.SetTheme("layout", "editfield", "singleline");
+
+ Handle = base.CreateHandle(parent);
+ _editfieldLayout.SetPartContent("elm.swallow.content", this);
+ bg.SetPartContent("elm.swallow.content", _editfieldLayout);
+
+ // The minimun size for the Content area of an Editfield. This is used to calculate the size when layouting.
+ _heightPadding = _editfieldLayout.EdjeObject["elm.swallow.content"].Geometry.Height;
+ return bg;
+ }
+
+ public new ElmSharp.Size Measure(int availableWidth, int availableHeight)
+ {
+ var textBlockSize = base.Measure(availableWidth, availableHeight);
+
+ // Calculate the minimum size by adding the width of a TextBlock and an Editfield.
+ textBlockSize.Width += _editfieldLayout.MinimumWidth;
+
+ // If the height of a TextBlock is shorter than Editfield, use the minimun height of the Editfield.
+ // Or add the height of the EditField to the TextBlock
+ if (textBlockSize.Height < _editfieldLayout.MinimumHeight)
+ textBlockSize.Height = _editfieldLayout.MinimumHeight;
+ else
+ textBlockSize.Height += _heightPadding;
+
+ return textBlockSize;
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs
index fefadcc..2fa86a5 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs
@@ -1,13 +1,11 @@
using System;
-using ELayout = ElmSharp.Layout;
namespace Xamarin.Forms.Platform.Tizen
{
- public class DatePickerRenderer : ViewRenderer<DatePicker, ELayout>
+ public class DatePickerRenderer : ViewRenderer<DatePicker, Native.EditfieldEntry>
{
//TODO need to add internationalization support
const string DialogTitle = "Choose Date";
- Native.Entry _realControl = null;
public DatePickerRenderer()
{
@@ -20,31 +18,34 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var layout = new ELayout(Forms.Context.MainWindow);
- layout.SetTheme("layout", "editfield", "singleline");
- _realControl = new Native.Entry(layout)
+ var entry = new Native.EditfieldEntry(Forms.Context.MainWindow)
{
IsSingleLine = true,
HorizontalTextAlignment = Native.TextAlignment.Center,
};
- _realControl.AllowFocus(false);
- layout.SetPartContent("elm.swallow.content", _realControl);
- SetNativeControl(layout);
+ entry.SetVerticalTextAlignment("elm.text", 0.5);
+ entry.AllowFocus(false);
+ SetNativeControl(entry);
}
if (e.OldElement != null)
{
- _realControl.Clicked -= ClickedHandler;
+ Control.Clicked -= ClickedHandler;
}
if (e.NewElement != null)
{
- _realControl.Clicked += ClickedHandler;
+ Control.Clicked += ClickedHandler;
}
base.OnElementChanged(e);
}
+ protected override Size MinimumSize()
+ {
+ return Control.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
+ }
+
void ClickedHandler(object sender, EventArgs e)
{
Native.DateTimePickerDialog dialog = new Native.DateTimePickerDialog(Forms.Context.MainWindow)
@@ -61,7 +62,7 @@ namespace Xamarin.Forms.Platform.Tizen
void DialogDateTimeChangedHandler(object sender, Native.DateChangedEventArgs dcea)
{
Element.Date = dcea.NewDate;
- _realControl.Text = dcea.NewDate.ToString(Element.Format);
+ Control.Text = dcea.NewDate.ToString(Element.Format);
}
void DialogDismissedHandler(object sender, EventArgs e)
@@ -73,12 +74,12 @@ namespace Xamarin.Forms.Platform.Tizen
void UpdateDate()
{
- _realControl.Text = Element.Date.ToString(Element.Format);
+ Control.Text = Element.Date.ToString(Element.Format);
}
void UpdateTextColor()
{
- _realControl.TextColor = Element.TextColor.ToNative();
+ Control.TextColor = Element.TextColor.ToNative();
}
}
-}
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs
index 547f931..6c517c9 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs
@@ -1,20 +1,16 @@
using System;
using System.Globalization;
-using ELayout = ElmSharp.Layout;
namespace Xamarin.Forms.Platform.Tizen
{
- public class TimePickerRenderer : ViewRenderer<TimePicker, ELayout>
+ public class TimePickerRenderer : ViewRenderer<TimePicker, Native.EditfieldEntry>
{
//TODO need to add internationalization support
const string DialogTitle = "Choose Time";
static readonly string s_defaultFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;
- string _format;
-
TimeSpan _time;
- Native.Entry _realControl;
public TimePickerRenderer()
{
@@ -27,35 +23,37 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var layout = new ELayout(Forms.Context.MainWindow);
- layout.SetTheme("layout", "editfield", "singleline");
- _realControl = new Native.Entry(layout)
+ var entry = new Native.EditfieldEntry(Forms.Context.MainWindow)
{
IsSingleLine = true,
HorizontalTextAlignment = Native.TextAlignment.Center,
};
- _realControl.AllowFocus(false);
- layout.SetPartContent("elm.swallow.content", _realControl);
- SetNativeControl(layout);
+ entry.SetVerticalTextAlignment("elm.text", 0.5);
+ entry.AllowFocus(false);
+ SetNativeControl(entry);
}
if (e.OldElement != null)
{
- _realControl.Clicked -= ClickedHandler;
+ Control.Clicked -= ClickedHandler;
}
if (e.NewElement != null)
{
_time = DateTime.Now.TimeOfDay;
- _format = s_defaultFormat;
UpdateTimeAndFormat();
- _realControl.Clicked += ClickedHandler;
+ Control.Clicked += ClickedHandler;
}
base.OnElementChanged(e);
}
+ protected override Size MinimumSize()
+ {
+ return Control.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
+ }
+
void ClickedHandler(object o, EventArgs e)
{
Native.DateTimePickerDialog dialog = new Native.DateTimePickerDialog(Forms.Context.MainWindow)
@@ -63,7 +61,7 @@ namespace Xamarin.Forms.Platform.Tizen
Title = DialogTitle
};
- dialog.InitializeTimePicker(_time, _format);
+ dialog.InitializeTimePicker(_time, null);
dialog.DateTimeChanged += DialogDateTimeChangedHandler;
dialog.Dismissed += DialogDismissedHandler;
dialog.Show();
@@ -84,13 +82,12 @@ namespace Xamarin.Forms.Platform.Tizen
void UpdateFormat()
{
- _format = Element.Format ?? s_defaultFormat;
UpdateTimeAndFormat();
}
void UpdateTextColor()
{
- _realControl.TextColor = Element.TextColor.ToNative();
+ Control.TextColor = Element.TextColor.ToNative();
}
void UpdateTime()
@@ -102,7 +99,7 @@ namespace Xamarin.Forms.Platform.Tizen
void UpdateTimeAndFormat()
{
// Xamarin using DateTime formatting (https://developer.xamarin.com/api/property/Xamarin.Forms.TimePicker.Format/)
- _realControl.Text = new DateTime(_time.Ticks).ToString(_format);
+ Control.Text = new DateTime(_time.Ticks).ToString(Element.Format ?? s_defaultFormat);
}
}
-}
+} \ No newline at end of file