From bd2406a4db218f8f407962d5ab067c4a6cf0c497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Escalada=20Beltr=C3=A1n?= Date: Wed, 27 Jun 2018 13:50:24 +0200 Subject: [PATCH] Added TextColor and FontFamily properties to customize badge label --- Example/BadgeViewExample/BadgePage.xaml | 9 +++++- src/BadgeView.Shared/BadgeView.xaml.cs | 40 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Example/BadgeViewExample/BadgePage.xaml b/Example/BadgeViewExample/BadgePage.xaml index 93ea321..6d0a291 100644 --- a/Example/BadgeViewExample/BadgePage.xaml +++ b/Example/BadgeViewExample/BadgePage.xaml @@ -3,7 +3,14 @@ \ No newline at end of file diff --git a/src/BadgeView.Shared/BadgeView.xaml.cs b/src/BadgeView.Shared/BadgeView.xaml.cs index a3115be..a988352 100644 --- a/src/BadgeView.Shared/BadgeView.xaml.cs +++ b/src/BadgeView.Shared/BadgeView.xaml.cs @@ -12,6 +12,18 @@ public partial class BadgeView : Grid view.BadgeLabel.Text = (string)newVal; }); + public static BindableProperty TextColorProperty = BindableProperty.Create("TextColor", typeof(Color), typeof(BadgeView), Color.White, propertyChanged: (bindable, oldVal, newVal) => + { + var view = (BadgeView)bindable; + view.BadgeLabel.TextColor = (Color)newVal; + }); + + public static BindableProperty FontFamilyProperty = BindableProperty.Create("FontFamily", typeof(string), typeof(BadgeView), Label.FontFamilyProperty.DefaultValue, propertyChanged: (bindable, oldVal, newVal) => + { + var view = (BadgeView)bindable; + view.BadgeLabel.FontFamily = (string)newVal; + }); + public static BindableProperty BadgeColorProperty = BindableProperty.Create("BadgeColor", typeof(Color), typeof(BadgeView), Color.Blue, propertyChanged: (bindable, oldVal, newVal) => { var view = (BadgeView)bindable; @@ -29,6 +41,31 @@ public string Text SetValue(TextProperty, value); } } + + public Color TextColor + { + get + { + return (Color)GetValue(TextColorProperty); + } + set + { + SetValue(TextColorProperty, value); + } + } + + public string FontFamily + { + get + { + return (string)GetValue(FontFamilyProperty); + } + set + { + SetValue(FontFamilyProperty, value); + } + } + public Color BadgeColor { get @@ -40,10 +77,13 @@ public Color BadgeColor SetValue(BadgeColorProperty, value); } } + public BadgeView() { InitializeComponent(); BadgeLabel.Text = Text; + BadgeLabel.TextColor = TextColor; + BadgeLabel.FontFamily = FontFamily; BadgeCircle.BackgroundColor = BadgeColor; } }