Skip to content

Commit

Permalink
fix: FreakySwitch rewritten and FreakyButton with Visual states chang…
Browse files Browse the repository at this point in the history
…es (#111)
  • Loading branch information
FreakyAli authored Feb 25, 2024
1 parent 6df0896 commit 0de0401
Show file tree
Hide file tree
Showing 21 changed files with 379 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<RootNamespace>Maui.FreakyControls</RootNamespace>
<AssemblyVersion>0.4.10</AssemblyVersion>
<AssemblyFileVersion>0.4.10</AssemblyFileVersion>
<Version>0.4.10-pre</Version>
<Version>0.4.10</Version>
<NeutralLanguage>en</NeutralLanguage>
<!--Version of C# to use -->
<PackageId>FreakyControls</PackageId>
Expand All @@ -26,7 +26,7 @@
<RepositoryUrl>https://github.com/FreakyAli/MAUI.FreakyControls</RepositoryUrl>
<PackageProjectUrl>https://github.com/FreakyAli/MAUI.FreakyControls</PackageProjectUrl>
<PackageTags>Maui dotnet.Maui .net-Maui FreakyControls CodeView OTP PinCodeView Switch AutoComplete JumpList Button Checkbox uikit Signature Radiobutton SignatureView Svg CircularImage TextInputLayout</PackageTags>
<PackageReleaseNotes>.NET 8 Support for your favorite Freaky Controls!!!</PackageReleaseNotes>
<PackageReleaseNotes>FreakySwitch rewritten and changes and visual state changes</PackageReleaseNotes>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<Copyright>Copyright 2023</Copyright>
<PackOnBuild>true</PackOnBuild>
Expand Down Expand Up @@ -140,8 +140,8 @@
<ItemGroup>
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.7" />
<PackageReference Include="SkiaSharp.Svg" Version="1.60.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.6" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.6" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.7" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.7" />
<PackageReference Include="FreakyEffects" Version="0.1.1-pre" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
#if ANDROID
#endif
#if IOS
using Maui.FreakyControls.Platforms.iOS;
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
using NativeColor = UIKit.UIColor;
using NativeImage = UIKit.UIImage;
#endif

namespace Maui.FreakyControls.Extensions
namespace Maui.FreakyControls.Extensions
{
public class AssemblyNotFoundException : Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ namespace Maui.FreakyControls.Extensions;

public static class Extensions
{
public static bool IsAndroid => DeviceInfo.Current.Platform == DevicePlatform.Android;

public static bool IsiOS => DeviceInfo.Current.Platform == DevicePlatform.iOS;

public static void ExecuteCommandIfAvailable(this ICommand command, object parameter = null)
{
if (command?.CanExecute(parameter) == true)
Expand Down Expand Up @@ -61,7 +65,6 @@ private static void AddHandlers(this IMauiHandlersCollection handlers)
handlers.AddHandler(typeof(FreakyPicker), typeof(FreakyPickerHandler));
handlers.AddHandler(typeof(FreakyImage), typeof(FreakyImageHandler));
handlers.AddHandler(typeof(FreakySignatureCanvasView), typeof(FreakySignatureCanvasViewHandler));
handlers.AddHandler(typeof(FreakySwitch), typeof(FreakySwitchHandler));
handlers.AddHandler(typeof(FreakyAutoCompleteView), typeof(FreakyAutoCompleteViewHandler));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,5 +409,14 @@ private async void Button_Tapped(object sender, TappedEventArgs e)
Command?.ExecuteCommandIfAvailable(CommandParameter);
}

protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
base.OnPropertyChanged(propertyName);
if (propertyName == nameof(IsEnabled))
{
ChangeVisualState();
}
}

#endregion Methods
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,10 @@ private async Task PostAnimateAsync()
private void Handle_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
{
e?.Surface?.Canvas?.Clear();
DrawOutline(e);
if (IsChecked)
DrawCheckFilled(e);
else
DrawOutline(e);
}

private void DrawCheckFilled(SKPaintSurfaceEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,43 @@ public class FreakyPicker : Picker, IDrawableImageView
public static readonly BindableProperty ImageSourceProperty = BindableProperty.Create(
nameof(Image),
typeof(ImageSource),
typeof(FreakyDatePicker),
typeof(FreakyPicker),
default(ImageSource));

public static readonly BindableProperty ImageHeightProperty = BindableProperty.Create(
nameof(ImageHeight),
typeof(int),
typeof(FreakyDatePicker),
typeof(FreakyPicker),
25);

public static readonly BindableProperty ImageWidthProperty = BindableProperty.Create(
nameof(ImageWidth),
typeof(int),
typeof(FreakyDatePicker),
typeof(FreakyPicker),
25);

public static readonly BindableProperty ImageAlignmentProperty = BindableProperty.Create(
nameof(ImageAlignment),
typeof(ImageAlignment),
typeof(FreakyDatePicker),
typeof(FreakyPicker),
ImageAlignment.Right);

public static readonly BindableProperty ImagePaddingProperty = BindableProperty.Create(
nameof(ImagePadding),
typeof(int),
typeof(FreakyDatePicker),
typeof(FreakyPicker),
5);

public static readonly BindableProperty ImageCommandProperty = BindableProperty.Create(
nameof(ImagePadding),
typeof(ICommand),
typeof(FreakyDatePicker),
typeof(FreakyPicker),
default(ICommand));

public static readonly BindableProperty ImageCommandParameterProperty = BindableProperty.Create(
nameof(ImageCommandParameter),
typeof(object),
typeof(FreakyDatePicker),
typeof(FreakyPicker),
default(object));

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ private void Radiobutton_Tapped(object sender, EventArgs e)
private void Handle_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
{
e?.Surface?.Canvas?.Clear();
DrawOutline(e);
if (IsChecked)
DrawCheckFilled(e);
else
DrawOutline(e);
}

/// <summary>
Expand Down
Loading

0 comments on commit 0de0401

Please sign in to comment.