Skip to content

Commit 57c73a9

Browse files
committed
Added Accounts settings page
1 parent feaab08 commit 57c73a9

26 files changed

Lines changed: 685 additions & 35 deletions

File tree

src/Platforms/SecureFolderFS.Maui/Views/Modals/Settings/SettingsPage.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public partial class SettingsPage : BaseModalPage, IOverlayControl
3333

3434
public PrivacySettingsViewModel? PrivacyViewModel { get; private set; }
3535

36+
public AccountsSettingsViewModel? AccountsViewModel { get; private set; }
37+
3638
public AboutSettingsViewModel? AboutViewModel { get; private set; }
3739

3840
public SettingsPage(INavigation sourceNavigation)
@@ -69,12 +71,14 @@ public void SetView(IViewable viewable)
6971
GeneralViewModel = OverlayViewModel.NavigationService.Views.GetOrAdd(() => new GeneralSettingsViewModel().WithInitAsync());
7072
PreferencesViewModel = OverlayViewModel.NavigationService.Views.GetOrAdd(() => new PreferencesSettingsViewModel().WithInitAsync());
7173
PrivacyViewModel = OverlayViewModel.NavigationService.Views.GetOrAdd(() => new PrivacySettingsViewModel().WithInitAsync());
74+
AccountsViewModel = OverlayViewModel.NavigationService.Views.GetOrAdd(() => new AccountsSettingsViewModel().WithInitAsync());
7275
AboutViewModel = OverlayViewModel.NavigationService.Views.GetOrAdd(() => new AboutSettingsViewModel().WithInitAsync());
7376

7477
OnPropertyChanged(nameof(OverlayViewModel));
7578
OnPropertyChanged(nameof(GeneralViewModel));
7679
OnPropertyChanged(nameof(PreferencesViewModel));
7780
OnPropertyChanged(nameof(PrivacyViewModel));
81+
OnPropertyChanged(nameof(AccountsViewModel));
7882
OnPropertyChanged(nameof(AboutViewModel));
7983
}
8084

490 KB
Loading
Lines changed: 74 additions & 0 deletions
Loading

src/Platforms/SecureFolderFS.UI/SecureFolderFS.UI.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<ProjectReference Include="..\..\Core\SecureFolderFS.Core\SecureFolderFS.Core.csproj" />
2020
<ProjectReference Include="..\..\Sdk\SecureFolderFS.Sdk.DeviceLink\SecureFolderFS.Sdk.DeviceLink.csproj" />
2121
<ProjectReference Include="..\..\Sdk\SecureFolderFS.Sdk\SecureFolderFS.Sdk.csproj" />
22-
22+
2323
<!-- Detect App Platform SDK -->
2424
<ProjectReference Include="$(AppPlatformSdkPath)" Condition="Exists('$(AppPlatformSdkPath)')" />
2525
</ItemGroup>
@@ -30,6 +30,8 @@
3030
<None Remove="Assets\AppAssets\app_icon.svg" />
3131
<None Remove="Assets\AppAssets\app_title.png" />
3232
<None Remove="Assets\AppAssets\app_title.svg" />
33+
<None Remove="Assets\AppAssets\app_platform_icon.png" />
34+
<None Remove="Assets\AppAssets\app_platform_icon.svg" />
3335
<None Remove="Assets\AppAssets\vault_dark.svg" />
3436
<None Remove="Assets\AppAssets\vault_light.svg" />
3537
<None Remove="Assets\AppAssets\Devices\gpixel_dark.png" />
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#if APP_PLATFORM_PRESENT
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
using SecureFolderFS.Sdk.AppPlatform.Services;
7+
using SecureFolderFS.Sdk.Models;
8+
using SecureFolderFS.Sdk.Services;
9+
using SecureFolderFS.Shared;
10+
11+
namespace SecureFolderFS.UI.ServiceImplementation
12+
{
13+
/// <summary>
14+
/// <see cref="IAccountProvider"/> for App Platform device-key identities, backed by <see cref="IDeviceKeyStore"/>.
15+
/// </summary>
16+
public sealed class AppPlatformAccountProvider : IAccountProvider
17+
{
18+
private readonly IDeviceKeyStore _deviceKeyStore;
19+
20+
/// <inheritdoc/>
21+
public string ProviderId { get; } = Core.Constants.Vault.Authentication.AUTH_APP_PLATFORM;
22+
23+
public AppPlatformAccountProvider(IDeviceKeyStore deviceKeyStore)
24+
{
25+
_deviceKeyStore = deviceKeyStore;
26+
}
27+
28+
/// <inheritdoc/>
29+
public async Task<IReadOnlyList<AccountModel>> GetAccountsAsync(CancellationToken cancellationToken = default)
30+
{
31+
var mediaService = DI.Service<IMediaService>();
32+
var icon = await mediaService.GetImageFromResourceAsync("AppPlatformIcon", cancellationToken);
33+
34+
var accounts = await _deviceKeyStore.GetAccountsAsync(cancellationToken);
35+
return accounts
36+
.Select(x => new AccountModel(
37+
x.Id,
38+
x.DisplayName,
39+
x.ServerUrl,
40+
icon,
41+
ProviderId))
42+
.ToList();
43+
}
44+
45+
/// <inheritdoc/>
46+
public Task RemoveAccountAsync(string accountId, CancellationToken cancellationToken = default)
47+
{
48+
return _deviceKeyStore.ClearAsync(accountId, cancellationToken);
49+
}
50+
}
51+
}
52+
#endif

src/Platforms/SecureFolderFS.UI/Strings/en-US/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,12 @@
854854
<data name="Remove" xml:space="preserve">
855855
<value>Remove</value>
856856
</data>
857+
<data name="Accounts" xml:space="preserve">
858+
<value>Accounts</value>
859+
</data>
860+
<data name="Account" xml:space="preserve">
861+
<value>Account</value>
862+
</data>
857863
<data name="GoToVaults" xml:space="preserve">
858864
<value>Go to vault list</value>
859865
</data>

0 commit comments

Comments
 (0)