summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs51
1 files changed, 31 insertions, 20 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs
index 7a9f756d..b0651340 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs
@@ -4,11 +4,8 @@ using ERectangle = ElmSharp.Rectangle;
namespace Xamarin.Forms.Platform.Tizen
{
- public class BoxViewRenderer :
- VisualElementRenderer<BoxView>
+ public class BoxViewRenderer : VisualElementRenderer<BoxView>
{
- static readonly EColor s_defaultColor = EColor.Transparent;
-
ERectangle _control;
public BoxViewRenderer()
@@ -23,10 +20,6 @@ namespace Xamarin.Forms.Platform.Tizen
SetNativeControl(_control);
}
- if (e.OldElement != null)
- {
- }
-
if (e.NewElement != null)
{
UpdateColor();
@@ -35,27 +28,45 @@ namespace Xamarin.Forms.Platform.Tizen
base.OnElementChanged(e);
}
- void UpdateColor()
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
- Color colorToSet = Element.Color;
-
- if (colorToSet == Color.Default)
+ if (e.PropertyName == BoxView.ColorProperty.PropertyName)
{
- colorToSet = Element.BackgroundColor;
+ UpdateColor();
}
+ base.OnElementPropertyChanged(sender, e);
+ }
- _control.Color = (colorToSet == Color.Default) ? s_defaultColor : colorToSet.ToNative();
+ protected override void UpdateBackgroundColor()
+ {
+ UpdateColor();
}
- protected override void OnElementPropertyChanged(object sender,
- PropertyChangedEventArgs e)
+ protected override void UpdateOpacity()
+ {
+ UpdateColor();
+ }
+
+ void UpdateColor()
{
- if (e.PropertyName == BoxView.ColorProperty.PropertyName ||
- e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
+ if (Element.Color.IsDefault)
{
- UpdateColor();
+ if (Element.BackgroundColor.IsDefault)
+ {
+ // Set to default color. (Transparent)
+ _control.Color = EColor.Transparent;
+ }
+ else
+ {
+ // Use BackgroundColor only if color is default and background color is not default.
+ _control.Color = Element.BackgroundColor.MultiplyAlpha(Element.Opacity).ToNative();
+ }
+ }
+ else
+ {
+ // Color has higer priority than BackgroundColor.
+ _control.Color = Element.Color.MultiplyAlpha(Element.Opacity).ToNative();
}
- base.OnElementPropertyChanged(sender, e);
}
}
}