-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from sahin-a/20-settings-tab-steam-api-key
20 settings tab steam api key
- Loading branch information
Showing
4 changed files
with
56 additions
and
28 deletions.
There are no files selected for viewing
34 changes: 24 additions & 10 deletions
34
SteamAccountManager.AvaloniaUI/ViewModels/SettingsViewModel.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,32 @@ | ||
using ReactiveUI; | ||
using SteamAccountManager.AvaloniaUI.ViewModels.Commands; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Input; | ||
using System.Windows.Input; | ||
using ReactiveUI; | ||
using SteamAccountManager.Infrastructure.Steam.Local.Storage; | ||
|
||
namespace SteamAccountManager.AvaloniaUI.ViewModels | ||
{ | ||
public class SettingsViewModel : RoutableViewModel | ||
{ | ||
public SettingsViewModel(IScreen screen) : base(screen) | ||
private readonly SteamApiKeyStorage _steamApiKeyStorage; | ||
|
||
public ICommand SaveApiKeyCommand { get; } | ||
public string WebApiKey { get; set; } | ||
|
||
public SettingsViewModel(IScreen screen, SteamApiKeyStorage apiKeyStorage) : base(screen) | ||
{ | ||
_steamApiKeyStorage = apiKeyStorage; | ||
SaveApiKeyCommand = ReactiveCommand.Create((string key) => SaveApiKey(key)); | ||
|
||
PrefillFields(); | ||
} | ||
|
||
private void PrefillFields() | ||
{ | ||
WebApiKey = _steamApiKeyStorage.Get(); | ||
} | ||
|
||
private void SaveApiKey(string key) | ||
{ | ||
_steamApiKeyStorage.Set(key); | ||
} | ||
} | ||
} | ||
} |
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