Account management - Final tweaks

This commit is contained in:
RobertBeekman committed 2024-02-13 21:55:09 +01:00
1 parent a2fe5d5d08
commit 38a1318170
4 files changed
+42 -32

No files matched your search

@@ -5,6 +5,7 @@
xmlns:settings="clr-namespace:Artemis.UI.Screens.Settings"
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
xmlns:loaders="clr-namespace:AsyncImageLoader.Loaders;assembly=AsyncImageLoader.Avalonia"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="800"
x:Class="Artemis.UI.Screens.Settings.AccountTabView"
x:DataType="settings:AccountTabViewModel">
@@ -34,9 +35,9 @@
</TextBlock>
<Button HorizontalAlignment="Center" Command="{CompiledBinding Login}" Margin="0 25 0 0">Login</Button>
</StackPanel>
<ScrollViewer IsVisible="{CompiledBinding IsLoggedIn^}" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<StackPanel Margin="15" MaxWidth="1000">
<Grid RowDefinitions="*,*" ColumnDefinitions="Auto,*" VerticalAlignment="Top">
<Border Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" VerticalAlignment="Top" CornerRadius="92" Width="92" Height="92" Margin="0 0 15 0" ClipToBounds="True">
<asyncImageLoader:AdvancedImage Source="{CompiledBinding AvatarUrl}">
@@ -45,7 +46,7 @@
</asyncImageLoader:AdvancedImage.Loader>
</asyncImageLoader:AdvancedImage>
</Border>
<TextBlock Grid.Row="0" Grid.Column="1" Padding="0" VerticalAlignment="Bottom" Text="{CompiledBinding Name}" />
<TextBlock Grid.Row="0" Grid.Column="1" Padding="0" VerticalAlignment="Bottom" Text="{CompiledBinding Name}" Classes="h3 no-margin"/>
<TextBlock Classes="subtitle" Grid.Column="1" Grid.Row="1" Padding="0" VerticalAlignment="Top" Text="{CompiledBinding Email}" />
</Grid>
@@ -54,11 +55,27 @@
</TextBlock>
<Border Classes="card" VerticalAlignment="Stretch" Margin="0,0,5,0">
<StackPanel>
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto" IsVisible="{CompiledBinding CanChangePassword}">
<StackPanel Grid.Column="0" VerticalAlignment="Top">
<TextBlock>
Credentials
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Spacing="10">
<Button Width="150" Content="Change email" Command="{CompiledBinding ChangeEmailAddress}" />
<Button Width="150" Content="Change password" Command="{CompiledBinding ChangePasswordAddress}" />
</StackPanel>
</Grid>
<Border Classes="card-separator" IsVisible="{CompiledBinding CanChangePassword}"/>
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
<StackPanel Grid.Column="0" VerticalAlignment="Center">
<TextBlock>
Change avatar
</TextBlock>
<TextBlock Classes="subtitle">
Quite pointless currently, but in the future your avatar will be visible in the workshop.
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Button Width="150" Content="Choose image" Command="{CompiledBinding ChangeAvatar}" />
@@ -66,37 +83,13 @@
</Grid>
<Border Classes="card-separator" />
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
<StackPanel Grid.Column="0" VerticalAlignment="Center">
<TextBlock>
Email address
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Button Width="150" Content=" Change email" Command="{CompiledBinding ChangeEmailAddress}" />
</StackPanel>
</Grid>
<Border Classes="card-separator" />
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
<StackPanel Grid.Column="0" VerticalAlignment="Center">
<TextBlock>
Password
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Button Width="150" Content="Change password" Command="{CompiledBinding ChangePasswordAddress}" />
</StackPanel>
</Grid>
<Border Classes="card-separator" />
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
<StackPanel Grid.Column="0" VerticalAlignment="Center">
<TextBlock>
Remove account
</TextBlock>
<TextBlock Classes="subtitle">
Permanently remove your account, this cannot be undone
Permanently remove your account, this cannot be undone.
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
@@ -3,6 +3,7 @@ using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading;
using System.Threading.Tasks;
using Artemis.UI.Screens.Settings.Account;
@@ -12,6 +13,7 @@ using Artemis.UI.Shared.Services;
using Artemis.WebClient.Workshop;
using Artemis.WebClient.Workshop.Handlers.UploadHandlers;
using Artemis.WebClient.Workshop.Services;
using IdentityModel;
using PropertyChanged.SourceGenerator;
using ReactiveUI;
@@ -22,6 +24,7 @@ public partial class AccountTabViewModel : RoutableScreen
private readonly IWindowService _windowService;
private readonly IAuthenticationService _authenticationService;
private readonly IUserManagementService _userManagementService;
private ObservableAsPropertyHelper<bool>? _canChangePassword;
[Notify(Setter.Private)] private string? _name;
[Notify(Setter.Private)] private string? _email;
@@ -37,9 +40,15 @@ public partial class AccountTabViewModel : RoutableScreen
DisplayName = "Account";
IsLoggedIn = _authenticationService.IsLoggedIn;
this.WhenActivated(d =>
{
_canChangePassword = _authenticationService.GetClaim(JwtClaimTypes.AuthenticationMethod).Select(c => c?.Value == "pwd").ToProperty(this, vm => vm.CanChangePassword);
_canChangePassword.DisposeWith(d);
});
this.WhenActivated(d => _authenticationService.IsLoggedIn.Subscribe(_ => LoadCurrentUser()).DisposeWith(d));
}
public bool CanChangePassword => _canChangePassword?.Value ?? false;
public IObservable<bool> IsLoggedIn { get; }
public async Task Login()