Skip to content

Commit

Permalink
Merge pull request #307 from enisn/4.1-checkbox-improvements
Browse files Browse the repository at this point in the history
Convert Type property of CheckBox to BindableProperty
  • Loading branch information
enisn committed Sep 17, 2022
2 parents 2d1ed44 + 51147d0 commit 506c199
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/InputKit.Maui/Shared/Controls/CheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public partial class CheckBox : StatefulStackLayout, IValidatable

protected Lazy<Path> iconValidation;

private CheckType _type = CheckType.Regular;
private bool _isEnabled;
#endregion

Expand Down Expand Up @@ -201,7 +200,7 @@ public Color Color
/// <summary>
/// Which icon will be shown when checkbox is checked
/// </summary>
public CheckType Type { get => _type; set { _type = value; UpdateType(); } }
public CheckType Type { get => (CheckType)GetValue(TypeProperty); set => SetValue(TypeProperty, value); }

/// <summary>
/// Size of Checkbox
Expand Down Expand Up @@ -330,6 +329,9 @@ public void DisplayValidation()
checkBox.iconValidation.Value.Fill = (Color)newValue;
}
});

public static readonly BindableProperty TypeProperty = BindableProperty.Create(nameof(Type), typeof(CheckType), typeof(CheckBox), defaultValue: CheckType.Regular,
propertyChanged: (bindable, oldValue, newValue)=> (bindable as CheckBox).UpdateType());
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
#endregion

Expand Down
11 changes: 4 additions & 7 deletions src/Xamarin.Forms.InputKit/Shared/Controls/CheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

namespace Plugin.InputKit.Shared.Controls
{
/// <summary>
/// A checkbox for boolean inputs. It Includes a text inside
/// </summary>

/// <summary>
/// A checkbox for boolean inputs. It Includes a text inside
/// </summary>
Expand Down Expand Up @@ -68,7 +64,6 @@ public partial class CheckBox : StatefulStackLayout, IValidatable
};

protected Lazy<Path> iconValidation;
private CheckType _type = CheckType.Regular;
private bool _isEnabled;
#endregion

Expand Down Expand Up @@ -203,7 +198,7 @@ public Color Color
/// <summary>
/// Which icon will be shown when checkbox is checked
/// </summary>
public CheckType Type { get => _type; set { _type = value; UpdateType(); } }
public CheckType Type { get => (CheckType)GetValue(TypeProperty); set => SetValue(TypeProperty, value); }

/// <summary>
/// Size of Checkbox
Expand Down Expand Up @@ -329,7 +324,9 @@ public void DisplayValidation()
{
checkBox.iconValidation.Value.Fill = ((Color)newValue).ToBrush();
}
});
});
public static readonly BindableProperty TypeProperty = BindableProperty.Create(nameof(Type), typeof(CheckType), typeof(CheckBox), defaultValue: CheckType.Regular,
propertyChanged: (bindable, oldValue, newValue) => (bindable as CheckBox).UpdateType());
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
#endregion

Expand Down

0 comments on commit 506c199

Please sign in to comment.