1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-17 00:33:20 +00:00

PS-70 Added new props to custom control.

This commit is contained in:
André Bispo
2022-06-17 10:23:25 +01:00
parent 6ae7d6dd8d
commit 751fdf2db6
2 changed files with 28 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using SkiaSharp;
using SkiaSharp.Views.Forms;
using Xamarin.Essentials;
@@ -20,6 +21,12 @@ namespace Bit.App.Controls
set { SetValue(ProgressProperty, value); }
}
public float Radius { get; set; }
public float StrokeWidth { get; set; }
public Color ProgressColor { get; set; }
public Color EndingProgressColor { get; set; }
public Color BackgroundProgressColor { get; set; }
private static void OnProgressChanged(BindableObject bindable, object oldvalue, object newvalue)
{
var context = bindable as CircularProgressbarView;
@@ -29,9 +36,16 @@ namespace Bit.App.Controls
public CircularProgressbarView()
{
InitializeComponent();
var pixels = DeviceDisplay.MainDisplayInfo.Density * 15;
var circle = new Circle((float)pixels, (info) => new SKPoint((float)info.Width / 2, (float)info.Height / 2));
_progressDrawer = new ProgressDrawer(SkCanvasView, circle, () => (float)Progress, 5, SKColors.White, SKColors.Blue, SKColors.Red);
}
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
base.OnPropertyChanged(propertyName);
if(propertyName == nameof(Progress) && _progressDrawer == null)
{
var circle = new Circle(Radius * (float)DeviceDisplay.MainDisplayInfo.Density, (info) => new SKPoint((float)info.Width / 2, (float)info.Height / 2));
_progressDrawer = new ProgressDrawer(SkCanvasView, circle, () => (float)Progress, StrokeWidth * (float)DeviceDisplay.MainDisplayInfo.Density, BackgroundProgressColor.ToSKColor(), ProgressColor.ToSKColor(), EndingProgressColor.ToSKColor());
}
}
}