summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangho Hur <kangho.hur@samsung.com>2017-01-12 22:27:35 -0800
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2017-01-12 22:27:35 -0800
commit821a8e4a379b32debc35832a9bc87a5c84bb07cd (patch)
tree4e7e85a322d6fdd1c0d0c7533d0a30675fb11a57
parentde24ff5ad9c5258129b4dc9a82d221132138599e (diff)
parentf7246c3adde376884a36a936439333e47701d686 (diff)
downloadxamarin-forms-821a8e4a379b32debc35832a9bc87a5c84bb07cd.tar.gz
xamarin-forms-821a8e4a379b32debc35832a9bc87a5c84bb07cd.tar.bz2
xamarin-forms-821a8e4a379b32debc35832a9bc87a5c84bb07cd.zip
Merge "Add Switch Style" into tizen
-rw-r--r--Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Switch.cs30
-rw-r--r--Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/SwitchStyle.cs9
-rw-r--r--Xamarin.Forms.Core/Xamarin.Forms.Core.csproj4
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs31
4 files changed, 71 insertions, 3 deletions
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Switch.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Switch.cs
new file mode 100644
index 00000000..cef38f34
--- /dev/null
+++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Switch.cs
@@ -0,0 +1,30 @@
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ using FormsElement = Forms.Switch;
+
+ public static class Switch
+ {
+ public static readonly BindableProperty SwitchStyleProperty = BindableProperty.Create("SwitchStyle", typeof(SwitchStyle), typeof(FormsElement), SwitchStyle.Default);
+
+ public static SwitchStyle GetSwitchStyle(BindableObject element)
+ {
+ return (SwitchStyle)element.GetValue(SwitchStyleProperty);
+ }
+
+ public static void SetSwitchStyle(BindableObject element, SwitchStyle value)
+ {
+ element.SetValue(SwitchStyleProperty, value);
+ }
+
+ public static SwitchStyle GetSwitchStyle(this IPlatformElementConfiguration<Tizen, FormsElement> config)
+ {
+ return GetSwitchStyle(config.Element);
+ }
+
+ public static IPlatformElementConfiguration<Tizen, FormsElement> SetSwitchStyle(this IPlatformElementConfiguration<Tizen, FormsElement> config, SwitchStyle value)
+ {
+ SetSwitchStyle(config.Element, value);
+ return config;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/SwitchStyle.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/SwitchStyle.cs
new file mode 100644
index 00000000..a7980fe2
--- /dev/null
+++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/SwitchStyle.cs
@@ -0,0 +1,9 @@
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ public enum SwitchStyle
+ {
+ Default,
+ CheckBox,
+ Favorite
+ }
+}
diff --git a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
index 26445cae..47f49f79 100644
--- a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
+++ b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
@@ -103,6 +103,8 @@
<Compile Include="PlatformConfiguration\TizenSpecific\ProgressBar.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\Button.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\ButtonStyle.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\Switch.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\SwitchStyle.cs" />
<Compile Include="PlatformConfiguration\WindowsSpecific\MasterDetailPage.cs" />
<Compile Include="PlatformConfiguration\WindowsSpecific\CollapseStyle.cs" />
<Compile Include="Configuration.cs" />
@@ -462,4 +464,4 @@
</PostBuildEvent>
</PropertyGroup>
<ItemGroup />
-</Project>
+</Project> \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
index b3539e6c..c67a69a2 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
@@ -1,5 +1,8 @@
using System;
+using System.ComponentModel;
using ElmSharp;
+using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Switch;
namespace Xamarin.Forms.Platform.Tizen
{
@@ -28,14 +31,22 @@ namespace Xamarin.Forms.Platform.Tizen
if (e.NewElement != null)
{
- Control.Style = "toggle";
-
+ UpdateStyle();
Control.StateChanged += CheckChangedHandler;
}
base.OnElementChanged(e);
}
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == Specific.SwitchStyleProperty.PropertyName)
+ {
+ UpdateStyle();
+ }
+ base.OnElementPropertyChanged(sender, e);
+ }
+
void CheckChangedHandler(object sender, EventArgs e)
{
Element.SetValue(Switch.IsToggledProperty, Control.IsChecked);
@@ -46,5 +57,21 @@ namespace Xamarin.Forms.Platform.Tizen
Control.IsChecked = Element.IsToggled;
}
+ void UpdateStyle()
+ {
+ switch (Specific.GetSwitchStyle(Element))
+ {
+ case SwitchStyle.CheckBox:
+ Control.Style = "default";
+ break;
+ case SwitchStyle.Favorite:
+ Control.Style = "favorite";
+ break;
+ default:
+ Control.Style = "toggle";
+ break;
+ }
+ ((IVisualElementController)Element).NativeSizeChanged();
+ }
}
}