summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen
diff options
context:
space:
mode:
authorKangho Hur <kangho.hur@samsung.com>2017-01-11 22:33:15 -0800
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2017-01-11 22:33:15 -0800
commite0f0633138acb59acf19994c35275f48fa018948 (patch)
treef41c1d923c6be2fe4d21f031b5407a02c2ee4969 /Xamarin.Forms.Platform.Tizen
parent0ce1edda16e280a3d42fc487d33b47aa5919560f (diff)
parentb21711c5ea0d70de3ccc01c1ee0a9d1b6ac2f407 (diff)
downloadxamarin-forms-e0f0633138acb59acf19994c35275f48fa018948.tar.gz
xamarin-forms-e0f0633138acb59acf19994c35275f48fa018948.tar.bz2
xamarin-forms-e0f0633138acb59acf19994c35275f48fa018948.zip
Merge "Add Button Style" into tizen
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen')
-rw-r--r--Xamarin.Forms.Platform.Tizen/Native/Button.cs39
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs34
2 files changed, 72 insertions, 1 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Native/Button.cs b/Xamarin.Forms.Platform.Tizen/Native/Button.cs
index 8f85da63..71ec0c10 100644
--- a/Xamarin.Forms.Platform.Tizen/Native/Button.cs
+++ b/Xamarin.Forms.Platform.Tizen/Native/Button.cs
@@ -20,7 +20,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
/// <summary>
/// The internal padding of the button, helps to determine the size.
/// </summary>
- readonly ESize _internalPadding;
+ ESize _internalPadding;
/// <summary>
/// Optional image, if set will be drawn on the button.
@@ -201,6 +201,18 @@ namespace Xamarin.Forms.Platform.Tizen.Native
var padding = _internalPadding;
+ if (Style == "circle")
+ {
+ 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
@@ -299,5 +311,30 @@ namespace Xamarin.Forms.Platform.Tizen.Native
SetPartContent("icon", _image);
}
}
+
+ public void UpdateStyle(string style)
+ {
+ if (Style != style)
+ {
+ Style = style;
+
+ if (Style == "circle")
+ {
+ var circleSize = (EdjeObject["bg"]?.Geometry.Width).GetValueOrDefault(0);
+ _internalPadding = new ESize(circleSize, circleSize);
+ _span.HorizontalTextAlignment = TextAlignment.Center;
+ }
+ else if (Style == "bottom")
+ {
+ _internalPadding = GetInternalPadding();
+ _span.HorizontalTextAlignment = TextAlignment.Auto;
+ }
+ else
+ {
+ _span.HorizontalTextAlignment = TextAlignment.Auto;
+ }
+ ApplyTextAndStyle();
+ }
+ }
}
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
index a34df549..8af7bb69 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
@@ -1,5 +1,8 @@
using System;
+using System.ComponentModel;
using EColor = ElmSharp.Color;
+using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Button;
namespace Xamarin.Forms.Platform.Tizen
{
@@ -38,12 +41,23 @@ namespace Xamarin.Forms.Platform.Tizen
if (e.NewElement != null)
{
+ UpdateStyle();
Control.Clicked += ButtonClickedHandler;
}
base.OnElementChanged(e);
}
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+
+ if (e.PropertyName == Specific.ButtonStyleProperty.PropertyName)
+ {
+ UpdateStyle();
+ }
+ }
+
protected override Size MinimumSize()
{
return new Size(Control.MinimumWidth, Control.MinimumHeight);
@@ -84,6 +98,26 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
+ void UpdateStyle()
+ {
+ string style;
+ switch (Specific.GetButtonStyle(Element))
+ {
+ case ButtonStyle.Circle:
+ style = "circle";
+ break;
+ case ButtonStyle.Bottom:
+ style = "bottom";
+ break;
+ default:
+ style = "default";
+ break;
+ }
+
+ Control.UpdateStyle(style);
+ ((IVisualElementController)Element).NativeSizeChanged();
+ }
+
void UpdateBorder()
{
/* The simpler way is to create some specialized theme for button in