Fixed Label.FormattedText property issue
authorchungryeol lim <cdark.lim@samsung.com>
Mon, 23 Jan 2017 07:06:08 +0000 (16:06 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Fri, 24 Mar 2017 04:19:01 +0000 (13:19 +0900)
- Text color is not set when it is FormattedText
- Task=TCAPI-2205

Change-Id: I16796fa52b73c87da7fcbc5c3517adb3e47c9684
Signed-off-by: chungryeol lim <cdark.lim@samsung.com>
Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs

index d21d3d7..24e93bc 100644 (file)
@@ -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;