From a38b817f6dc78322ad1629321dbef8d23c63cb6e Mon Sep 17 00:00:00 2001 From: chungryeol lim Date: Mon, 23 Jan 2017 16:06:08 +0900 Subject: Fixed Label.FormattedText property issue - Text color is not set when it is FormattedText - Task=TCAPI-2205 Change-Id: I16796fa52b73c87da7fcbc5c3517adb3e47c9684 Signed-off-by: chungryeol lim --- .../Renderers/LabelRenderer.cs | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs index d21d3d76..24e93bca 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs @@ -54,17 +54,25 @@ namespace Xamarin.Forms.Platform.Tizen Native.FormattedString nativeString = new Native.FormattedString(); - foreach (var element in formattedString.Spans) + foreach (var span in formattedString.Spans) { - Native.Span span = new Native.Span(); - span.FormattedText = element.Text; - span.FontAttributes = element.FontAttributes; - span.FontFamily = element.FontFamily; - span.FontSize = element.FontSize; - span.ForegroundColor = element.ForegroundColor.IsDefault ? s_defaultForegroundColor : element.ForegroundColor.ToNative(); - span.BackgroundColor = element.BackgroundColor.IsDefault ? s_defaultBackgroundColor : element.BackgroundColor.ToNative(); - - nativeString.Spans.Add(span); + Native.Span nativeSpan = new Native.Span(); + nativeSpan.FormattedText = span.Text; + nativeSpan.FontAttributes = span.FontAttributes == FontAttributes.None ? Element.FontAttributes : span.FontAttributes; + nativeSpan.FontFamily = span.FontFamily == null ? Element.FontFamily : span.FontFamily; + nativeSpan.FontSize = span.FontSize == Device.GetNamedSize(NamedSize.Default, typeof(Label), true) ? Element.FontSize : span.FontSize; + + if (span.ForegroundColor.IsDefault) + nativeSpan.ForegroundColor = Element.TextColor.IsDefault ? s_defaultForegroundColor : Element.TextColor.ToNative(); + else + nativeSpan.ForegroundColor = span.ForegroundColor.ToNative(); + + if (span.BackgroundColor.IsDefault) + nativeSpan.BackgroundColor = Element.BackgroundColor.IsDefault ? s_defaultBackgroundColor : Element.BackgroundColor.ToNative(); + else + nativeSpan.BackgroundColor = span.BackgroundColor.ToNative(); + + nativeString.Spans.Add(nativeSpan); } return nativeString; -- cgit v1.2.3