Skip to content

Commit

Permalink
Update RadioButton icons
Browse files Browse the repository at this point in the history
  • Loading branch information
enisn committed Nov 18, 2022
1 parent 6567797 commit a9f05e8
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/InputKit.Maui/Shared/Controls/RadioButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public class RadioButton : StatefulStackLayout
{
Fill = GlobalSetting.Color,
Scale = 0,
Aspect = Stretch.Uniform,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
HeightRequest = GlobalSetting.Size,
WidthRequest = GlobalSetting.Size
WidthRequest = GlobalSetting.Size,
};
protected internal Label lblText = new Label
{
Expand All @@ -61,6 +62,7 @@ public class RadioButton : StatefulStackLayout
LineBreakMode = LineBreakMode.WordWrap
};
private bool _isDisabled;
const double DOT_FULL_SCALE = .65;
#endregion

#region Ctor
Expand Down Expand Up @@ -90,15 +92,18 @@ public RadioButton()
ApplyLabelPosition(LabelPosition);
UpdateShape();

GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() =>
GestureRecognizers.Add(new TapGestureRecognizer
{
if (IsDisabled)
Command = new Command(() =>
{
return;
}
if (IsDisabled)
{
return;
}
IsChecked = true;
})});
IsChecked = true;
})
});
}
#endregion

Expand Down Expand Up @@ -268,13 +273,13 @@ public virtual void ApplyIsChecked(bool isChecked)
Clicked?.Invoke(this, new EventArgs());
ClickCommand?.Execute(CommandParameter ?? Value);

var isCheckedInLastState = iconChecked.Scale == 1;
var isCheckedInLastState = iconChecked.Scale == DOT_FULL_SCALE;

var changed = isCheckedInLastState != isChecked;

if (changed)
{
iconChecked.ScaleTo(Convert.ToDouble(isChecked), 180);
iconChecked.ScaleTo(isChecked ? DOT_FULL_SCALE : 0, 180);
UpdateColors();
Checked?.Invoke(this, null);
}
Expand Down

0 comments on commit a9f05e8

Please sign in to comment.