Fix TextCell text color bug
authorSeungkeun Lee <sngn.lee@samsung.com>
Mon, 19 Dec 2016 00:18:31 +0000 (09:18 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Mon, 24 Apr 2017 04:36:43 +0000 (13:36 +0900)
 - Remove predefined default color in CellRenderers
 - handle Color.Default in Span

Change-Id: I901f93c4b9d929b9d3e646ae29a5a3fb81237152

Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs
Xamarin.Forms.Platform.Tizen/Cells/EntryCellRenderer.cs
Xamarin.Forms.Platform.Tizen/Cells/TextCellRenderer.cs
Xamarin.Forms.Platform.Tizen/Native/Span.cs

index 1cda74c..4701905 100644 (file)
@@ -7,8 +7,6 @@ namespace Xamarin.Forms.Platform.Tizen
        public abstract class CellRenderer : IRegisterable
        {
                const string _heightProperty = "Height";
-               protected static readonly EColor s_defaultTextColor = EColor.Black;
-               protected static readonly EColor s_defaultBackgroundColor = EColor.White;
                readonly Dictionary<Cell, Dictionary<string, EvasObject>> _realizedNativeViews = new Dictionary<Cell, Dictionary<string, EvasObject>>();
 
                protected CellRenderer(string style)
@@ -69,9 +67,9 @@ namespace Xamarin.Forms.Platform.Tizen
                {
                        var nativeSpan = new Native.Span();
                        nativeSpan.Text = span.Text;
-                       nativeSpan.ForegroundColor = span.ForegroundColor.IsDefault ? s_defaultTextColor : span.ForegroundColor.ToNative();
+                       nativeSpan.ForegroundColor = span.ForegroundColor.ToNative();
                        nativeSpan.FontAttributes = span.FontAttributes;
-                       nativeSpan.BackgroundColor = span.BackgroundColor.IsDefault ? s_defaultBackgroundColor : span.BackgroundColor.ToNative();
+                       nativeSpan.BackgroundColor = span.BackgroundColor.ToNative();
                        nativeSpan.FontSize = span.FontSize;
                        nativeSpan.FontFamily = span.FontFamily;
                        return nativeSpan;
@@ -106,7 +104,7 @@ namespace Xamarin.Forms.Platform.Tizen
                string GetText(object data, string part)
                {
                        var span = OnGetText((data as Native.ListView.ItemContext).Cell, part);
-                       return span != null ? ToNative(span).GetDecoratedText() : null;
+                       return span != null ? ToNative(span).GetMarkupText() : null;
                }
 
                EvasObject GetContent(object data, string part)
index c07985f..4c4e7f1 100644 (file)
@@ -8,6 +8,7 @@ namespace Xamarin.Forms.Platform.Tizen
        public class EntryCellRenderer : ViewCellRenderer
        {
                const int _defaultHeight = 120;
+               static readonly EColor s_defaultLabelColor = EColor.Black;
                readonly Dictionary<EvasObject, NativeEntryComponent> _realizedComponent = new Dictionary<EvasObject, NativeEntryComponent>();
 
                public EntryCellRenderer()
@@ -46,9 +47,7 @@ namespace Xamarin.Forms.Platform.Tizen
                                {
                                        IsSingleLine = true,
                                        Text = entryCell.Text,
-                                       TextColor = s_defaultTextColor,
                                        Placeholder = entryCell.Placeholder,
-                                       PlaceholderColor = s_defaultTextColor,
                                        Keyboard = entryCell.Keyboard.ToNative(),
                                        HorizontalTextAlignment = entryCell.HorizontalTextAlignment.ToNative(),
                                };
@@ -151,7 +150,7 @@ namespace Xamarin.Forms.Platform.Tizen
 
                EColor GetLabelColor(EntryCell cell)
                {
-                       return cell.LabelColor.IsDefault ? s_defaultTextColor : cell.LabelColor.ToNative();
+                       return cell.LabelColor.IsDefault ? s_defaultLabelColor : cell.LabelColor.ToNative();
                }
 
                class NativeEntryComponent
index 2bea384..1f9594a 100644 (file)
@@ -34,7 +34,8 @@ namespace Xamarin.Forms.Platform.Tizen
                        return new Span()
                        {
                                Text = cell.Text,
-                               ForegroundColor = cell.TextColor
+                               ForegroundColor = cell.TextColor,
+                               FontSize = -1
                        };
                }
 
@@ -43,7 +44,8 @@ namespace Xamarin.Forms.Platform.Tizen
                        return new Span()
                        {
                                Text = cell.Detail,
-                               ForegroundColor = cell.DetailColor
+                               ForegroundColor = cell.DetailColor,
+                               FontSize = -1
                        };
                }
 
index 6c479e3..7ac4134 100644 (file)
@@ -8,6 +8,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
        /// </summary>
        public class Span
        {
+               static EColor s_defaultLineColor = EColor.Black;
                string _text;
 
                /// <summary>
@@ -111,8 +112,8 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                        FontFamily = "";
                        FontSize = -1;
                        FontAttributes = FontAttributes.None;
-                       ForegroundColor = EColor.White;
-                       BackgroundColor = EColor.Transparent;
+                       ForegroundColor = EColor.Default;
+                       BackgroundColor = EColor.Default;
                        HorizontalTextAlignment = TextAlignment.Auto;
                        VerticalTextAlignment = TextAlignment.Auto;
                        LineBreakMode = LineBreakMode.MixedWrap;
@@ -157,12 +158,15 @@ namespace Xamarin.Forms.Platform.Tizen.Native
 
                StringBuilder PrepareFormattingString(StringBuilder _formattingString)
                {
-                       var foregroundColor = ForegroundColor.ToHex();
-
-                       _formattingString.AppendFormat("color={0} ", foregroundColor);
+                       if (!ForegroundColor.IsDefault)
+                       {
+                               _formattingString.AppendFormat("color={0} ", ForegroundColor.ToHex());
+                       }
 
-                       _formattingString.AppendFormat("backing_color={0} ", BackgroundColor.ToHex());
-                       _formattingString.Append("backing=on ");
+                       if (!BackgroundColor.IsDefault)
+                       {
+                               _formattingString.AppendFormat("backing_color={0} backing=on ", BackgroundColor.ToHex());
+                       }
 
                        if (!string.IsNullOrEmpty(FontFamily))
                        {
@@ -185,12 +189,14 @@ namespace Xamarin.Forms.Platform.Tizen.Native
 
                        if (Underline)
                        {
-                               _formattingString.AppendFormat("underline=on underline_color={0} ", foregroundColor);
+                               _formattingString.AppendFormat("underline=on underline_color={0} ",
+                                       ForegroundColor.IsDefault ? s_defaultLineColor.ToHex() : ForegroundColor.ToHex());
                        }
 
                        if (Strikethrough)
                        {
-                               _formattingString.AppendFormat("strikethrough=on strikethrough_color={0} ", foregroundColor);
+                               _formattingString.AppendFormat("strikethrough=on strikethrough_color={0} ",
+                                       ForegroundColor.IsDefault ? s_defaultLineColor.ToHex() : ForegroundColor.ToHex());
                        }
 
                        switch (HorizontalTextAlignment)