Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avatars are now bigger and currently logged in steam account now gets… #61

Merged
merged 1 commit into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions SteamAccountManager.AvaloniaUI/Mappers/AccountMapper.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using SteamAccountManager.AvaloniaUI.Common;
using System;
using System.Text;
using System.Threading.Tasks;
using SteamAccountManager.AvaloniaUI.Common;
using SteamAccountManager.AvaloniaUI.Common.Utils;
using SteamAccountManager.AvaloniaUI.Models;
using SteamAccountManager.AvaloniaUI.Services;
using System;
using System.Text;
using System.Threading.Tasks;
using Account = SteamAccountManager.AvaloniaUI.Models.Account;

namespace SteamAccountManager.AvaloniaUI.Mappers
{
Expand Down Expand Up @@ -34,6 +33,7 @@ private string GetTimePassedFormatted(long minutesPassed)
stringBuilder.Append($"{minutesPassed} minutes");
break;
}

stringBuilder.Append(" ago");

return stringBuilder.ToString();
Expand All @@ -46,7 +46,7 @@ public async Task<Account> FromSteamAccount(Domain.Steam.Model.Account steamAcco
var avatar = await _avatarService.GetAvatarAsync(steamAccount.Id, steamAccount.AvatarUrl);
var rank = new Rank
{
Level = steamAccount.Level
Level = steamAccount.Level,
};

return new Account
Expand All @@ -60,8 +60,9 @@ public async Task<Account> FromSteamAccount(Domain.Steam.Model.Account steamAcco
IsVacBanned = steamAccount.IsVacBanned,
IsCommunityBanned = steamAccount.IsCommunityBanned,
LastLogin = timePassedSinceLastLogin,
Rank = rank
Rank = rank,
IsLoggedIn = steamAccount.IsLoggedIn,
};
}
}
}
}
1 change: 1 addition & 0 deletions SteamAccountManager.AvaloniaUI/Models/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class Account
public bool IsVacBanned { get; set; }
public bool IsCommunityBanned { get; set; }
public string LastLogin { get; set; } = string.Empty;
public bool IsLoggedIn { get; set; }

public Rank Rank { get; set; } = new()
{
Expand Down
12 changes: 12 additions & 0 deletions SteamAccountManager.AvaloniaUI/SteamAccountSwitcherStyles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,16 @@
<Style Selector="TextBlock.Title">
<Setter Property="FontSize" Value="16" />
</Style>

<Style Selector="Border.Active">
<Setter Property="BorderThickness" Value="2" />
<Setter Property="BorderBrush" Value="#23a559" />
<Setter Property="CornerRadius" Value="10" />
<Setter Property="Padding" Value="2" />
</Style>

<Style Selector="Border.Rounded">
<Setter Property="CornerRadius" Value="10" />
<Setter Property="ClipToBounds" Value="True" />
</Style>
</Styles>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class AccountSwitcherViewModel : RoutableViewModel
public ICommand RefreshAccountsCommand { get; }
public ICommand ShowInfoCommand { get; }
public ICommand AddAccountCommand { get; }
public Account? SelectedAccount { get; set; }
public VisibilityConfig Config { get; private set; } = new();

private bool _isLoading;
Expand Down Expand Up @@ -161,7 +160,6 @@ private async void SendNotification(Account account)
public async void OnAccountSelected(Account selectedAccount)
{
await _switchAccountUseCase.Execute(selectedAccount.Name);
SelectedAccount = selectedAccount;
SendNotification(selectedAccount);
}

Expand Down
24 changes: 16 additions & 8 deletions SteamAccountManager.AvaloniaUI/Views/AccountSwitcherView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</UniformGrid>
</Grid>

<!-- Account Selection -->
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
Expand Down Expand Up @@ -62,14 +63,22 @@
IsVisible="{Binding Path=DataContext.Config.ShowAvatar,
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
Margin="0,0,12,0">
<Button.Styles>
<Style Selector="Border">
<Setter Property="CornerRadius" Value="10" />
</Style>
</Button.Styles>
<Button.Template>
<ControlTemplate>
<Image Source="{Binding ProfilePicture}" Width="40" Height="40" />
<Grid Width="48" Height="48">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<Border Classes.Active="{Binding IsLoggedIn}">
<Border Classes="Rounded">
<Image Source="{Binding ProfilePicture}" />
</Border>
</Border>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
Expand All @@ -79,8 +88,7 @@
<Border VerticalAlignment="Center" Margin="0,0,12,0"
IsVisible="{Binding Path=DataContext.Config.ShowBanStatus,
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}">
<TextBlock IsVisible="{Binding IsVacBanned}" Text="🛡️"
FontSize="28" />
<TextBlock IsVisible="{Binding IsVacBanned}" Text="🛡️" FontSize="28" />
</Border>

<StackPanel Orientation="Vertical" VerticalAlignment="Center" Margin="0,0,12,0">
Expand Down
3 changes: 2 additions & 1 deletion SteamAccountManager.Domain/Steam/Model/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class Account
public bool IsLoginValid { get; set; }
public DateTime LastLogin { get; set; }
public int Level { get; set; }
public bool IsLoggedIn { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class GetAccountsWithDetailsUseCase : IGetAccountsWithDetailsUseCase
private readonly ISteamProfileService _steamProfileService;
private readonly ILogger _logger;

public GetAccountsWithDetailsUseCase(ISteamRepository steamRepository, ISteamProfileService steamProfileService, ILogger logger)
public GetAccountsWithDetailsUseCase(ISteamRepository steamRepository, ISteamProfileService steamProfileService,
ILogger logger)
{
_steamRepository = steamRepository;
_steamProfileService = steamProfileService;
Expand All @@ -22,6 +23,7 @@ public async Task<List<Account>> Execute()
{
try
{
var currentlySetAutoLoginUserId = (await _steamRepository.GetCurrentAutoLoginUser()).SteamId;
var steamLoginUsers = await _steamRepository.GetSteamLoginHistoryUsers();
var steamIds = steamLoginUsers.Select(user => user.SteamId);
var steamProfiles = await _steamProfileService.GetProfileDetails(steamIds.ToArray());
Expand All @@ -30,14 +32,14 @@ public async Task<List<Account>> Execute()
{
var steamProfile = steamProfiles.FirstOrDefault(
profile => profile.Id == steamLoginUser.SteamId,
new Profile()
new Profile
{
Username = steamLoginUser.Username,
Level = -1
Level = -1,
}
);

return new Account()
return new Account
{
Id = steamLoginUser.SteamId,
Name = steamLoginUser.AccountName,
Expand All @@ -48,7 +50,8 @@ public async Task<List<Account>> Execute()
IsCommunityBanned = steamProfile.IsCommunityBanned,
LastLogin = steamLoginUser.LastLogin,
IsLoginValid = steamLoginUser.IsLoginTokenValid,
Level = steamProfile.Level
Level = steamProfile.Level,
IsLoggedIn = steamLoginUser.SteamId == currentlySetAutoLoginUserId,
};
});

Expand All @@ -62,4 +65,4 @@ public async Task<List<Account>> Execute()
return new List<Account>();
}
}
}
}