Skip to content

Commit

Permalink
Fixing two issues with the ToggleSwitch control: (1) The ToggleSwitch…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
davepruitt committed Apr 27, 2023
1 parent bd81ba9 commit b9ca4d3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/AlohaKit/Controls/ToggleSwitch/ToggleSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ void UpdateIsOn()
Toggled?.Invoke(this, new ToggledEventArgs(IsOn));

Invalidate();

AnimateToggle();
}

void UpdateHasShadow()
Expand All @@ -148,9 +150,10 @@ void UpdateHasShadow()

void OnToggleSwitchStartInteraction(object sender, TouchEventArgs e)
{
IsOn = !IsOn;

AnimateToggle();
if (IsEnabled)
{
IsOn = !IsOn;
}
}

void AnimateToggle()
Expand Down

0 comments on commit b9ca4d3

Please sign in to comment.