summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/Span.cs
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-03-03 09:16:04 +0100
committerGitHub <noreply@github.com>2017-03-03 09:16:04 +0100
commitd9ef5525b441375b8d127b6b006b97615b37dcdf (patch)
tree00ef649aefc5b68feeadef77e94d34a66a5ee33a /Xamarin.Forms.Core/Span.cs
parent62cdb35a0bcdd76414ec01501de0ed3f7227acab (diff)
downloadxamarin-forms-d9ef5525b441375b8d127b6b006b97615b37dcdf.tar.gz
xamarin-forms-d9ef5525b441375b8d127b6b006b97615b37dcdf.tar.bz2
xamarin-forms-d9ef5525b441375b8d127b6b006b97615b37dcdf.zip
[Core] Share BP across IFontElement implementors (#783)
* [Core] Share BP accross IFontElement implementors * make sure the converter is used
Diffstat (limited to 'Xamarin.Forms.Core/Span.cs')
-rw-r--r--Xamarin.Forms.Core/Span.cs49
1 files changed, 32 insertions, 17 deletions
diff --git a/Xamarin.Forms.Core/Span.cs b/Xamarin.Forms.Core/Span.cs
index 6ffc3f17..a410c100 100644
--- a/Xamarin.Forms.Core/Span.cs
+++ b/Xamarin.Forms.Core/Span.cs
@@ -84,9 +84,11 @@ namespace Xamarin.Forms
{
if (_fontAttributes == value)
return;
+ var oldValue = _fontAttributes;
_fontAttributes = value;
OnPropertyChanged();
- UpdateStructFromFontProperties();
+
+ ((IFontElement)this).OnFontAttributesChanged(oldValue, value);
}
}
@@ -97,9 +99,10 @@ namespace Xamarin.Forms
{
if (_fontFamily == value)
return;
+ var oldValue = _fontFamily;
_fontFamily = value;
OnPropertyChanged();
- UpdateStructFromFontProperties();
+ ((IFontElement)this).OnFontFamilyChanged(oldValue, value);
}
}
@@ -111,9 +114,10 @@ namespace Xamarin.Forms
{
if (_fontSize == value)
return;
+ var oldValue = _fontSize;
_fontSize = value;
OnPropertyChanged();
- UpdateStructFromFontProperties();
+ ((IFontElement)this).OnFontSizeChanged(oldValue, value);
}
}
@@ -149,23 +153,34 @@ namespace Xamarin.Forms
_inUpdate = false;
}
- void UpdateStructFromFontProperties()
+ void OnSomeFontPropertyChanged()
{
- if (_inUpdate)
- return;
- _inUpdate = true;
-
- if (FontFamily != null)
{
- Font = Font.OfSize(FontFamily, FontSize).WithAttributes(FontAttributes);
- }
- else
- {
- Font = Font.SystemFontOfSize(FontSize).WithAttributes(FontAttributes);
- }
+ if (_inUpdate)
+ return;
+ _inUpdate = true;
- _inUpdate = false;
+ if (FontFamily != null)
+ Font = Font.OfSize(FontFamily, FontSize).WithAttributes(FontAttributes);
+ else
+ Font = Font.SystemFontOfSize(FontSize).WithAttributes(FontAttributes);
+
+ _inUpdate = false;
+ }
}
- }
+
#pragma warning restore
+
+ void IFontElement.OnFontFamilyChanged(string oldValue, string newValue) =>
+ OnSomeFontPropertyChanged();
+
+ void IFontElement.OnFontSizeChanged(double oldValue, double newValue) =>
+ OnSomeFontPropertyChanged();
+
+ double IFontElement.FontSizeDefaultValueCreator() =>
+ Device.GetNamedSize(NamedSize.Default, typeof(Label));
+
+ void IFontElement.OnFontAttributesChanged(FontAttributes oldValue, FontAttributes newValue) =>
+ OnSomeFontPropertyChanged();
+ }
} \ No newline at end of file