diff --git a/.github/workflows/PrCheck.yml b/.github/workflows/PrCheck.yml new file mode 100644 index 0000000..347379f --- /dev/null +++ b/.github/workflows/PrCheck.yml @@ -0,0 +1,17 @@ +name: Build Xamarin.Forms.NeoControls + +on: [pull_request] + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v1 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.200 + - name: Build with dotnet core + run: dotnet build --configuration Release \ No newline at end of file diff --git a/Images/Icon.png b/Images/Icon.png new file mode 100644 index 0000000..86497e9 Binary files /dev/null and b/Images/Icon.png differ diff --git a/README.md b/README.md index 0a90b6a..762e59a 100644 --- a/README.md +++ b/README.md @@ -43,4 +43,14 @@ xmlns:neo="clr-namespace:Xamarin.Forms.NeoControls;assembly=Xamarin.Forms.NeoCon ``` - +## Property reference + +| Property | What it does | Extra info | +| ------------------ | --------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `CornerRadius` | A `CornerRadius` object representing each individual corner's radius. | Uses the `CornerRadius` struct allowing you to specify individual corners. | +| `Elevation` | Set this value to chenge element depth effect. | | +| `InnerView` | View that will be shown inside the neo control. | | +| `ShadowBlur` | Set this value to change shadow blur effect. | | +| `ShadowDistance` | Set this value to change shadow distance relative from control. | | +| `DarkShadowColor` | The Dark color that will be applied on draw the dark shadow. | This will be applied with `Elevation` property, as Alpha parameter. | +| `LightShadowColor` | The White color that will be applied on draw the light shadow. | | \ No newline at end of file diff --git a/Xamarin.Forms.NeoControls/NeoButton.cs b/Xamarin.Forms.NeoControls/NeoButton.cs index 11b478e..cffe6ec 100644 --- a/Xamarin.Forms.NeoControls/NeoButton.cs +++ b/Xamarin.Forms.NeoControls/NeoButton.cs @@ -74,6 +74,8 @@ public bool IsChecked set => SetValue(IsCheckedProperty, value); } + public event EventHandler Clicked; + public NeoButton() { var tapGesture = new TapGestureRecognizer(); @@ -89,13 +91,15 @@ public virtual Task AnimateClick(double toValue, uint length = 250, Easing protected virtual async Task PerformButtonTappedAsync() { - if (isPerformingTap) + if (isPerformingTap || !IsEnabled) return; isPerformingTap = true; try { + Clicked?.Invoke(this, EventArgs.Empty); + if (Command?.CanExecute(CommandParameter) ?? false) Command.Execute(CommandParameter); @@ -199,10 +203,7 @@ private static void OnIsCheckedChanged(BindableObject bindable, object oldValue, PerformIsCheckedAnimationAsync(neoButton).SafeFireAndForget(); } - private static async Task PerformIsCheckedAnimationAsync(NeoButton neoButton) - { + private static async Task PerformIsCheckedAnimationAsync(NeoButton neoButton) => await neoButton.AnimateClick(neoButton.ShadowDistance * -1); - await neoButton.AnimateClick(neoButton.ShadowDistance); - } } } diff --git a/Xamarin.Forms.NeoControls/NeoProgressView.cs b/Xamarin.Forms.NeoControls/NeoProgressView.cs index 4d81a86..cbd90f3 100644 --- a/Xamarin.Forms.NeoControls/NeoProgressView.cs +++ b/Xamarin.Forms.NeoControls/NeoProgressView.cs @@ -20,6 +20,7 @@ public class NeoProgressView : NeoView returnType: typeof(double), declaringType: typeof(NeoProgressView), defaultValue: .4, + propertyChanging: OnProgressChanging, propertyChanged: OnVisualPropertyChanged); public static readonly BindableProperty ThicknessProperty = BindableProperty.Create( @@ -49,6 +50,8 @@ public Color BarColor public virtual Task AnimateProgress(float toValue, uint length = 250, Easing easing = null) { + EnsureProgressRange(toValue); + float transform(double t) => (float)(t * (toValue)); return ProgressAnimation(nameof(AnimateProgress), transform, length, easing); } @@ -134,7 +137,7 @@ protected virtual SKPath CreateBarPath(SKPaint paint, SKCanvas canvas, float pad protected virtual Task ProgressAnimation(string name, Func transform, uint length, Easing easing) { var taskCompletionSource = new TaskCompletionSource(); - this.Animate( + (this).Animate( name, transform, (progress) => Progress = progress, @@ -145,5 +148,14 @@ protected virtual Task ProgressAnimation(string name, Func return taskCompletionSource.Task; } + + private static void EnsureProgressRange(float progress) + { + if (progress > 1f || progress < 0) + throw new ArgumentOutOfRangeException($"{nameof(progress)} should be between 0 and 1"); + } + + private static void OnProgressChanging(BindableObject bindable, object oldValue, object newValue) => + EnsureProgressRange((float)newValue); } } diff --git a/Xamarin.Forms.NeoControls/Xamarin.Forms.NeoControls.csproj b/Xamarin.Forms.NeoControls/Xamarin.Forms.NeoControls.csproj index 9222aee..da2a16d 100644 --- a/Xamarin.Forms.NeoControls/Xamarin.Forms.NeoControls.csproj +++ b/Xamarin.Forms.NeoControls/Xamarin.Forms.NeoControls.csproj @@ -8,7 +8,10 @@ https://github.com/felipebaltazar/Xamarin.Forms.NeoControls neomorphism, xamarin, xamarin.forms, skia, neomorphic Neomorphic controls for Xamarin.Forms - 1.0.0-pre + 1.0.1-pre + 1.0.1.0 + 1.0.1.0 + Icon.png @@ -23,6 +26,10 @@ + + True + + True