diff options
author | Kangho Hur <kangho.hur@samsung.com> | 2017-02-08 14:54:28 +0900 |
---|---|---|
committer | Kangho Hur <kangho.hur@samsung.com> | 2017-03-24 13:19:02 +0900 |
commit | c7664b9f16fbe17eca43fe7e09a24d90d50776d1 (patch) | |
tree | 63ddd7e6c0d3eb461187df2af8d4aed0dd3ec9d5 /Xamarin.Forms.Platform.Tizen | |
parent | 2789a69ae607387369dec96835e4f12993ef9243 (diff) | |
download | xamarin-forms-c7664b9f16fbe17eca43fe7e09a24d90d50776d1.tar.gz xamarin-forms-c7664b9f16fbe17eca43fe7e09a24d90d50776d1.tar.bz2 xamarin-forms-c7664b9f16fbe17eca43fe7e09a24d90d50776d1.zip |
Add Style to VisualElement as TizenSpecific
- Implement the change proposed in RFC-17
Change-Id: I96431b3a32358be6f32e7acdeb0cbc6a27a98ec4
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen')
4 files changed, 27 insertions, 72 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs index def27a99..eea46e80 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs @@ -2,7 +2,7 @@ using System; using System.ComponentModel; using EColor = ElmSharp.Color; using Xamarin.Forms.PlatformConfiguration.TizenSpecific; -using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Button; +using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement; namespace Xamarin.Forms.Platform.Tizen { @@ -41,23 +41,11 @@ 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); @@ -98,23 +86,9 @@ namespace Xamarin.Forms.Platform.Tizen } } - void UpdateStyle() + protected override void UpdateThemeStyle() { - 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); + Control.UpdateStyle(Specific.GetStyle(Element)); ((IVisualElementController)Element).NativeSizeChanged(); } diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ProgressBarRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ProgressBarRenderer.cs index 6bf86b16..444bc852 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/ProgressBarRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/ProgressBarRenderer.cs @@ -1,5 +1,6 @@ using System.ComponentModel; +using SpecificVE = Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement; using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.ProgressBar; using EProgressBar = ElmSharp.ProgressBar; @@ -46,20 +47,20 @@ namespace Xamarin.Forms.Platform.Tizen { UpdateProgress(); } - else if (e.PropertyName == Specific.ProgressBarPendingModeProperty.PropertyName) - { - UpdatePendingMode(); - } else if (e.PropertyName == Specific.ProgressBarPulsingStatusProperty.PropertyName) { UpdatePulsingStatus(); } } + protected override void UpdateThemeStyle() + { + Control.Style = SpecificVE.GetStyle(Element); + } + void UpdateAll() { UpdateProgress(); - UpdatePendingMode(); UpdatePulsingStatus(); } @@ -68,19 +69,6 @@ namespace Xamarin.Forms.Platform.Tizen Control.Value = Element.Progress; } - void UpdatePendingMode() - { - bool isPending = Specific.GetPendingMode(Element); - if (isPending) - { - Control.Style = "pending"; - } - else - { - Control.Style = "default"; - } - } - void UpdatePulsingStatus() { bool isPulsing = Specific.GetPulsingStatus(Element); diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs index c67a69a2..da00ef9f 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs @@ -2,7 +2,7 @@ using System; using System.ComponentModel; using ElmSharp; using Xamarin.Forms.PlatformConfiguration.TizenSpecific; -using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Switch; +using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement; namespace Xamarin.Forms.Platform.Tizen { @@ -31,20 +31,27 @@ namespace Xamarin.Forms.Platform.Tizen if (e.NewElement != null) { - UpdateStyle(); Control.StateChanged += CheckChangedHandler; } base.OnElementChanged(e); } - protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) + protected override void UpdateThemeStyle() { - if (e.PropertyName == Specific.SwitchStyleProperty.PropertyName) + var style = Specific.GetStyle(Element); + switch (style) { - UpdateStyle(); + case SwitchStyle.Toggle: + case SwitchStyle.Favorite: + case SwitchStyle.CheckBox: + Control.Style = style; + break; + default: + Control.Style = SwitchStyle.Toggle; + break; } - base.OnElementPropertyChanged(sender, e); + ((IVisualElementController)Element).NativeSizeChanged(); } void CheckChangedHandler(object sender, EventArgs e) @@ -56,22 +63,5 @@ 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(); - } } } diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs index 8c5c0be0..4bde705c 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using System.Diagnostics; using System.ComponentModel; using ElmSharp; -using ELayout = ElmSharp.Layout; using EColor = ElmSharp.Color; using ESize = ElmSharp.Size; using ERect = ElmSharp.Rect; using ERectangle = ElmSharp.Rectangle; -using EBox = ElmSharp.Box; +using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement; + namespace Xamarin.Forms.Platform.Tizen { @@ -59,6 +59,7 @@ namespace Xamarin.Forms.Platform.Tizen RegisterPropertyHandler(VisualElement.IsEnabledProperty, UpdateIsEnabled); RegisterPropertyHandler(VisualElement.InputTransparentProperty, UpdateInputTransparent); RegisterPropertyHandler(VisualElement.BackgroundColorProperty, UpdateBackgroundColor); + RegisterPropertyHandler(Specific.StyleProperty, UpdateThemeStyle); RegisterPropertyHandler(VisualElement.AnchorXProperty, ApplyTransformation); RegisterPropertyHandler(VisualElement.AnchorYProperty, ApplyTransformation); @@ -794,6 +795,8 @@ namespace Xamarin.Forms.Platform.Tizen NativeView.PassEvents = Element.InputTransparent; } + protected virtual void UpdateThemeStyle() {} + void ApplyRotation(EvasMap map, ERect geometry, ref bool changed) { var rotationX = Element.RotationX; |