Modify FontWeight type for flexibility
authorKangho Hur <kangho.hur@samsung.com>
Tue, 14 Feb 2017 03:42:06 +0000 (12:42 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Mon, 10 Jul 2017 02:11:19 +0000 (11:11 +0900)
This change is introduced in RFC-15

Change-Id: I8bc22b8818ccda3bee95c83e6979e39810e6b028

Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Entry.cs
Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/FontWeight.cs
Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Label.cs
Xamarin.Forms.Platform.Tizen/Native/Entry.cs
Xamarin.Forms.Platform.Tizen/Native/FontWeight.cs [deleted file]
Xamarin.Forms.Platform.Tizen/Native/Label.cs
Xamarin.Forms.Platform.Tizen/Native/Span.cs
Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs
Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj

index c84dcc3..6572610 100644 (file)
@@ -4,24 +4,24 @@ namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
 
        public static class Entry
        {
-               public static readonly BindableProperty FontWeightProperty = BindableProperty.Create("FontWeight", typeof(FontWeight), typeof(FormsElement), FontWeight.None);
+               public static readonly BindableProperty FontWeightProperty = BindableProperty.Create("FontWeight", typeof(string), typeof(FormsElement), FontWeight.None);
 
-               public static FontWeight GetFontWeight(BindableObject element)
+               public static string GetFontWeight(BindableObject element)
                {
-                       return (FontWeight)element.GetValue(FontWeightProperty);
+                       return (string)element.GetValue(FontWeightProperty);
                }
 
-               public static void SetFontWeight(BindableObject element, FontWeight weight)
+               public static void SetFontWeight(BindableObject element, string weight)
                {
                        element.SetValue(FontWeightProperty, weight);
                }
 
-               public static FontWeight GetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config)
+               public static string GetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config)
                {
                        return GetFontWeight(config.Element);
                }
 
-               public static IPlatformElementConfiguration<Tizen, FormsElement> SetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config, FontWeight weight)
+               public static IPlatformElementConfiguration<Tizen, FormsElement> SetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config, string weight)
                {
                        SetFontWeight(config.Element, weight);
                        return config;
index 8838bc0..763935b 100644 (file)
@@ -1,18 +1,18 @@
 namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
 {
-       public enum FontWeight
+       public static class FontWeight
        {
-               None,
-               Normal,
-               Thin,
-               UltraLight,
-               Light,
-               Book,
-               Medium,
-               SemiBold,
-               Bold,
-               UltraBold,
-               Black,
-               ExtraBlack
+               public const string None = "None";
+               public const string Normal = "Normal";
+               public const string Thin = "Thin";
+               public const string UltraLight = "UltraLight";
+               public const string Light = "Light";
+               public const string Book = "Book";
+               public const string Medium = "Medium";
+               public const string SemiBold = "SemiBold";
+               public const string Bold = "Bold";
+               public const string UltraBold = "UltraBold";
+               public const string Black= "Black";
+               public const string ExtraBlack= "ExtraBlack";
        }
 }
index d95daa8..f560057 100644 (file)
@@ -4,24 +4,24 @@ namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
 
        public static class Label
        {
-               public static readonly BindableProperty FontWeightProperty = BindableProperty.Create("FontWeight", typeof(FontWeight), typeof(FormsElement), FontWeight.None);
+               public static readonly BindableProperty FontWeightProperty = BindableProperty.Create("FontWeight", typeof(string), typeof(FormsElement), FontWeight.None);
 
-               public static FontWeight GetFontWeight(BindableObject element)
+               public static string GetFontWeight(BindableObject element)
                {
-                       return (FontWeight)element.GetValue(FontWeightProperty);
+                       return (string)element.GetValue(FontWeightProperty);
                }
 
-               public static void SetFontWeight(BindableObject element, FontWeight weight)
+               public static void SetFontWeight(BindableObject element, string weight)
                {
                        element.SetValue(FontWeightProperty, weight);
                }
 
-               public static FontWeight GetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config)
+               public static string GetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config)
                {
                        return GetFontWeight(config.Element);
                }
 
-               public static IPlatformElementConfiguration<Tizen, FormsElement> SetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config, FontWeight weight)
+               public static IPlatformElementConfiguration<Tizen, FormsElement> SetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config, string weight)
                {
                        SetFontWeight(config.Element, weight);
                        return config;
index 003a298..26b775c 100644 (file)
@@ -183,7 +183,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                /// Gets or sets the font weight for the text.
                /// </summary>
                /// <value>The weight of the font.</value>
-               public FontWeight FontWeight
+               public string FontWeight
                {
                        get
                        {
diff --git a/Xamarin.Forms.Platform.Tizen/Native/FontWeight.cs b/Xamarin.Forms.Platform.Tizen/Native/FontWeight.cs
deleted file mode 100644 (file)
index 90bb637..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-namespace Xamarin.Forms.Platform.Tizen.Native
-{
-       /// <summary>
-       /// Enumerates values that describe options for line braking.
-       /// </summary>
-       public enum FontWeight
-       {
-               None,
-               Normal,
-               Thin,
-               UltraLight,
-               Light,
-               Book,
-               Medium,
-               SemiBold,
-               Bold,
-               UltraBold,
-               Black,
-               ExtraBlack
-       }
-}
index 231127c..a75e6aa 100644 (file)
@@ -178,7 +178,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                /// Gets or sets the font weight for the text.
                /// </summary>
                /// <value>The weight of the font.</value>
-               public FontWeight FontWeight
+               public string FontWeight
                {
                        get
                        {
index 50d596a..8120105 100644 (file)
@@ -1,6 +1,7 @@
 using System;
 using System.Text;
 using EColor = ElmSharp.Color;
+using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific;
 
 namespace Xamarin.Forms.Platform.Tizen.Native
 {
@@ -79,7 +80,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                /// <summary>
                /// Gets or sets the font weight for the text.
                /// </summary>
-               public FontWeight FontWeight { get; set; }
+               public string FontWeight { get; set; }
 
                /// <summary>
                /// Gets or sets the line break mode for the text.
@@ -117,7 +118,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                        Text = "";
                        FontFamily = "";
                        FontSize = -1;
-                       FontWeight = FontWeight.None;
+                       FontWeight = Specific.FontWeight.None;
                        FontAttributes = FontAttributes.None;
                        ForegroundColor = EColor.Default;
                        BackgroundColor = EColor.Default;
@@ -192,41 +193,9 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                        else
                        {
                                // FontWeight is only available in case of FontAttributes.Bold is not used.
-                               switch (FontWeight)
+                               if(FontWeight != Specific.FontWeight.None)
                                {
-                                       case FontWeight.Bold:
-                                               _formattingString.Append("font_weight=Bold ");
-                                               break;
-                                       case FontWeight.SemiBold:
-                                               _formattingString.Append("font_weight=SemiBold ");
-                                               break;
-                                       case FontWeight.UltraBold:
-                                               _formattingString.Append("font_weight=UltraBold ");
-                                               break;
-                                       case FontWeight.Black:
-                                               _formattingString.Append("font_weight=Black ");
-                                               break;
-                                       case FontWeight.ExtraBlack:
-                                               _formattingString.Append("font_weight=ExtraBlack ");
-                                               break;
-                                       case FontWeight.Book:
-                                               _formattingString.Append("font_weight=Book ");
-                                               break;
-                                       case FontWeight.Light:
-                                               _formattingString.Append("font_weight=Light ");
-                                               break;
-                                       case FontWeight.Medium:
-                                               _formattingString.Append("font_weight=Medium ");
-                                               break;
-                                       case FontWeight.Normal:
-                                               _formattingString.Append("font_weight=Normal ");
-                                               break;
-                                       case FontWeight.Thin:
-                                               _formattingString.Append("font_weight=Thin ");
-                                               break;
-                                       case FontWeight.UltraLight:
-                                               _formattingString.Append("font_weight=UltraLight ");
-                                               break;
+                                       _formattingString.AppendFormat("font_weight={0} ", FontWeight);
                                }
                        }
 
index eea46e8..39f26b4 100644 (file)
@@ -1,7 +1,5 @@
 using System;
-using System.ComponentModel;
 using EColor = ElmSharp.Color;
-using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
 using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement;
 
 namespace Xamarin.Forms.Platform.Tizen
index 46af352..7e7c892 100644 (file)
@@ -130,39 +130,7 @@ namespace Xamarin.Forms.Platform.Tizen
 
                void UpdateFontWeight()
                {
-                       var weight = Specific.GetFontWeight(Element);
-                       Control.FontWeight = ConvertToNativeFontWeight(weight);
-               }
-
-               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;
-                       }
+                       Control.FontWeight = Specific.GetFontWeight(Element);
                }
        }
 }
index 3f26f4e..49611e4 100644 (file)
@@ -1,5 +1,3 @@
-using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
-
 using EColor = ElmSharp.Color;
 using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Label;
 
@@ -75,7 +73,7 @@ namespace Xamarin.Forms.Platform.Tizen
 
                void UpdateFormattedText()
                {
-                       if(Element.FormattedText != null)
+                       if (Element.FormattedText != null)
                                Control.FormattedText = ConvertFormattedText(Element.FormattedText);
                }
 
@@ -104,9 +102,7 @@ namespace Xamarin.Forms.Platform.Tizen
 
                void UpdateFontWeight()
                {
-                       var weight = Specific.GetFontWeight(Element);
-
-                       Control.FontWeight = ConvertToNativeFontWeight(weight);
+                       Control.FontWeight = Specific.GetFontWeight(Element);
                }
 
                Native.LineBreakMode ConvertToNativeLineBreakMode(LineBreakMode mode)
@@ -128,36 +124,5 @@ 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;
-                       }
-               }
        }
 }
index 5c8ac95..6f8a65c 100644 (file)
@@ -80,7 +80,6 @@
     <Compile Include="Native\Keyboard.cs" />
     <Compile Include="Native\Label.cs" />
     <Compile Include="Native\LayoutEventArgs.cs" />
-    <Compile Include="Native\FontWeight.cs" />
     <Compile Include="Native\LineBreakMode.cs" />
     <Compile Include="Native\ListView.cs" />
     <Compile Include="Native\MasterDetailPage.cs" />