summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Entry.cs30
-rw-r--r--Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/FontWeight.cs18
-rw-r--r--Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Label.cs30
-rw-r--r--Xamarin.Forms.Core/Xamarin.Forms.Core.csproj3
-rw-r--r--Xamarin.Forms.Platform.Tizen/Native/Entry.cs26
-rw-r--r--Xamarin.Forms.Platform.Tizen/Native/FontWeight.cs21
-rw-r--r--Xamarin.Forms.Platform.Tizen/Native/Label.cs21
-rw-r--r--Xamarin.Forms.Platform.Tizen/Native/Span.cs47
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs43
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs48
-rw-r--r--Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj3
-rw-r--r--packaging/xamarin-forms-tizen.spec2
12 files changed, 288 insertions, 4 deletions
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Entry.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Entry.cs
new file mode 100644
index 0000000..c84dcc3
--- /dev/null
+++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Entry.cs
@@ -0,0 +1,30 @@
+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;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/FontWeight.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/FontWeight.cs
new file mode 100644
index 0000000..8838bc0
--- /dev/null
+++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/FontWeight.cs
@@ -0,0 +1,18 @@
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ public enum FontWeight
+ {
+ None,
+ Normal,
+ Thin,
+ UltraLight,
+ Light,
+ Book,
+ Medium,
+ SemiBold,
+ Bold,
+ UltraBold,
+ Black,
+ ExtraBlack
+ }
+}
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Label.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Label.cs
new file mode 100644
index 0000000..d95daa8
--- /dev/null
+++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Label.cs
@@ -0,0 +1,30 @@
+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;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
index af940a6..6d3ce33 100644
--- a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
+++ b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
@@ -103,11 +103,14 @@
<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" />
diff --git a/Xamarin.Forms.Platform.Tizen/Native/Entry.cs b/Xamarin.Forms.Platform.Tizen/Native/Entry.cs
index 808155c..003a298 100644
--- a/Xamarin.Forms.Platform.Tizen/Native/Entry.cs
+++ b/Xamarin.Forms.Platform.Tizen/Native/Entry.cs
@@ -1,4 +1,4 @@
-´╗┐using System;
+using System;
using ElmSharp;
using EEntry = ElmSharp.Entry;
using EColor = ElmSharp.Color;
@@ -180,6 +180,30 @@ namespace Xamarin.Forms.Platform.Tizen.Native
}
/// <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>
diff --git a/Xamarin.Forms.Platform.Tizen/Native/FontWeight.cs b/Xamarin.Forms.Platform.Tizen/Native/FontWeight.cs
new file mode 100644
index 0000000..90bb637
--- /dev/null
+++ b/Xamarin.Forms.Platform.Tizen/Native/FontWeight.cs
@@ -0,0 +1,21 @@
+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 9d52cde..231127c 100644
--- a/Xamarin.Forms.Platform.Tizen/Native/Label.cs
+++ b/Xamarin.Forms.Platform.Tizen/Native/Label.cs
@@ -175,6 +175,27 @@ namespace Xamarin.Forms.Platform.Tizen.Native
}
/// <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>
diff --git a/Xamarin.Forms.Platform.Tizen/Native/Span.cs b/Xamarin.Forms.Platform.Tizen/Native/Span.cs
index 4a5daf3..028e9db 100644
--- a/Xamarin.Forms.Platform.Tizen/Native/Span.cs
+++ b/Xamarin.Forms.Platform.Tizen/Native/Span.cs
@@ -77,6 +77,11 @@ namespace Xamarin.Forms.Platform.Tizen.Native
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>
@@ -112,6 +117,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
Text = "";
FontFamily = "";
FontSize = -1;
+ FontWeight = FontWeight.None;
FontAttributes = FontAttributes.None;
ForegroundColor = EColor.Default;
BackgroundColor = EColor.Default;
@@ -183,6 +189,47 @@ namespace Xamarin.Forms.Platform.Tizen.Native
{
_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 ");
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
index 95828c0..46af352 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
@@ -1,5 +1,8 @@
-´╗┐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
{
@@ -21,6 +24,7 @@ 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)
@@ -123,5 +127,42 @@ namespace Xamarin.Forms.Platform.Tizen
{
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;
+ }
+ }
}
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs
index 9f4157e..a1c0713 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs
@@ -1,4 +1,7 @@
+using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+
using EColor = ElmSharp.Color;
+using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Label;
namespace Xamarin.Forms.Platform.Tizen
{
@@ -19,6 +22,7 @@ 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)
@@ -117,6 +121,19 @@ namespace Xamarin.Forms.Platform.Tizen
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)
@@ -136,5 +153,36 @@ 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 818e480..012512b 100644
--- a/Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj
+++ b/Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj
@@ -79,6 +79,7 @@
<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" />
@@ -160,4 +161,4 @@
<_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
<AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
</PropertyGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/packaging/xamarin-forms-tizen.spec b/packaging/xamarin-forms-tizen.spec
index f9778ba..968fd92 100644
--- a/packaging/xamarin-forms-tizen.spec
+++ b/packaging/xamarin-forms-tizen.spec
@@ -1,7 +1,7 @@
%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