diff options
author | Kangho Hur <kangho.hur@samsung.com> | 2017-01-24 14:09:11 +0900 |
---|---|---|
committer | Kangho Hur <kangho.hur@samsung.com> | 2017-02-03 13:28:06 +0900 |
commit | 7ba95644132d7e5d8311300b8f1ea56e74a1ea69 (patch) | |
tree | 82cbcdfde7106b216c6628b940df795f35e0d536 /Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs | |
parent | 3bd9baf1348c00caab933087554f84fbe9ba3289 (diff) | |
download | xamarin-forms-7ba95644132d7e5d8311300b8f1ea56e74a1ea69.tar.gz xamarin-forms-7ba95644132d7e5d8311300b8f1ea56e74a1ea69.tar.bz2 xamarin-forms-7ba95644132d7e5d8311300b8f1ea56e74a1ea69.zip |
Add FontWeight for Label and Entry
- This change is for the referernce application (Clock) to follow UX guideline. (Internal only).
- We will improve design and implementation of this APIs in the next release, if requred.
Change-Id: Ifac91174a5859adecc9ec6bff1a1d568512ee70b
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs index 9f4157ed..a1c07134 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs @@ -1,4 +1,7 @@ +using Xamarin.Forms.PlatformConfiguration.TizenSpecific; + using EColor = ElmSharp.Color; +using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Label; namespace Xamarin.Forms.Platform.Tizen { @@ -19,6 +22,7 @@ namespace Xamarin.Forms.Platform.Tizen RegisterPropertyHandler(Label.HorizontalTextAlignmentProperty, UpdateTextAlignment); RegisterPropertyHandler(Label.VerticalTextAlignmentProperty, UpdateTextAlignment); RegisterPropertyHandler(Label.FormattedTextProperty, UpdateFormattedText); + RegisterPropertyHandler(Specific.FontWeightProperty, UpdateFontWeight); } protected override void OnElementChanged(ElementChangedEventArgs<Label> e) @@ -117,6 +121,19 @@ namespace Xamarin.Forms.Platform.Tizen Control.LineBreakMode = ConvertToNativeLineBreakMode(Element.LineBreakMode); } + void UpdateFontWeight() + { + var weight = Specific.GetFontWeight(Element); + if (Control.FormattedText != null) + { + foreach (var span in Control.FormattedText.Spans) + { + span.FontWeight = ConvertToNativeFontWeight(weight); + } + } + Control.FontWeight = ConvertToNativeFontWeight(weight); + } + Native.LineBreakMode ConvertToNativeLineBreakMode(LineBreakMode mode) { switch (mode) @@ -136,5 +153,36 @@ namespace Xamarin.Forms.Platform.Tizen return Native.LineBreakMode.WordWrap; } } + + Native.FontWeight ConvertToNativeFontWeight(FontWeight weight) + { + switch (weight) + { + case FontWeight.Bold: + return Native.FontWeight.Bold; + case FontWeight.SemiBold: + return Native.FontWeight.SemiBold; + case FontWeight.UltraBold: + return Native.FontWeight.UltraBold; + case FontWeight.Black: + return Native.FontWeight.Black; + case FontWeight.ExtraBlack: + return Native.FontWeight.ExtraBlack; + case FontWeight.Book: + return Native.FontWeight.Book; + case FontWeight.Light: + return Native.FontWeight.Light; + case FontWeight.Medium: + return Native.FontWeight.Medium; + case FontWeight.Normal: + return Native.FontWeight.Normal; + case FontWeight.Thin: + return Native.FontWeight.Thin; + case FontWeight.UltraLight: + return Native.FontWeight.UltraLight; + default: + return Native.FontWeight.None; + } + } } } |