Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Core/src/Handlers/Picker/PickerHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ void UpdatePickerFromPickerSource(PickerSource? pickerSource)
return;

PlatformView.Text = VirtualView.GetItem(pickerSource.SelectedIndex);
Comment thread
SyedAbdulAzeemSF4852 marked this conversation as resolved.

VirtualView.SelectedIndex = pickerSource.SelectedIndex;
}

Expand Down
4 changes: 3 additions & 1 deletion src/Core/src/Platform/iOS/PickerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ internal static void UpdatePicker(this MauiPicker platformPicker, IPicker picker
platformPicker.UpdatePickerTitle(picker);
}

platformPicker.UpdateCharacterSpacing(picker);

var pickerView = platformPicker.UIPickerView;
pickerView?.ReloadAllComponents();

Expand All @@ -66,4 +68,4 @@ internal static void UpdatePicker(this MauiPicker platformPicker, IPicker picker
pickerView?.Select(Math.Max(selectedIndex, 0), 0, true);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,55 @@ public async Task TextColorInitializesCorrectly()
Assert.Equal(expectedValue, values.PlatformViewValue);
}

[Fact(DisplayName = "CharacterSpacing Initializes Correctly")]
public async Task CharacterSpacingInitializesCorrectly()
{
const double xplatCharacterSpacing = 4;

var picker = new PickerStub
{
Items = new[] { "Item 1", "Item 2", "Item 3" },
SelectedIndex = 1,
CharacterSpacing = xplatCharacterSpacing
};

var values = await GetValueAsync(picker, (handler) =>
{
return new
{
ViewValue = picker.CharacterSpacing,
PlatformViewValue = GetNativeCharacterSpacing(handler)
};
});

Assert.Equal(xplatCharacterSpacing, values.ViewValue);
Assert.Equal(xplatCharacterSpacing, values.PlatformViewValue);
}

[Fact(DisplayName = "CharacterSpacing Maintained After SelectedIndex Change")]
public async Task CharacterSpacingMaintainedAfterSelectedIndexChange()
{
const double xplatCharacterSpacing = 4;

var picker = new PickerStub
{
Items = new[] { "Item 1", "Item 2", "Item 3" },
SelectedIndex = 0,
CharacterSpacing = xplatCharacterSpacing
};

await SetValueAsync(picker, 2, (handler, value) =>
{
handler.VirtualView.SelectedIndex = value;
handler.UpdateValue(nameof(IPicker.SelectedIndex));
});

var nativeCharacterSpacing = await GetValueAsync(picker, (handler) =>
GetNativeCharacterSpacing(handler));

Assert.Equal(xplatCharacterSpacing, nativeCharacterSpacing);
}

MauiPicker GetNativePicker(PickerHandler pickerHandler) =>
pickerHandler.PlatformView;

Expand Down Expand Up @@ -110,6 +159,12 @@ UIColor GetNativeTextColor(PickerHandler pickerHandler)
return mauiPicker.TextColor;
}

double GetNativeCharacterSpacing(PickerHandler pickerHandler)
{
var mauiPicker = GetNativePicker(pickerHandler);
return mauiPicker.AttributedText.GetCharacterSpacing();
}

UIControlContentVerticalAlignment GetNativeVerticalTextAlignment(PickerHandler pickerHandler) =>
GetNativePicker(pickerHandler).VerticalAlignment;
}
Expand Down
Loading