Fix Native.Button default size issue
authordarkleem <cdark.lim@samsung.com>
Fri, 19 May 2017 12:31:53 +0000 (21:31 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Mon, 10 Jul 2017 02:11:26 +0000 (11:11 +0900)
   - DatePicker & TimePicker size issue can be resolved.

Change-Id: I2eb1ad1577be7cbb91c4dc2b8bd21e0dabc72298
Signed-off-by: darkleem <cdark.lim@samsung.com>
Xamarin.Forms.Platform.Tizen/Native/Button.cs

index c663866..a3f36a4 100644 (file)
@@ -1,8 +1,8 @@
-using System;
 using ElmSharp;
+using System;
 using EButton = ElmSharp.Button;
-using ESize = ElmSharp.Size;
 using EColor = ElmSharp.Color;
+using ESize = ElmSharp.Size;
 
 namespace Xamarin.Forms.Platform.Tizen.Native
 {
@@ -18,11 +18,6 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                readonly Span _span = new Span();
 
                /// <summary>
-               /// The internal padding of the button, helps to determine the size.
-               /// </summary>
-               ESize _internalPadding;
-
-               /// <summary>
                /// Optional image, if set will be drawn on the button.
                /// </summary>
                Image _image;
@@ -186,51 +181,14 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                /// </summary>
                public ESize Measure(int availableWidth, int availableHeight)
                {
-                       var size = Geometry;
-
-                       // resize the control using the whole available width
-                       Resize(availableWidth, size.Height);
-
-                       // measure the button's text, use it as a hint for the size
-                       var rawSize = Native.TextHelper.GetRawTextBlockSize(this);
-                       var formattedSize = Native.TextHelper.GetFormattedTextBlockSize(this);
-
-                       // restore the original size
-                       Resize(size.Width, size.Height);
-
-                       var padding = _internalPadding;
-
-                       // TODO : If the efl theme for the circle button is modified, it will be deleted.
-                       if (Style == "circle")
+                       switch (Style)
                        {
-                               var circleTextPadding = (EdjeObject["icon_text_padding"]?.Geometry.Height).GetValueOrDefault(0);
-                               var circleHeight = padding.Height + ((rawSize.Width == 0) ? 0 : circleTextPadding + formattedSize.Height);
-
-                               return new ESize
-                               {
-                                       Width = padding.Width,
-                                       Height = circleHeight
-                               };
-                       }
-
-                       if (rawSize.Width > availableWidth)
-                       {
-                               // if the raw text width is larger than the available width, use
-                               // either formatted size or internal padding, whichever is bigger
-                               return new ESize()
-                               {
-                                       Width = Math.Max(padding.Width, formattedSize.Width),
-                                       Height = Math.Max(padding.Height, Math.Min(formattedSize.Height, Math.Max(rawSize.Height, availableHeight))),
-                               };
-                       }
-                       else
-                       {
-                               // otherwise use the formatted size along with padding
-                               return new ESize()
-                               {
-                                       Width = padding.Width + formattedSize.Width,
-                                       Height = Math.Max(padding.Height, formattedSize.Height),
-                               };
+                               case "bottom":
+                               case "circle":
+                                       return new ESize(MinimumWidth, MinimumHeight);
+                               default:
+                                       var rawSize = TextHelper.GetRawTextBlockSize(this);
+                                       return new ESize(rawSize.Width + MinimumWidth, Math.Max(MinimumHeight, rawSize.Height));
                        }
                }
 
@@ -310,19 +268,10 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                        if (Style != style)
                        {
                                Style = style;
-
-                               //TODO : If the efl theme for the circle button is modified, will use MinimumWidth, MinimumHeight to get the size.
                                if (Style == "circle")
-                               {
-                                       var circleSize = (EdjeObject["bg"]?.Geometry.Width).GetValueOrDefault(0);
-                                       _internalPadding = new ESize(circleSize, circleSize);
                                        _span.HorizontalTextAlignment = TextAlignment.Center;
-                               }
                                else
-                               {
-                                       _internalPadding = new ESize(MinimumWidth, MinimumHeight);
                                        _span.HorizontalTextAlignment = TextAlignment.Auto;
-                               }
                                ApplyTextAndStyle();
                        }
                }