-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b4d976
commit b3eb309
Showing
15 changed files
with
112 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
namespace WonderLab.Services.Account; | ||
using MinecraftLaunch.Classes.Models.Auth; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace WonderLab.Services.Accounts; | ||
|
||
public sealed class AccountService { | ||
private readonly ConfigService _configService; | ||
|
||
public ObservableCollection<Account> Accounts { get; set; } | ||
|
||
public AccountService(ConfigService configService) { | ||
_configService = configService; | ||
} | ||
|
||
public void Initialize() { | ||
Accounts = new(_configService?.Entries?.Accounts ?? []); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
WonderLab/ViewModels/Dialog/ChooseAccountTypeDialogViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
|
||
namespace WonderLab.ViewModels.Dialog; | ||
|
||
public sealed partial class ChooseAccountTypeDialogViewModel : ObservableObject { | ||
} |
42 changes: 30 additions & 12 deletions
42
WonderLab/ViewModels/Page/Setting/AccountPageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using Avalonia.Threading; | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
using DialogHostAvalonia; | ||
using MinecraftLaunch.Classes.Models.Auth; | ||
using MinecraftLaunch.Components.Authenticator; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Threading.Tasks; | ||
using WonderLab.Services.Accounts; | ||
using WonderLab.ViewModels.Dialog; | ||
|
||
namespace WonderLab.ViewModels.Page.Setting; | ||
|
||
public sealed partial class AccountPageViewModel : ObservableObject { | ||
public List<Account> Test => [ | ||
new OfflineAuthenticator("Account1").Authenticate(), | ||
new OfflineAuthenticator("Account2").Authenticate(), | ||
new OfflineAuthenticator("Account3").Authenticate(), | ||
new OfflineAuthenticator("Account4").Authenticate(), | ||
new OfflineAuthenticator("Account5").Authenticate(), | ||
new OfflineAuthenticator("Account6").Authenticate(), | ||
new OfflineAuthenticator("Account7").Authenticate(), | ||
]; | ||
private readonly AccountService _accountService; | ||
|
||
public bool HasAccount => Accounts?.Count > 0; | ||
|
||
[ObservableProperty] | ||
[NotifyPropertyChangedFor(nameof(HasAccount))] | ||
private ReadOnlyObservableCollection<Account> _accounts; | ||
|
||
public AccountPageViewModel(AccountService accountService) { | ||
_accountService = accountService; | ||
|
||
Accounts = new(_accountService.Accounts); | ||
} | ||
|
||
[RelayCommand] | ||
private Task CreateAccount() => Dispatcher.UIThread.InvokeAsync(async () => { | ||
ChooseAccountTypeDialog dialog = new() { | ||
DataContext = App.Get<ChooseAccountTypeDialogViewModel>() | ||
}; | ||
|
||
await DialogHost.Show(dialog, "PART_DialogHost"); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" | ||
x:Class="WonderLab.ChooseAccountTypeDialog"> | ||
Welcome to Avalonia! | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Avalonia.Controls; | ||
|
||
namespace WonderLab; | ||
|
||
public partial class ChooseAccountTypeDialog : UserControl { | ||
public ChooseAccountTypeDialog() => InitializeComponent(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters