Picker completed

This commit is contained in:
2026-01-16 05:38:45 +00:00
parent 59bcb9244e
commit c27f073938
2 changed files with 85 additions and 3 deletions

View File

@@ -160,22 +160,32 @@ public partial class PickerHandler : ViewHandler<IPicker, SkiaPicker>
{ {
handler.PlatformView.FontSize = font.Size; handler.PlatformView.FontSize = font.Size;
} }
// Map FontAttributes from the Font weight
var attrs = FontAttributes.None;
if (font.Weight >= FontWeight.Bold)
attrs |= FontAttributes.Bold;
handler.PlatformView.FontAttributes = attrs;
handler.PlatformView.Invalidate(); handler.PlatformView.Invalidate();
} }
public static void MapCharacterSpacing(PickerHandler handler, IPicker picker) public static void MapCharacterSpacing(PickerHandler handler, IPicker picker)
{ {
// Character spacing could be implemented with custom text rendering if (handler.PlatformView is null) return;
handler.PlatformView.CharacterSpacing = picker.CharacterSpacing;
} }
public static void MapHorizontalTextAlignment(PickerHandler handler, IPicker picker) public static void MapHorizontalTextAlignment(PickerHandler handler, IPicker picker)
{ {
// Text alignment would require changes to SkiaPicker drawing if (handler.PlatformView is null) return;
handler.PlatformView.HorizontalTextAlignment = picker.HorizontalTextAlignment;
} }
public static void MapVerticalTextAlignment(PickerHandler handler, IPicker picker) public static void MapVerticalTextAlignment(PickerHandler handler, IPicker picker)
{ {
// Text alignment would require changes to SkiaPicker drawing if (handler.PlatformView is null) return;
handler.PlatformView.VerticalTextAlignment = picker.VerticalTextAlignment;
} }
public static void MapBackground(PickerHandler handler, IPicker picker) public static void MapBackground(PickerHandler handler, IPicker picker)

View File

@@ -125,6 +125,42 @@ public class SkiaPicker : SkiaView
BindingMode.TwoWay, BindingMode.TwoWay,
propertyChanged: (b, o, n) => ((SkiaPicker)b).InvalidateMeasure()); propertyChanged: (b, o, n) => ((SkiaPicker)b).InvalidateMeasure());
public static readonly BindableProperty FontAttributesProperty =
BindableProperty.Create(
nameof(FontAttributes),
typeof(FontAttributes),
typeof(SkiaPicker),
FontAttributes.None,
BindingMode.TwoWay,
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
public static readonly BindableProperty CharacterSpacingProperty =
BindableProperty.Create(
nameof(CharacterSpacing),
typeof(double),
typeof(SkiaPicker),
0.0,
BindingMode.TwoWay,
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
public static readonly BindableProperty HorizontalTextAlignmentProperty =
BindableProperty.Create(
nameof(HorizontalTextAlignment),
typeof(TextAlignment),
typeof(SkiaPicker),
TextAlignment.Start,
BindingMode.TwoWay,
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
public static readonly BindableProperty VerticalTextAlignmentProperty =
BindableProperty.Create(
nameof(VerticalTextAlignment),
typeof(TextAlignment),
typeof(SkiaPicker),
TextAlignment.Center,
BindingMode.TwoWay,
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
public static readonly BindableProperty ItemHeightProperty = public static readonly BindableProperty ItemHeightProperty =
BindableProperty.Create( BindableProperty.Create(
nameof(ItemHeight), nameof(ItemHeight),
@@ -237,6 +273,42 @@ public class SkiaPicker : SkiaView
set => SetValue(FontSizeProperty, value); set => SetValue(FontSizeProperty, value);
} }
/// <summary>
/// Gets or sets the font attributes.
/// </summary>
public FontAttributes FontAttributes
{
get => (FontAttributes)GetValue(FontAttributesProperty);
set => SetValue(FontAttributesProperty, value);
}
/// <summary>
/// Gets or sets the character spacing.
/// </summary>
public double CharacterSpacing
{
get => (double)GetValue(CharacterSpacingProperty);
set => SetValue(CharacterSpacingProperty, value);
}
/// <summary>
/// Gets or sets the horizontal text alignment.
/// </summary>
public TextAlignment HorizontalTextAlignment
{
get => (TextAlignment)GetValue(HorizontalTextAlignmentProperty);
set => SetValue(HorizontalTextAlignmentProperty, value);
}
/// <summary>
/// Gets or sets the vertical text alignment.
/// </summary>
public TextAlignment VerticalTextAlignment
{
get => (TextAlignment)GetValue(VerticalTextAlignmentProperty);
set => SetValue(VerticalTextAlignmentProperty, value);
}
/// <summary> /// <summary>
/// Gets or sets the item height. /// Gets or sets the item height.
/// </summary> /// </summary>