Skip to content

Commit 6b804c0

Browse files
committed
Added aggregated data reading and writing operation dots
1 parent 09744ad commit 6b804c0

8 files changed

Lines changed: 102 additions & 35 deletions

File tree

src/Platforms/Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ItemGroup>
33
<PackageVersion Include="AathifMahir.Maui.MauiIcons.Cupertino" Version="6.0.0" />
44
<PackageVersion Include="AathifMahir.Maui.MauiIcons.Material" Version="6.0.0" />
5-
<PackageVersion Include="AcrylicView.Maui" Version="3.0.0" />
5+
<PackageVersion Include="AcrylicView.Maui" Version="3.0.1" />
66
<PackageVersion Include="CommunityToolkit.Maui" Version="14.0.0" />
77
<PackageVersion Include="CommunityToolkit.WinUI.Animations" Version="8.2.251219" />
88
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Segmented" Version="8.2.251219" />
@@ -45,7 +45,7 @@
4545
<PackageVersion Include="VideoLAN.LibVLC.Android" Version="3.6.5" />
4646
<PackageVersion Include="VideoLAN.LibVLC.iOS" Version="3.6.1" />
4747
<PackageVersion Include="WinUI.TableView" Version="1.4.0" />
48-
<PackageVersion Include="Xamarin.AndroidX.DocumentFile" Version="1.1.0.1" />
48+
<PackageVersion Include="Xamarin.AndroidX.DocumentFile" Version="1.1.0.3" />
4949
<PackageVersion Include="Yubico.YubiKey" Version="1.15.1" />
5050
</ItemGroup>
51-
</Project>
51+
</Project>

src/Platforms/SecureFolderFS.Maui/UserControls/Widgets/AggregatedDataWidget.xaml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,13 @@
2424
<Border.StrokeShape>
2525
<RoundRectangle CornerRadius="12" />
2626
</Border.StrokeShape>
27-
<Grid RowSpacing="0">
28-
<Grid.RowDefinitions>
29-
<RowDefinition Height="4" />
30-
<RowDefinition />
31-
</Grid.RowDefinitions>
27+
<Grid Padding="12" ColumnSpacing="8">
28+
<Grid.ColumnDefinitions>
29+
<ColumnDefinition />
30+
<ColumnDefinition Width="Auto" />
31+
</Grid.ColumnDefinitions>
3232

33-
<VerticalStackLayout
34-
Grid.Row="1"
35-
Padding="12,10,12,12"
36-
Spacing="2">
33+
<VerticalStackLayout Grid.Column="0" Spacing="2">
3734
<Label
3835
FontSize="12"
3936
Opacity="0.6"
@@ -43,6 +40,14 @@
4340
FontSize="22"
4441
Text="{Binding TotalRead, Mode=OneWay}" />
4542
</VerticalStackLayout>
43+
44+
<Ellipse
45+
x:Name="ReadEllipsis"
46+
Grid.Column="1"
47+
Background="Orange"
48+
HeightRequest="8"
49+
Opacity="0"
50+
WidthRequest="8" />
4651
</Grid>
4752
</Border>
4853

@@ -55,16 +60,13 @@
5560
<Border.StrokeShape>
5661
<RoundRectangle CornerRadius="12" />
5762
</Border.StrokeShape>
58-
<Grid RowSpacing="0">
59-
<Grid.RowDefinitions>
60-
<RowDefinition Height="4" />
61-
<RowDefinition />
62-
</Grid.RowDefinitions>
63+
<Grid Padding="12" ColumnSpacing="8">
64+
<Grid.ColumnDefinitions>
65+
<ColumnDefinition />
66+
<ColumnDefinition Width="Auto" />
67+
</Grid.ColumnDefinitions>
6368

64-
<VerticalStackLayout
65-
Grid.Row="1"
66-
Padding="12,10,12,12"
67-
Spacing="2">
69+
<VerticalStackLayout Grid.Column="0" Spacing="2">
6870
<Label
6971
FontSize="12"
7072
Opacity="0.6"
@@ -74,6 +76,14 @@
7476
FontSize="22"
7577
Text="{Binding TotalWrite, Mode=OneWay}" />
7678
</VerticalStackLayout>
79+
80+
<Ellipse
81+
x:Name="WriteEllipsis"
82+
Grid.Column="1"
83+
Background="Orange"
84+
HeightRequest="8"
85+
Opacity="0"
86+
WidthRequest="8" />
7787
</Grid>
7888
</Border>
7989

src/Platforms/SecureFolderFS.Maui/UserControls/Widgets/AggregatedDataWidget.xaml.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,36 @@ public string? TotalWrite
2222
}
2323
public static readonly BindableProperty TotalWriteProperty =
2424
BindableProperty.Create(nameof(TotalWrite), typeof(string), typeof(AggregatedDataWidget));
25+
26+
public bool IsReading
27+
{
28+
get => (bool)GetValue(IsReadingProperty);
29+
set => SetValue(IsReadingProperty, value);
30+
}
31+
public static readonly BindableProperty IsReadingProperty =
32+
BindableProperty.Create(nameof(IsReading), typeof(bool), typeof(AggregatedDataWidget), false,
33+
propertyChanged: static (bindable, _, newValue) =>
34+
{
35+
if (bindable is not AggregatedDataWidget widget || newValue is not bool bValue)
36+
return;
37+
38+
widget.ReadEllipsis.FadeToAsync(bValue ? 1d : 0d);
39+
});
40+
41+
public bool IsWriting
42+
{
43+
get => (bool)GetValue(IsWritingProperty);
44+
set => SetValue(IsWritingProperty, value);
45+
}
46+
public static readonly BindableProperty IsWritingProperty =
47+
BindableProperty.Create(nameof(IsWriting), typeof(bool), typeof(AggregatedDataWidget), false,
48+
propertyChanged: static (bindable, _, newValue) =>
49+
{
50+
if (bindable is not AggregatedDataWidget widget || newValue is not bool bValue)
51+
return;
52+
53+
widget.WriteEllipsis.FadeToAsync(bValue ? 1d : 0d);
54+
});
2555
}
2656
}
2757

src/Platforms/SecureFolderFS.Maui/Views/Vault/OverviewPage.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727

2828
<!-- Aggregated Data Statistics Widget -->
2929
<DataTemplate x:Key="AggregatedDataWidgetTemplate" x:DataType="vm2:AggregatedDataWidgetViewModel">
30-
<ucw:AggregatedDataWidget TotalRead="{Binding TotalRead, Mode=OneWay}" TotalWrite="{Binding TotalWrite, Mode=OneWay}" />
30+
<ucw:AggregatedDataWidget
31+
IsReading="{Binding IsReading, Mode=OneWay}"
32+
IsWriting="{Binding IsWriting, Mode=OneWay}"
33+
TotalRead="{Binding TotalRead, Mode=OneWay}"
34+
TotalWrite="{Binding TotalWrite, Mode=OneWay}" />
3135
</DataTemplate>
3236
</ContentPage.Resources>
3337

src/Sdk/SecureFolderFS.Sdk/Constants.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ public static class Widgets
1616

1717
public static class Graphs
1818
{
19-
public const int MAX_GRAPH_POINTS = 30;
20-
public const int GRAPH_UPDATE_INTERVAL_MS = 200; // 0.2s
21-
public const int GRAPH_REFRESH_RATE = 1000 / GRAPH_UPDATE_INTERVAL_MS;
19+
public const int MAX_POINTS = 30;
20+
public const int UPDATE_INTERVAL_MS = 200;
21+
public const int REFRESH_RATE = 1000 / UPDATE_INTERVAL_MS;
22+
}
23+
24+
public static class AggregatedData
25+
{
26+
public const int UPDATE_INTERVAL_MS = 400;
27+
public const int REFRESH_RATE = 4;
2228
}
2329

2430
public static class Health

src/Sdk/SecureFolderFS.Sdk/ViewModels/Controls/Widgets/Data/AggregatedDataWidgetViewModel.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ public sealed partial class AggregatedDataWidgetViewModel : BaseWidgetViewModel
2121
private ulong _pendingBytesWritten;
2222
private ByteSize _bytesRead;
2323
private ByteSize _bytesWritten;
24+
private int _updateTicks;
2425

2526
[ObservableProperty] private string? _TotalRead;
2627
[ObservableProperty] private string? _TotalWrite;
28+
[ObservableProperty] private bool _IsReading;
29+
[ObservableProperty] private bool _IsWriting;
2730

2831
public AggregatedDataWidgetViewModel(UnlockedVaultViewModel unlockedVaultViewModel, IWidgetModel widgetModel)
2932
: base(widgetModel)
3033
{
3134
_fileSystemStatistics = unlockedVaultViewModel.StorageRoot.Options.FileSystemStatistics;
32-
_periodicTimer = new(TimeSpan.FromMilliseconds(Constants.Widgets.Graphs.GRAPH_UPDATE_INTERVAL_MS));
35+
_periodicTimer = new(TimeSpan.FromMilliseconds(Constants.Widgets.AggregatedData.UPDATE_INTERVAL_MS));
3336
Title = "AggregatedDataWidget".ToLocalized();
3437
}
3538

@@ -46,14 +49,20 @@ public override Task InitAsync(CancellationToken cancellationToken = default)
4649
{
4750
_bytesReadSubscription = subscriber.SubscribeToBytesRead(new Progress<long>(x =>
4851
{
49-
if (x > 0)
50-
_pendingBytesRead += (ulong)x;
52+
if (x <= 0L)
53+
return;
54+
55+
IsReading = true;
56+
_pendingBytesRead += (ulong)x;
5157
}));
5258

5359
_bytesWrittenSubscription = subscriber.SubscribeToBytesWritten(new Progress<long>(x =>
5460
{
55-
if (x > 0)
56-
_pendingBytesWritten += (ulong)x;
61+
if (x <= 0L)
62+
return;
63+
64+
IsWriting = true;
65+
_pendingBytesWritten += (ulong)x;
5766
}));
5867
}
5968

@@ -80,6 +89,14 @@ private async Task InitializeBlockingTimer(CancellationToken cancellationToken)
8089
TotalWrite = _bytesWritten.ToString().Replace(" ", string.Empty);
8190
_pendingBytesWritten = 0UL;
8291
}
92+
93+
_updateTicks++;
94+
if (_updateTicks >= Constants.Widgets.AggregatedData.REFRESH_RATE)
95+
{
96+
_updateTicks = 0;
97+
IsReading = false;
98+
IsWriting = false;
99+
}
83100
}
84101
}
85102

src/Sdk/SecureFolderFS.Sdk/ViewModels/Controls/Widgets/Data/GraphControlViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void Report(double value)
2929
/// <inheritdoc/>
3030
public Task InitAsync(CancellationToken cancellationToken = default)
3131
{
32-
for (var i = 0; i < Constants.Widgets.Graphs.MAX_GRAPH_POINTS; i++)
32+
for (var i = 0; i < Constants.Widgets.Graphs.MAX_POINTS; i++)
3333
Data.Add(0d);
3434

3535
return Task.CompletedTask;

src/Sdk/SecureFolderFS.Sdk/ViewModels/Controls/Widgets/Data/GraphsWidgetViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public GraphsWidgetViewModel(UnlockedVaultViewModel unlockedVaultViewModel, IWid
3939
WriteGraphViewModel = new();
4040
_fileSystemStatistics = unlockedVaultViewModel.StorageRoot.Options.FileSystemStatistics;
4141

42-
_periodicTimer = new(TimeSpan.FromMilliseconds(Constants.Widgets.Graphs.GRAPH_UPDATE_INTERVAL_MS));
42+
_periodicTimer = new(TimeSpan.FromMilliseconds(Constants.Widgets.Graphs.UPDATE_INTERVAL_MS));
4343
_readRates = [ 0 ];
4444
_writeRates = [ 0 ];
4545
}
@@ -68,8 +68,8 @@ private async Task InitializeBlockingTimer(CancellationToken cancellationToken)
6868
if (!IsActive)
6969
continue;
7070

71-
_readRates.AddWithMaxCapacity(_currentReadAmount, Constants.Widgets.Graphs.GRAPH_REFRESH_RATE);
72-
_writeRates.AddWithMaxCapacity(_currentWriteAmount, Constants.Widgets.Graphs.GRAPH_REFRESH_RATE);
71+
_readRates.AddWithMaxCapacity(_currentReadAmount, Constants.Widgets.Graphs.REFRESH_RATE);
72+
_writeRates.AddWithMaxCapacity(_currentWriteAmount, Constants.Widgets.Graphs.REFRESH_RATE);
7373

7474
CalculateStatistics();
7575
}
@@ -93,7 +93,7 @@ private void CalculateStatistics()
9393
_currentWriteAmount = 0;
9494

9595
_updateTimeCount++;
96-
if (_updateTimeCount == Constants.Widgets.Graphs.GRAPH_REFRESH_RATE)
96+
if (_updateTimeCount == Constants.Widgets.Graphs.REFRESH_RATE)
9797
{
9898
_updateTimeCount = 0;
9999

0 commit comments

Comments
 (0)