diff --git a/SteamAccountManager.AvaloniaUI/ViewModels/SettingsViewModel.cs b/SteamAccountManager.AvaloniaUI/ViewModels/SettingsViewModel.cs index 94a958d..c50de03 100644 --- a/SteamAccountManager.AvaloniaUI/ViewModels/SettingsViewModel.cs +++ b/SteamAccountManager.AvaloniaUI/ViewModels/SettingsViewModel.cs @@ -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); } } -} +} \ No newline at end of file diff --git a/SteamAccountManager.AvaloniaUI/Views/SettingsView.axaml b/SteamAccountManager.AvaloniaUI/Views/SettingsView.axaml index 6279f1e..fb5fcdd 100644 --- a/SteamAccountManager.AvaloniaUI/Views/SettingsView.axaml +++ b/SteamAccountManager.AvaloniaUI/Views/SettingsView.axaml @@ -4,6 +4,24 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SteamAccountManager.AvaloniaUI.Views.SettingsView"> - - - + + + + + + + + + + + +