diff --git a/Demo/App/App.csproj b/Demo/App/App.csproj index 78f485d..d0505cc 100644 --- a/Demo/App/App.csproj +++ b/Demo/App/App.csproj @@ -74,6 +74,9 @@ BackButton.xaml + + IsBusyTestPage.xaml + IsEnabledTestPage.xaml @@ -119,6 +122,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile diff --git a/Demo/App/Controls/CustomSwitchExamples/IosSwitch.xaml b/Demo/App/Controls/CustomSwitchExamples/IosSwitch.xaml index ca614df..13c1efc 100644 --- a/Demo/App/Controls/CustomSwitchExamples/IosSwitch.xaml +++ b/Demo/App/Controls/CustomSwitchExamples/IosSwitch.xaml @@ -5,6 +5,7 @@ xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"> + + + \ No newline at end of file diff --git a/Demo/App/Controls/CustomSwitchExamples/IosSwitch.xaml.cs b/Demo/App/Controls/CustomSwitchExamples/IosSwitch.xaml.cs index 62b39d3..e901ddf 100644 --- a/Demo/App/Controls/CustomSwitchExamples/IosSwitch.xaml.cs +++ b/Demo/App/Controls/CustomSwitchExamples/IosSwitch.xaml.cs @@ -30,6 +30,13 @@ public string AccessibilityHint set => SetValue(AccessibilityHintProperty, value); } + public static readonly BindableProperty IsBusyProperty = BindableProperty.Create(nameof(IsBusy), typeof(bool), typeof(CustomSwitch), false); + public bool IsBusy + { + get => (bool)GetValue(IsBusyProperty); + set => SetValue(IsBusyProperty, value); + } + public static readonly BindableProperty ToggledCommandProperty = BindableProperty.Create(nameof(ToggledCommand), typeof(ICommand), typeof(IosSwitch)); public ICommand ToggledCommand diff --git a/Demo/App/MainPage.xaml b/Demo/App/MainPage.xaml index 44a7014..3e0b692 100644 --- a/Demo/App/MainPage.xaml +++ b/Demo/App/MainPage.xaml @@ -10,6 +10,7 @@ + diff --git a/Demo/App/MainPage.xaml.cs b/Demo/App/MainPage.xaml.cs index e711150..d2fe4a1 100644 --- a/Demo/App/MainPage.xaml.cs +++ b/Demo/App/MainPage.xaml.cs @@ -29,6 +29,11 @@ async void IsEnabledBtn_Clicked(object sender, EventArgs e) await Navigation.PushAsync(new IsEnabledTestPage()); } + async void IsBusyBtn_Clicked(object sender, EventArgs e) + { + await Navigation.PushAsync(new IsBusyTestPage()); + } + async void PanGestureBtn_Clicked(object sender, EventArgs e) { await Navigation.PushAsync(new PanGestureTestPage()); diff --git a/Demo/App/Pages/IsBusyTestPage.xaml b/Demo/App/Pages/IsBusyTestPage.xaml new file mode 100644 index 0000000..c78078f --- /dev/null +++ b/Demo/App/Pages/IsBusyTestPage.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demo/App/Pages/IsBusyTestPage.xaml.cs b/Demo/App/Pages/IsBusyTestPage.xaml.cs new file mode 100644 index 0000000..30c1ee9 --- /dev/null +++ b/Demo/App/Pages/IsBusyTestPage.xaml.cs @@ -0,0 +1,9 @@ +namespace App.Pages; + +public partial class IsBusyTestPage : ContentPage +{ + public IsBusyTestPage() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/Scr/Switch/CustomSwitch.xaml b/Scr/Switch/CustomSwitch.xaml index 1632d17..b584a30 100644 --- a/Scr/Switch/CustomSwitch.xaml +++ b/Scr/Switch/CustomSwitch.xaml @@ -33,6 +33,7 @@ StrokeThickness="{Binding KnobStrokeThickness, Source={RelativeSource AncestorType={x:Type ContentView}}}" VerticalOptions="Center" WidthRequest="{Binding KnobWidth, Source={RelativeSource AncestorType={x:Type ContentView}}}" /> + \ No newline at end of file diff --git a/Scr/Switch/CustomSwitch.xaml.cs b/Scr/Switch/CustomSwitch.xaml.cs index 9b03762..fd67f71 100644 --- a/Scr/Switch/CustomSwitch.xaml.cs +++ b/Scr/Switch/CustomSwitch.xaml.cs @@ -176,6 +176,20 @@ public KnobLimitEnum KnobLimit set => SetValue(KnobLimitProperty, value); } + public static readonly BindableProperty IsBusyProperty = BindableProperty.Create(nameof(IsBusy), typeof(bool), typeof(CustomSwitch), false); + public bool IsBusy + { + get => (bool)GetValue(IsBusyProperty); + set => SetValue(IsBusyProperty, value); + } + + public static readonly BindableProperty IsBusyContentProperty = BindableProperty.Create(nameof(IsBusyContent), typeof(View), typeof(CustomSwitch), null); + public View? IsBusyContent + { + get => (View?)GetValue(IsBusyContentProperty); + set => SetValue(IsBusyContentProperty, value); + } + #endregion Properties #region Events @@ -205,8 +219,6 @@ public CustomSwitch() HasLoaded = true; }; - - } protected override void IsToggledChanged() @@ -215,7 +227,7 @@ protected override void IsToggledChanged() { return; } - + if (IsToggled && CurrentState != SwitchStateEnum.Right) { GoToRight();