From 359b198657c7cb4aabf0573e0cfceed5674a24e7 Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Mon, 6 Feb 2017 13:41:42 +0900 Subject: Refactoring Label Renderer - Optimize FormattedText handling - Define a new Value of TextAlignment, LineBreakMode for default value - Old-version of Span used a wrong specific value of Alignement and LineBreakMode Change-Id: I78baded712ce18f279774b09608c2a2d19931a69 --- .../Native/LineBreakMode.cs | 7 +++++- Xamarin.Forms.Platform.Tizen/Native/Span.cs | 15 +++++++++--- .../Native/TextAlignment.cs | 5 ++++ .../Renderers/LabelRenderer.cs | 27 +--------------------- 4 files changed, 24 insertions(+), 30 deletions(-) (limited to 'Xamarin.Forms.Platform.Tizen') diff --git a/Xamarin.Forms.Platform.Tizen/Native/LineBreakMode.cs b/Xamarin.Forms.Platform.Tizen/Native/LineBreakMode.cs index 27253ad1..e8727f44 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/LineBreakMode.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/LineBreakMode.cs @@ -5,6 +5,11 @@ namespace Xamarin.Forms.Platform.Tizen.Native /// public enum LineBreakMode { + /// + /// Follow base LineBreakMode. + /// + None, + /// /// Do not wrap text. /// @@ -38,6 +43,6 @@ namespace Xamarin.Forms.Platform.Tizen.Native /// /// Truncate the tail of text. /// - TailTruncation + TailTruncation, } } diff --git a/Xamarin.Forms.Platform.Tizen/Native/Span.cs b/Xamarin.Forms.Platform.Tizen/Native/Span.cs index 41a20b7d..50d596a4 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/Span.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/Span.cs @@ -121,9 +121,9 @@ namespace Xamarin.Forms.Platform.Tizen.Native FontAttributes = FontAttributes.None; ForegroundColor = EColor.Default; BackgroundColor = EColor.Default; - HorizontalTextAlignment = TextAlignment.Auto; - VerticalTextAlignment = TextAlignment.Auto; - LineBreakMode = LineBreakMode.MixedWrap; + HorizontalTextAlignment = TextAlignment.None; + VerticalTextAlignment = TextAlignment.None; + LineBreakMode = LineBreakMode.None; Underline = false; Strikethrough = false; } @@ -264,6 +264,9 @@ namespace Xamarin.Forms.Platform.Tizen.Native case TextAlignment.Center: _formattingString.Append("align=center "); break; + + case TextAlignment.None: + break; } switch (VerticalTextAlignment) @@ -280,6 +283,9 @@ namespace Xamarin.Forms.Platform.Tizen.Native case TextAlignment.Center: _formattingString.Append("valign=middle "); break; + + case TextAlignment.None: + break; } switch (LineBreakMode) @@ -311,6 +317,9 @@ namespace Xamarin.Forms.Platform.Tizen.Native case LineBreakMode.TailTruncation: _formattingString.Append("ellipsis=1.0"); break; + + case LineBreakMode.None: + break; } return _formattingString; diff --git a/Xamarin.Forms.Platform.Tizen/Native/TextAlignment.cs b/Xamarin.Forms.Platform.Tizen/Native/TextAlignment.cs index c7e934bf..33fa72b0 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/TextAlignment.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/TextAlignment.cs @@ -5,6 +5,11 @@ namespace Xamarin.Forms.Platform.Tizen.Native /// public enum TextAlignment { + /// + /// Follow base TextAlignment + /// + None, + /// /// Aligns horizontal text according to language. Top aligned for vertical text. /// diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs index a1c07134..3f26f4ea 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs @@ -65,9 +65,6 @@ namespace Xamarin.Forms.Platform.Tizen nativeSpan.FontAttributes = span.FontAttributes; nativeSpan.FontFamily = span.FontFamily; nativeSpan.FontSize = span.FontSize; - nativeSpan.LineBreakMode = Control.LineBreakMode; - nativeSpan.HorizontalTextAlignment = Control.HorizontalTextAlignment; - nativeSpan.VerticalTextAlignment = Control.VerticalTextAlignment; nativeSpan.ForegroundColor = span.ForegroundColor.ToNative(); nativeSpan.BackgroundColor = span.BackgroundColor.ToNative(); nativeString.Spans.Add(nativeSpan); @@ -89,15 +86,6 @@ namespace Xamarin.Forms.Platform.Tizen void UpdateTextAlignment() { - if (Control.FormattedText != null) - { - foreach (var span in Control.FormattedText.Spans) - { - span.HorizontalTextAlignment = Element.HorizontalTextAlignment.ToNative(); - span.VerticalTextAlignment = Element.VerticalTextAlignment.ToNative(); - } - } - Control.HorizontalTextAlignment = Element.HorizontalTextAlignment.ToNative(); Control.VerticalTextAlignment = Element.VerticalTextAlignment.ToNative(); } @@ -111,26 +99,13 @@ namespace Xamarin.Forms.Platform.Tizen void UpdateLineBreakMode() { - if (Control.FormattedText != null) - { - foreach (var span in Control.FormattedText.Spans) - { - span.LineBreakMode = ConvertToNativeLineBreakMode(Element.LineBreakMode); - } - } 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); } -- cgit v1.2.3