diff options
author | Kangho Hur <kangho.hur@samsung.com> | 2017-02-14 12:42:06 +0900 |
---|---|---|
committer | Kangho Hur <kangho.hur@samsung.com> | 2017-04-24 13:36:53 +0900 |
commit | a494dc82289fbe4904a2bb5b31802729c24b91c9 (patch) | |
tree | dfa4cc5eff1fbce6179475358b47915a44dcb032 | |
parent | 75b8ca3ef7e850a511e72acf657a718a9d5f5469 (diff) | |
download | xamarin-forms-a494dc82289fbe4904a2bb5b31802729c24b91c9.tar.gz xamarin-forms-a494dc82289fbe4904a2bb5b31802729c24b91c9.tar.bz2 xamarin-forms-a494dc82289fbe4904a2bb5b31802729c24b91c9.zip |
Modify FontWeight type for flexibility
This change is introduced in RFC-15
Change-Id: I8bc22b8818ccda3bee95c83e6979e39810e6b028
11 files changed, 35 insertions, 157 deletions
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Entry.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Entry.cs index c84dcc36..6572610a 100644 --- a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Entry.cs +++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Entry.cs @@ -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; diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/FontWeight.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/FontWeight.cs index 8838bc07..763935b2 100644 --- a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/FontWeight.cs +++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/FontWeight.cs @@ -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"; } } diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Label.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Label.cs index d95daa83..f560057a 100644 --- a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Label.cs +++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Label.cs @@ -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; diff --git a/Xamarin.Forms.Platform.Tizen/Native/Entry.cs b/Xamarin.Forms.Platform.Tizen/Native/Entry.cs index 003a298b..26b775c8 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/Entry.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/Entry.cs @@ -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 index 90bb6370..00000000 --- a/Xamarin.Forms.Platform.Tizen/Native/FontWeight.cs +++ /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 - } -} diff --git a/Xamarin.Forms.Platform.Tizen/Native/Label.cs b/Xamarin.Forms.Platform.Tizen/Native/Label.cs index 231127c2..a75e6aa8 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/Label.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/Label.cs @@ -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 { diff --git a/Xamarin.Forms.Platform.Tizen/Native/Span.cs b/Xamarin.Forms.Platform.Tizen/Native/Span.cs index 50d596a4..8120105f 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/Span.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/Span.cs @@ -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); } } diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs index eea46e80..39f26b4f 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs @@ -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 diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs index 46af3520..7e7c8925 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs @@ -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); } } } diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs index 3f26f4ea..49611e4b 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs @@ -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; - } - } } } diff --git a/Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj b/Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj index 5c8ac950..6f8a65c9 100644 --- a/Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj +++ b/Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj @@ -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" /> |