diff --git a/Ooui.Forms/Exports.cs b/Ooui.Forms/Exports.cs
index c823d1b..5388bab 100644
--- a/Ooui.Forms/Exports.cs
+++ b/Ooui.Forms/Exports.cs
@@ -11,6 +11,7 @@ using Xamarin.Forms.Internals;
[assembly: ExportRenderer (typeof (DatePicker), typeof (DatePickerRenderer))]
[assembly: ExportRenderer (typeof (Editor), typeof (EditorRenderer))]
[assembly: ExportRenderer (typeof (Entry), typeof (EntryRenderer))]
+[assembly: ExportRenderer (typeof (Frame), typeof (FrameRenderer))]
[assembly: ExportRenderer (typeof (Label), typeof (LabelRenderer))]
[assembly: ExportRenderer (typeof (ProgressBar), typeof (ProgressBarRenderer))]
diff --git a/Ooui.Forms/Renderers/FrameRenderer.cs b/Ooui.Forms/Renderers/FrameRenderer.cs
new file mode 100644
index 0000000..752f534
--- /dev/null
+++ b/Ooui.Forms/Renderers/FrameRenderer.cs
@@ -0,0 +1,64 @@
+using System;
+using System.ComponentModel;
+using Xamarin.Forms;
+using Ooui.Forms.Extensions;
+
+namespace Ooui.Forms.Renderers
+{
+ public class FrameRenderer : VisualElementRenderer
+ {
+ protected override void OnElementChanged (ElementChangedEventArgs e)
+ {
+ base.OnElementChanged (e);
+
+ if (e.NewElement != null)
+ SetupLayer ();
+ }
+
+ protected override void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged (sender, e);
+
+ if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName ||
+ e.PropertyName == Xamarin.Forms.Frame.OutlineColorProperty.PropertyName ||
+ e.PropertyName == Xamarin.Forms.Frame.HasShadowProperty.PropertyName ||
+ e.PropertyName == Xamarin.Forms.Frame.CornerRadiusProperty.PropertyName)
+ SetupLayer ();
+ }
+
+ void SetupLayer ()
+ {
+ float cornerRadius = Element.CornerRadius;
+
+ if (cornerRadius == -1f)
+ cornerRadius = 5f; // default corner radius
+
+ var Layer = this.Style;
+
+ Layer.BorderRadius = cornerRadius;
+
+ if (Element.BackgroundColor == Xamarin.Forms.Color.Default)
+ Layer.BackgroundColor = "white";
+ else
+ Layer.BackgroundColor = Element.BackgroundColor.ToOouiColor ();
+
+ if (Element.HasShadow) {
+ //Layer.ShadowRadius = 5;
+ //Layer.ShadowColor = "black";
+ //Layer.ShadowOpacity = 0.8f;
+ //Layer.ShadowOffset = new SizeF ();
+ }
+ else {
+ //Layer.ShadowOpacity = 0;
+ }
+
+ if (Element.OutlineColor == Xamarin.Forms.Color.Default)
+ Layer.BorderColor = Colors.Clear;
+ else {
+ Layer.BorderColor = Element.OutlineColor.ToOouiColor ();
+ Layer.BorderWidth = 1;
+ Layer.BorderStyle = "solid";
+ }
+ }
+ }
+}
diff --git a/Ooui/Style.cs b/Ooui/Style.cs
index 06b6149..4163f75 100644
--- a/Ooui/Style.cs
+++ b/Ooui/Style.cs
@@ -93,38 +93,38 @@ namespace Ooui
public Value BorderTopWidth {
get => this["border-top-width"];
- set => this["border-top-width"] = value;
+ set => this["border-top-width"] = AddNumberUnits (value, "px");
}
public Value BorderRightWidth {
get => this["border-right-width"];
- set => this["border-right-width"] = value;
+ set => this["border-right-width"] = AddNumberUnits (value, "px");
}
public Value BorderBottomWidth {
get => this["border-bottom-width"];
- set => this["border-bottom-width"] = value;
+ set => this["border-bottom-width"] = AddNumberUnits (value, "px");
}
public Value BorderLeftWidth {
get => this["border-left-width"];
- set => this["border-left-width"] = value;
+ set => this["border-left-width"] = AddNumberUnits (value, "px");
}
public Value BorderRadius {
get => this["border-radius"];
set {
- this["border-radius"] = value;
+ this["border-radius"] = AddNumberUnits (value, "px");
}
}
public Value BorderWidth {
get => this["border-top-width"];
set {
- this["border-top-width"] = value;
- this["border-right-width"] = value;
- this["border-bottom-width"] = value;
- this["border-left-width"] = value;
+ this["border-top-width"] = AddNumberUnits (value, "px");
+ this["border-right-width"] = AddNumberUnits (value, "px");
+ this["border-bottom-width"] = AddNumberUnits (value, "px");
+ this["border-left-width"] = AddNumberUnits (value, "px");
}
}
@@ -403,6 +403,8 @@ namespace Ooui
static string AddNumberUnits (object val, string units)
{
+ if (val == null)
+ return null;
if (val is string s)
return s;
if (val is IConvertible c)