Fixing two issues with the ToggleSwitch control: (1) The ToggleSwitch would still react to user interactions even if disabled (tested on Android 13), and (2) the ToggleSwitch's visual appearance did not match its actual value upon initialization.

This commit is contained in:
David 2023-04-27 00:07:23 -06:00
Родитель bd81ba916d
Коммит b9ca4d3ebe
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -134,6 +134,8 @@ namespace AlohaKit.Controls
Toggled?.Invoke(this, new ToggledEventArgs(IsOn));
Invalidate();
AnimateToggle();
}
void UpdateHasShadow()
@ -148,9 +150,10 @@ namespace AlohaKit.Controls
void OnToggleSwitchStartInteraction(object sender, TouchEventArgs e)
{
IsOn = !IsOn;
AnimateToggle();
if (IsEnabled)
{
IsOn = !IsOn;
}
}
void AnimateToggle()