Skip to content

Commit

Permalink
Merge pull request #2 from felipebaltazar/feature/icon-doc-fix
Browse files Browse the repository at this point in the history
[Fix for #1]  Animate twice when `toggle mode` button tapped
  • Loading branch information
felipebaltazar authored Apr 26, 2020
2 parents f3857b2 + 1ae2d1b commit 0705173
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 8 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/PrCheck.yml
Original file line number Diff line number Diff line change
@@ -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
Binary file added Images/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,14 @@ xmlns:neo="clr-namespace:Xamarin.Forms.NeoControls;assembly=Xamarin.Forms.NeoCon
</neo:NeoButton>
```


## 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. | |
11 changes: 6 additions & 5 deletions Xamarin.Forms.NeoControls/NeoButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public bool IsChecked
set => SetValue(IsCheckedProperty, value);
}

public event EventHandler Clicked;

public NeoButton()
{
var tapGesture = new TapGestureRecognizer();
Expand All @@ -89,13 +91,15 @@ public virtual Task<bool> 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);

Expand Down Expand Up @@ -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);
}
}
}
14 changes: 13 additions & 1 deletion Xamarin.Forms.NeoControls/NeoProgressView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -49,6 +50,8 @@ public Color BarColor

public virtual Task<bool> 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);
}
Expand Down Expand Up @@ -134,7 +137,7 @@ protected virtual SKPath CreateBarPath(SKPaint paint, SKCanvas canvas, float pad
protected virtual Task<bool> ProgressAnimation(string name, Func<double, float> transform, uint length, Easing easing)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
this.Animate(
(this).Animate(
name,
transform,
(progress) => Progress = progress,
Expand All @@ -145,5 +148,14 @@ protected virtual Task<bool> ProgressAnimation(string name, Func<double, float>

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);
}
}
9 changes: 8 additions & 1 deletion Xamarin.Forms.NeoControls/Xamarin.Forms.NeoControls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
<RepositoryUrl>https://github.com/felipebaltazar/Xamarin.Forms.NeoControls</RepositoryUrl>
<PackageTags>neomorphism, xamarin, xamarin.forms, skia, neomorphic</PackageTags>
<Description>Neomorphic controls for Xamarin.Forms</Description>
<Version>1.0.0-pre</Version>
<Version>1.0.1-pre</Version>
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<FileVersion>1.0.1.0</FileVersion>
<PackageIcon>Icon.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
Expand All @@ -23,6 +26,10 @@
</ItemGroup>

<ItemGroup>
<None Include="..\Images\Icon.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
Expand Down

0 comments on commit 0705173

Please sign in to comment.