1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +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

@@ -61,7 +61,7 @@
Grid.Column="1"
VerticalOptions="Center"
HorizontalOptions="FillAndExpand"
Padding="0, 7">
Padding="0, 15, 15, 10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@@ -82,7 +82,12 @@
</Grid>
<controls:CircularProgressbarView
Progress="{Binding Progress}"
Progress="{Binding Progress}"
ProgressColor="{StaticResource PrimaryColor}"
EndingProgressColor="{StaticResource DangerColor}"
BackgroundProgressColor="{StaticResource BackgroundColor}"
StrokeWidth="3"
Radius="15"
Grid.Row="0"
Grid.Column="2"
HorizontalOptions="FillAndExpand"
@@ -102,9 +107,10 @@
<controls:MonoLabel
Text="{Binding TotpCodeFormatted, Mode=OneWay}"
Style="{DynamicResource textTotp}"
Margin="2,0,0,0"
Grid.Row="0"
Grid.Column="3"
StyleClass="list-title, list-title-platform"
StyleClass="text-lg"
XAlign="Center"
YAlign="Center"
HorizontalOptions="FillAndExpand"
@@ -118,8 +124,8 @@
Grid.Row="0"
Grid.Column="4"
Padding="0,0,1,0"
HorizontalOptions="FillAndExpand"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
VerticalOptions="Center"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n CopyTotp}" />
</controls:ExtendedGrid>

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());
}
}
}