mirror of
https://github.com/bitwarden/mobile
synced 2025-12-18 09:13:15 +00:00
PS-70 Added new props to custom control.
This commit is contained in:
@@ -61,7 +61,7 @@
|
|||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
VerticalOptions="Center"
|
VerticalOptions="Center"
|
||||||
HorizontalOptions="FillAndExpand"
|
HorizontalOptions="FillAndExpand"
|
||||||
Padding="0, 7">
|
Padding="0, 15, 15, 10">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
@@ -83,6 +83,11 @@
|
|||||||
|
|
||||||
<controls:CircularProgressbarView
|
<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.Row="0"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
HorizontalOptions="FillAndExpand"
|
HorizontalOptions="FillAndExpand"
|
||||||
@@ -102,9 +107,10 @@
|
|||||||
<controls:MonoLabel
|
<controls:MonoLabel
|
||||||
Text="{Binding TotpCodeFormatted, Mode=OneWay}"
|
Text="{Binding TotpCodeFormatted, Mode=OneWay}"
|
||||||
Style="{DynamicResource textTotp}"
|
Style="{DynamicResource textTotp}"
|
||||||
|
Margin="2,0,0,0"
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="3"
|
Grid.Column="3"
|
||||||
StyleClass="list-title, list-title-platform"
|
StyleClass="text-lg"
|
||||||
XAlign="Center"
|
XAlign="Center"
|
||||||
YAlign="Center"
|
YAlign="Center"
|
||||||
HorizontalOptions="FillAndExpand"
|
HorizontalOptions="FillAndExpand"
|
||||||
@@ -118,8 +124,8 @@
|
|||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="4"
|
Grid.Column="4"
|
||||||
Padding="0,0,1,0"
|
Padding="0,0,1,0"
|
||||||
HorizontalOptions="FillAndExpand"
|
HorizontalOptions="Center"
|
||||||
VerticalOptions="CenterAndExpand"
|
VerticalOptions="Center"
|
||||||
AutomationProperties.IsInAccessibleTree="True"
|
AutomationProperties.IsInAccessibleTree="True"
|
||||||
AutomationProperties.Name="{u:I18n CopyTotp}" />
|
AutomationProperties.Name="{u:I18n CopyTotp}" />
|
||||||
</controls:ExtendedGrid>
|
</controls:ExtendedGrid>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
using SkiaSharp.Views.Forms;
|
using SkiaSharp.Views.Forms;
|
||||||
using Xamarin.Essentials;
|
using Xamarin.Essentials;
|
||||||
@@ -20,6 +21,12 @@ namespace Bit.App.Controls
|
|||||||
set { SetValue(ProgressProperty, value); }
|
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)
|
private static void OnProgressChanged(BindableObject bindable, object oldvalue, object newvalue)
|
||||||
{
|
{
|
||||||
var context = bindable as CircularProgressbarView;
|
var context = bindable as CircularProgressbarView;
|
||||||
@@ -29,9 +36,16 @@ namespace Bit.App.Controls
|
|||||||
public CircularProgressbarView()
|
public CircularProgressbarView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user