Tizen Extension for ProgressBar
authorSungHyun Min <shyun.min@samsung.com>
Mon, 12 Dec 2016 03:02:40 +0000 (12:02 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Fri, 24 Mar 2017 04:18:58 +0000 (13:18 +0900)
 - Add Set/GetPendingMode methods
 - Add Set/GetPulsingStatus methods

Change-Id: Id59b4b2a848035e3a6f414572c2e411c0fd98767
Signed-off-by: SungHyun Min <shyun.min@samsung.com>
Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/ProgressBar.cs [new file with mode: 0644]
Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
Xamarin.Forms.Platform.Tizen/Renderers/ProgressBarRenderer.cs

diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/ProgressBar.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/ProgressBar.cs
new file mode 100644 (file)
index 0000000..8267ca0
--- /dev/null
@@ -0,0 +1,65 @@
+
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+       using FormsElement = Forms.ProgressBar;
+
+       public static class ProgressBar
+       {
+               public static readonly BindableProperty ProgressBarPendingModeProperty =
+                       BindableProperty.Create("ProgressBarPendingMode", typeof(bool),
+                       typeof(FormsElement), false);
+
+               public static readonly BindableProperty ProgressBarPulsingStatusProperty =
+                       BindableProperty.Create("ProgressBarPulsingStatus", typeof(bool),
+                       typeof(FormsElement), false);
+
+               public static bool GetPendingMode(BindableObject element)
+               {
+                       return (bool)element.GetValue(ProgressBarPendingModeProperty);
+               }
+
+               public static void SetPendingMode(BindableObject element, bool isPending)
+               {
+                       if (!isPending)
+                       {
+                               SetPulsingStatus(element, false);
+                       }
+                       element.SetValue(ProgressBarPendingModeProperty, isPending);
+               }
+
+               public static bool GetPulsingStatus(BindableObject element)
+               {
+                       return (bool)element.GetValue(ProgressBarPulsingStatusProperty);
+               }
+
+               public static void SetPulsingStatus(BindableObject element, bool isPulsing)
+               {
+                       if (GetPendingMode(element))
+                       {
+                               element.SetValue(ProgressBarPulsingStatusProperty, isPulsing);
+                       }
+               }
+
+               public static bool GetPendingMode(this IPlatformElementConfiguration<Tizen, FormsElement> config)
+               {
+                       return GetPendingMode(config.Element);
+               }
+
+               public static IPlatformElementConfiguration<Tizen, FormsElement> SetPendingMode(this IPlatformElementConfiguration<Tizen, FormsElement> config, bool isPending)
+               {
+                       SetPendingMode(config.Element, isPending);
+                       return config;
+               }
+
+               public static bool GetPulsingStatus(this IPlatformElementConfiguration<Tizen, FormsElement> config)
+               {
+                       return GetPulsingStatus(config.Element);
+               }
+
+               public static IPlatformElementConfiguration<Tizen, FormsElement> SetPulsingStatus(this IPlatformElementConfiguration<Tizen, FormsElement> config, bool isPulsing)
+               {
+                       SetPulsingStatus(config.Element, isPulsing);
+                       return config;
+               }
+       }
+}
index f1b7f6f..b639558 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Compile Include="PlatformConfiguration\iOSSpecific\UIStatusBarAnimation.cs" />
     <Compile Include="PlatformConfiguration\iOSSpecific\UpdateMode.cs" />
     <Compile Include="PlatformConfiguration\iOSSpecific\VisualElement.cs" />
+    <Compile Include="PlatformConfiguration\TizenSpecific\ProgressBar.cs" />
     <Compile Include="PlatformConfiguration\WindowsSpecific\MasterDetailPage.cs" />
     <Compile Include="PlatformConfiguration\WindowsSpecific\CollapseStyle.cs" />
     <Compile Include="Configuration.cs" />
   <ItemGroup>
     <Folder Include="PlatformConfiguration\macOSSpecific\" />
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
index 3aacd3f..6bf86b1 100644 (file)
@@ -1,4 +1,6 @@
 using System.ComponentModel;
+
+using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.ProgressBar;
 using EProgressBar = ElmSharp.ProgressBar;
 
 namespace Xamarin.Forms.Platform.Tizen
@@ -37,9 +39,28 @@ namespace Xamarin.Forms.Platform.Tizen
                        base.OnElementChanged(e);
                }
 
+               protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+               {
+                       base.OnElementPropertyChanged(sender, e);
+                       if (e.PropertyName == ProgressBar.ProgressProperty.PropertyName)
+                       {
+                               UpdateProgress();
+                       }
+                       else if (e.PropertyName == Specific.ProgressBarPendingModeProperty.PropertyName)
+                       {
+                               UpdatePendingMode();
+                       }
+                       else if (e.PropertyName == Specific.ProgressBarPulsingStatusProperty.PropertyName)
+                       {
+                               UpdatePulsingStatus();
+                       }
+               }
+
                void UpdateAll()
                {
                        UpdateProgress();
+                       UpdatePendingMode();
+                       UpdatePulsingStatus();
                }
 
                void UpdateProgress()
@@ -47,12 +68,29 @@ namespace Xamarin.Forms.Platform.Tizen
                        Control.Value = Element.Progress;
                }
 
-               protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+               void UpdatePendingMode()
                {
-                       base.OnElementPropertyChanged(sender, e);
-                       if (e.PropertyName == ProgressBar.ProgressProperty.PropertyName)
+                       bool isPending = Specific.GetPendingMode(Element);
+                       if (isPending)
                        {
-                               UpdateProgress();
+                               Control.Style = "pending";
+                       }
+                       else
+                       {
+                               Control.Style = "default";
+                       }
+               }
+
+               void UpdatePulsingStatus()
+               {
+                       bool isPulsing = Specific.GetPulsingStatus(Element);
+                       if (isPulsing)
+                       {
+                               Control.PlayPulse();
+                       }
+                       else
+                       {
+                               Control.StopPulse();
                        }
                }
        }