- This change is for the referernce application (Clock) to follow UX guideline. (Internal only).
- We will improve design and implementation of this APIs in the next release, if requred.
Change-Id: Ifac91174a5859adecc9ec6bff1a1d568512ee70b
--- /dev/null
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ using FormsElement = Forms.Entry;
+
+ public static class Entry
+ {
+ public static readonly BindableProperty FontWeightProperty = BindableProperty.Create("FontWeight", typeof(FontWeight), typeof(FormsElement), FontWeight.None);
+
+ public static FontWeight GetFontWeight(BindableObject element)
+ {
+ return (FontWeight)element.GetValue(FontWeightProperty);
+ }
+
+ public static void SetFontWeight(BindableObject element, FontWeight weight)
+ {
+ element.SetValue(FontWeightProperty, weight);
+ }
+
+ public static FontWeight GetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config)
+ {
+ return GetFontWeight(config.Element);
+ }
+
+ public static IPlatformElementConfiguration<Tizen, FormsElement> SetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config, FontWeight weight)
+ {
+ SetFontWeight(config.Element, weight);
+ return config;
+ }
+ }
+}
--- /dev/null
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ public enum FontWeight
+ {
+ None,
+ Normal,
+ Thin,
+ UltraLight,
+ Light,
+ Book,
+ Medium,
+ SemiBold,
+ Bold,
+ UltraBold,
+ Black,
+ ExtraBlack
+ }
+}
--- /dev/null
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ using FormsElement = Forms.Label;
+
+ public static class Label
+ {
+ public static readonly BindableProperty FontWeightProperty = BindableProperty.Create("FontWeight", typeof(FontWeight), typeof(FormsElement), FontWeight.None);
+
+ public static FontWeight GetFontWeight(BindableObject element)
+ {
+ return (FontWeight)element.GetValue(FontWeightProperty);
+ }
+
+ public static void SetFontWeight(BindableObject element, FontWeight weight)
+ {
+ element.SetValue(FontWeightProperty, weight);
+ }
+
+ public static FontWeight GetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config)
+ {
+ return GetFontWeight(config.Element);
+ }
+
+ public static IPlatformElementConfiguration<Tizen, FormsElement> SetFontWeight(this IPlatformElementConfiguration<Tizen, FormsElement> config, FontWeight weight)
+ {
+ SetFontWeight(config.Element, weight);
+ return config;
+ }
+ }
+}
<Compile Include="PlatformConfiguration\iOSSpecific\UIStatusBarAnimation.cs" />
<Compile Include="PlatformConfiguration\iOSSpecific\UpdateMode.cs" />
<Compile Include="PlatformConfiguration\iOSSpecific\VisualElement.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\Entry.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\Label.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\Image.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\ProgressBar.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\Button.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\ButtonStyle.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\Switch.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\FontWeight.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\SwitchStyle.cs" />
<Compile Include="PlatformConfiguration\WindowsSpecific\MasterDetailPage.cs" />
<Compile Include="PlatformConfiguration\WindowsSpecific\CollapseStyle.cs" />
-using System;
+using System;
using ElmSharp;
using EEntry = ElmSharp.Entry;
using EColor = ElmSharp.Color;
}
/// <summary>
+ /// Gets or sets the font weight for the text.
+ /// </summary>
+ /// <value>The weight of the font.</value>
+ public FontWeight FontWeight
+ {
+ get
+ {
+ return _span.FontWeight;
+ }
+
+ set
+ {
+ if (value != _span.FontWeight)
+ {
+ _span.FontWeight = value;
+ ApplyTextAndStyle();
+
+ _placeholderSpan.FontWeight = value;
+ ApplyPlaceholderAndStyle();
+ }
+ }
+ }
+
+ /// <summary>
/// Gets or sets the horizontal text alignment of both text and placeholder.
/// </summary>
/// <value>The horizontal text alignment of both text and placeholder.</value>
--- /dev/null
+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
+ }
+}
}
/// <summary>
+ /// Gets or sets the font weight for the text.
+ /// </summary>
+ /// <value>The weight of the font.</value>
+ public FontWeight FontWeight
+ {
+ get
+ {
+ return _span.FontWeight;
+ }
+
+ set
+ {
+ if (value != _span.FontWeight)
+ {
+ _span.FontWeight = value;
+ ApplyTextAndStyle();
+ }
+ }
+ }
+
+ /// <summary>
/// Gets or sets the line wrap option.
/// </summary>
/// <value>The line break mode.</value>
public double FontSize { get; set; }
/// <summary>
+ /// Gets or sets the font weight for the text.
+ /// </summary>
+ public FontWeight FontWeight { get; set; }
+
+ /// <summary>
/// Gets or sets the line break mode for the text.
/// See <see cref="LineBreakMode"/> for information about LineBreakMode.
/// </summary>
Text = "";
FontFamily = "";
FontSize = -1;
+ FontWeight = FontWeight.None;
FontAttributes = FontAttributes.None;
ForegroundColor = EColor.Default;
BackgroundColor = EColor.Default;
{
_formattingString.Append("font_weight=Bold ");
}
+ else
+ {
+ // FontWeight is only available in case of FontAttributes.Bold is not used.
+ switch (FontWeight)
+ {
+ 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;
+ }
+ }
+
if ((FontAttributes & FontAttributes.Italic) != 0)
{
_formattingString.Append("font_style=italic ");
-using System;
+using System;
+using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+
using EColor = ElmSharp.Color;
+using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Entry;
namespace Xamarin.Forms.Platform.Tizen
{
RegisterPropertyHandler(Entry.KeyboardProperty, UpdateKeyboard);
RegisterPropertyHandler(Entry.PlaceholderProperty, UpdatePlaceholder);
RegisterPropertyHandler(Entry.PlaceholderColorProperty, UpdatePlaceholderColor);
+ RegisterPropertyHandler(Specific.FontWeightProperty, UpdateFontWeight);
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
Control.PlaceholderColor = Element.PlaceholderColor.IsDefault ? s_defaultPlaceholderColor : Element.PlaceholderColor.ToNative();
}
+
+ 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;
+ }
+ }
}
}
+using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+
using EColor = ElmSharp.Color;
+using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Label;
namespace Xamarin.Forms.Platform.Tizen
{
RegisterPropertyHandler(Label.HorizontalTextAlignmentProperty, UpdateTextAlignment);
RegisterPropertyHandler(Label.VerticalTextAlignmentProperty, UpdateTextAlignment);
RegisterPropertyHandler(Label.FormattedTextProperty, UpdateFormattedText);
+ RegisterPropertyHandler(Specific.FontWeightProperty, UpdateFontWeight);
}
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
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);
+ }
+
Native.LineBreakMode ConvertToNativeLineBreakMode(LineBreakMode mode)
{
switch (mode)
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;
+ }
+ }
}
}
<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" />
<_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
<AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
</PropertyGroup>
-</Project>
+</Project>
\ No newline at end of file
%define XF_VERSION 2.3.3.175
# Increase this XF_TIZEN_VERSION when any public APIs of Xamarin.Forms.Platform.Tizen are changed.
-%define XF_TIZEN_VERSION beta-006
+%define XF_TIZEN_VERSION beta-007
Name: xamarin-forms-tizen
Summary: Xamarin.Forms for Tizen platform