Skip to content

Commit

Permalink
Merge pull request #15 from TheEightBot/feature/updates-and-cleanup
Browse files Browse the repository at this point in the history
Add NPicker and update package versions
  • Loading branch information
michaelstonis authored Jan 22, 2025
2 parents a7f5bd5 + e00240d commit 7c91d47
Show file tree
Hide file tree
Showing 22 changed files with 125 additions and 83 deletions.
5 changes: 3 additions & 2 deletions AuroraControls.TestApp/AuroraControls.TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@
<ProjectReference Include="..\AuroraControlsMaui\AuroraControls.Maui.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NPicker" Version="2.0.5" />
<PackageReference Include="ReactiveUI.Maui" Version="20.1.63" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="4.1.0" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.3" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.90" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.90" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.100" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.100" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions AuroraControls.TestApp/ImageProcessing.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public ImageProcessing()
this._imageProcessing.AddRange([_blur, _circular, _grayscale, _invert, _scale, _sepia]);
}

private void Handle_ValueChanged(object sender, ValueChangedEventArgs e)
private void Handle_ValueChanged(object? sender, ValueChangedEventArgs e)
{
_blur.BlurAmount = e.NewValue;
}

private void Handle_Clicked(object sender, System.EventArgs e)
private void Handle_Clicked(object? sender, System.EventArgs e)
{
if (_index > _imageProcessing.Count - 1)
{
Expand Down
8 changes: 8 additions & 0 deletions AuroraControls.TestApp/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ public MainPage(ILogger<TestRxViewModel> logger)
BorderColor = Colors.Chocolate,
BackgroundColor = Colors.Aquamarine,
},
new StyledInputLayout
{
Content =
new NPicker.DatePicker
{
Placeholder = "Nullable NDate Picker",
},
},
new Grid
{
ColumnDefinitions = Columns.Define(Auto, Star, Auto),
Expand Down
25 changes: 24 additions & 1 deletion AuroraControls.TestApp/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CommunityToolkit.Maui;
using CommunityToolkit.Maui.Markup;
using NPicker;
using SkiaSharp;

namespace AuroraControls.TestApp;
Expand All @@ -13,6 +14,28 @@ public static MauiApp CreateMauiApp()
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.UseMauiCommunityToolkitMarkup()
.UseNPicker()
.ConfigureMauiHandlers(
handlers =>
{
StyledInputLayout.StyledInputLayoutContentRegistrations
.Add(
typeof(NPicker.DatePicker),
new StyledContentTypeRegistration
{
HasValue =
view =>
{
if (view is NPicker.DatePicker dp)
{
return dp.Date.HasValue;
}

return false;
},
ValueChangeProperty = nameof(NPicker.DatePicker.Date),
});
})
.ConfigureFonts(
fonts =>
{
Expand All @@ -31,4 +54,4 @@ public static MauiApp CreateMauiApp()

return builder.Build();
}
}
}
14 changes: 7 additions & 7 deletions AuroraControlsMaui/AuroraControls.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<IsTrimmable>true</IsTrimmable>
<Nullable>enable</Nullable>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
Expand All @@ -16,12 +16,12 @@
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.8" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.8" />
<PackageReference Include="SkiaSharp.HarfBuzz" Version="2.88.8" />
<PackageReference Include="Svg.Skia" Version="2.0.0.1" />
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.9" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.9" />
<PackageReference Include="SkiaSharp.HarfBuzz" Version="2.88.9" />
<PackageReference Include="Svg.Skia" Version="2.0.0.4" />
<PackageReference Include="Topten.RichTextKit" Version="0.4.167" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.90" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.90" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.100" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.100" />
</ItemGroup>
</Project>
9 changes: 5 additions & 4 deletions AuroraControlsMaui/AuroraViewBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ protected override void OnPaintSurface(SKPaintSurfaceEventArgs e)
PaintSurfaceInternal(e.Surface, e.Info);
}

protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
protected override void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
base.OnPropertyChanged(propertyName);

if (propertyName.Equals(HeightProperty.PropertyName) ||
propertyName.Equals(WidthProperty.PropertyName) ||
propertyName.Equals(MarginProperty.PropertyName))
if (propertyName != null &&
(propertyName.Equals(HeightProperty.PropertyName) ||
propertyName.Equals(WidthProperty.PropertyName) ||
propertyName.Equals(MarginProperty.PropertyName)))
{
this.InvalidateSurface();
}
Expand Down
16 changes: 0 additions & 16 deletions AuroraControlsMaui/CupertinoTextToggleSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,22 +494,6 @@ protected override Size MeasureOverride(double widthConstraint, double heightCon
return size;
}

public override SizeRequest Measure(double widthConstraint, double heightConstraint, MeasureFlags flags = MeasureFlags.None)
{
return base.Measure(widthConstraint, heightConstraint, flags);
}

protected override Size ArrangeOverride(Rect bounds)
{
return base.ArrangeOverride(bounds);
}

protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
{
var sizeRequest = base.OnMeasure(widthConstraint, heightConstraint);
return sizeRequest;
}

/// <summary>
/// SKCanvas method that fires on touch.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions AuroraControlsMaui/Effects/ImageProcessingEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected override void OnDetached()
}
}

private async void ImageProcessingEffects_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs args)
private async void ImageProcessingEffects_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs args)
{
var view = Control as ImageView;

Expand Down Expand Up @@ -227,7 +227,7 @@ protected override void OnDetached()
}
}

private async void ImageProcessingEffects_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs args)
private async void ImageProcessingEffects_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs args)
{
var view = Control as UIImageView;

Expand Down
8 changes: 4 additions & 4 deletions AuroraControlsMaui/Extensions/ImageSourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ public static UriImageSource AsAsyncUriImageSource(this Task<UriImageSource> ima
return imageSource;
}

public static Button SetSvgIcon(this Button imageElement, string svgName, double squareSize = 22d, Color colorOverride = default(Color))
public static Button SetSvgIcon(this Button imageElement, string svgName, double squareSize = 24d, Color? colorOverride = default(Color))
{
return IconCache
.FileImageSourceFromSvg(svgName, squareSize, colorOverride: colorOverride)
.AsAsyncSourceFor(imageElement);
}

public static ImageButton SetSvgIcon(this ImageButton imageButton, string svgName, double squareSize = 22d, Color colorOverride = default(Color))
public static ImageButton SetSvgIcon(this ImageButton imageButton, string svgName, double squareSize = 24d, Color colorOverride = default(Color))
{
IconCache
.FileImageSourceFromSvg(svgName, squareSize, colorOverride: colorOverride)
Expand All @@ -281,14 +281,14 @@ public static UriImageSource AsAsyncUriImageSource(this Task<UriImageSource> ima
return imageButton;
}

public static ToolbarItem SetSvgIcon(this ToolbarItem toolbarItem, string svgName, double squareSize = 22d, Color colorOverride = default(Color))
public static ToolbarItem SetSvgIcon(this ToolbarItem toolbarItem, string svgName, double squareSize = 24d, Color colorOverride = default(Color))
{
return IconCache
.FileImageSourceFromSvg(svgName, squareSize, colorOverride: colorOverride)
.AsAsyncSourceFor(toolbarItem);
}

public static Image SetSvgIcon(this Image image, string svgName, double squareSize = 22d, Color colorOverride = default(Color))
public static Image SetSvgIcon(this Image image, string svgName, double squareSize = 24d, Color colorOverride = default(Color))
{
return IconCache
.FileImageSourceFromSvg(svgName, squareSize, colorOverride: colorOverride)
Expand Down
5 changes: 4 additions & 1 deletion AuroraControlsMaui/Extensions/SKCanvasExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace AuroraControls;
using System;
using System.Collections.Generic;

namespace AuroraControls;

internal static class SKCanvasExtensions
{
Expand Down
2 changes: 1 addition & 1 deletion AuroraControlsMaui/Gauges/CircularFillGauge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public CircularFillGauge()
/// The surface is automatically invalidated/redrawn whenever <c>HeightProperty</c>, <c>WidthProperty</c> or <c>MarginProperty</c> gets updated.
/// </summary>
/// <param name="propertyName">The name of the bound property that changed.</param>
protected override void OnPropertyChanged(string propertyName = null)
protected override void OnPropertyChanged(string? propertyName = null)
{
base.OnPropertyChanged(propertyName);

Expand Down
5 changes: 4 additions & 1 deletion AuroraControlsMaui/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
global using System.Windows.Input;
global using System;
global using System.Threading.Tasks;
global using System.Windows.Input;
global using Microsoft.Maui;
global using Microsoft.Maui.Controls;
global using Microsoft.Maui.Graphics;
global using SkiaSharp;
global using SkiaSharp.Views.Maui;
global using SkiaSharp.Views.Maui.Controls;
2 changes: 1 addition & 1 deletion AuroraControlsMaui/GradientColorView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected override void Attached()
base.Attached();
}

protected override void OnPropertyChanged(string propertyName = null)
protected override void OnPropertyChanged(string? propertyName = null)
{
base.OnPropertyChanged(propertyName);

Expand Down
8 changes: 7 additions & 1 deletion AuroraControlsMaui/IconCacheBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,13 @@ private async Task RenderSvgAsync(SKSvg skSvg, string key, Size size, Color? col
{
var minSize = (float)Math.Min(size.Width, size.Height);

scaledCanvas = (float)Math.Round((minSize / Math.Max(skSvg.Picture.CullRect.Width, skSvg.Picture.CullRect.Height)) * platformScalingFactor, 0, MidpointRounding.ToEven);
scaledCanvas = (minSize / Math.Max(skSvg.Picture.CullRect.Width, skSvg.Picture.CullRect.Height)) *
platformScalingFactor;

if (scaledCanvas > 1.0f)
{
scaledCanvas = (float)Math.Ceiling(scaledCanvas);
}

resize = new SKRect(0, 0, skSvg.Picture.CullRect.Width * scaledCanvas, skSvg.Picture.CullRect.Height * scaledCanvas);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ IEnumerator IEnumerable.GetEnumerator()
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e"><c>PropertyChangedEventArgs</c> provides the <see cref="T:PropertyChangedEventArgs.PropertyName"/> property to get the name of the property that changed.</param>
private void HandlePropertyChangedEventHandler(object sender, System.ComponentModel.PropertyChangedEventArgs e)
private void HandlePropertyChangedEventHandler(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
ClearValue(Effects.ImageProcessingEffect.ProcessorChangedProperty);
SetValue(Effects.ImageProcessingEffect.ProcessorChangedProperty, sender);
Expand Down
52 changes: 29 additions & 23 deletions AuroraControlsMaui/Loading/MaterialCircular.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace AuroraControls.Loading;
namespace AuroraControls.Loading;

/// <summary>
/// Material circular loading animation.
Expand All @@ -9,10 +7,10 @@ namespace AuroraControls.Loading;
public class MaterialCircular : SceneViewBase
#pragma warning restore CA1001 // Types that own disposable fields should be disposable
{
private SKPaint _progressPaint;
private SKPath _progressPath;
private SKPaint _progressBackgroundPaint;
private SKPath _backgroundProgressPath;
private SKPaint? _progressPaint;
private SKPath? _progressPath;
private SKPaint? _progressBackgroundPaint;
private SKPath? _backgroundProgressPath;

/// <summary>
/// The foreground color property. Specifies the foreground color.
Expand All @@ -35,8 +33,8 @@ public class MaterialCircular : SceneViewBase
/// <value>Takes a Xamarin.Forms.Color. Default value is default(Xamarin.Forms.Color).</value>
public Color ForegroundLoadingColor
{
get { return (Color)GetValue(ForegroundLoadingColorProperty); }
set { SetValue(ForegroundLoadingColorProperty, value); }
get => (Color)GetValue(ForegroundLoadingColorProperty);
set => SetValue(ForegroundLoadingColorProperty, value);
}

/// <summary>
Expand All @@ -60,8 +58,8 @@ public Color ForegroundLoadingColor
/// <value>Takes a Xamarin.Forms.Color. Default value is default(Xamarin.Forms.Color).</value>
public Color BackgroundLoadingColor
{
get { return (Color)GetValue(BackgroundLoadingColorProperty); }
set { SetValue(BackgroundLoadingColorProperty, value); }
get => (Color)GetValue(BackgroundLoadingColorProperty);
set => SetValue(BackgroundLoadingColorProperty, value);
}

/// <summary>
Expand Down Expand Up @@ -92,8 +90,8 @@ public Color BackgroundLoadingColor
/// <value>Takes an EndCapType. Default is EndCapType.Rounded.</value>
public EndCapType EndCapType
{
get { return (EndCapType)GetValue(EndCapTypeProperty); }
set { SetValue(EndCapTypeProperty, value); }
get => (EndCapType)GetValue(EndCapTypeProperty);
set => SetValue(EndCapTypeProperty, value);
}

/// <summary>
Expand All @@ -118,8 +116,8 @@ public EndCapType EndCapType
/// <value>Takes a double. Default value is 12d.</value>
public double ProgressThickness
{
get { return (double)GetValue(ProgressThicknessProperty); }
set { SetValue(ProgressThicknessProperty, value); }
get => (double)GetValue(ProgressThicknessProperty);
set => SetValue(ProgressThicknessProperty, value);
}

public MaterialCircular()
Expand All @@ -144,13 +142,13 @@ protected override void Attached()
_progressPaint.Color = ForegroundLoadingColor.ToSKColor();
_progressPaint.StrokeWidth = (float)ProgressThickness * _scale;

_progressPath = new SKPath { };
_progressPath = new SKPath();

_progressBackgroundPaint = new SKPaint { IsAntialias = true, Style = SKPaintStyle.Stroke };
_progressBackgroundPaint.Color = BackgroundLoadingColor.ToSKColor();
_progressBackgroundPaint.StrokeWidth = (float)ProgressThickness * _scale;

_backgroundProgressPath = new SKPath { };
_backgroundProgressPath = new SKPath();

base.Attached();
}
Expand Down Expand Up @@ -202,19 +200,27 @@ protected override SKImage PaintScene(SKSurface surface, SKImageInfo info, doubl
progressArcLength = 1;
}

_backgroundProgressPath.Reset();
_backgroundProgressPath.AddArc(arcRect, 0, 360);
_backgroundProgressPath?.Reset();
_backgroundProgressPath?.AddArc(arcRect, 0, 360);

_progressPath.Reset();
_progressPath.AddArc(arcRect, progressOfCircle, progressArcLength);
_progressPath?.Reset();
_progressPath?.AddArc(arcRect, progressOfCircle, progressArcLength);

using (new SKAutoCanvasRestore(canvas))
{
var matrix = SKMatrix.CreateRotationDegrees(progressOfCircle - 90f, info.Rect.MidX, info.Rect.MidY);
canvas.SetMatrix(matrix);
canvas.Clear();
canvas.DrawPath(_backgroundProgressPath, _progressBackgroundPaint);
canvas.DrawPath(_progressPath, _progressPaint);

if (this._backgroundProgressPath != null)
{
canvas.DrawPath(this._backgroundProgressPath, this._progressBackgroundPaint);
}

if (this._progressPath != null)
{
canvas.DrawPath(this._progressPath, this._progressPaint);
}
}

canvas.Flush();
Expand Down
Loading

0 comments on commit 7c91d47

Please sign in to comment.