summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen')
-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
7 files changed, 206 insertions, 3 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Native/Entry.cs b/Xamarin.Forms.Platform.Tizen/Native/Entry.cs
index 808155c5..003a298b 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 00000000..90bb6370
--- /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 9d52cde2..231127c2 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 4a5daf3c..028e9db9 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 95828c04..46af3520 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 9f4157ed..a1c07134 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 818e4803..012512b1 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