- Init Localizer at app startup (before self-update prompt) and assign to TrExtension.Localizer - Register ILocalizer in DI; inject into WizardViewModel and SettingsViewModel - WizardViewModel: SelectedLanguage ComboBox binding with OnSelectedLanguageChanged -> SetLanguage + InstallContext.Language - WizardWindow.xaml: DockPanel wraps step chips + language ComboBox (right-aligned) - Localize all installer XAML: WizardWindow, WelcomePage, PathsPage, ServicePage, UiSettingsPage, InstallPage, SettingsWindow, SelfUpdatePromptWindow - Localize page Title properties and WizardViewModel.NextButtonText via TrExtension.Localizer - Persist chosen Language in WriteConfigStep and SettingsViewModel.Save into ui.config.json - Append installer section to en.json (nav, welcome, paths, service, uiSettings, install, settings, selfUpdate) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
85 lines
2.3 KiB
C#
85 lines
2.3 KiB
C#
using System.Windows.Controls;
|
|
using ClaudeDo.Installer.Core;
|
|
using ClaudeDo.Installer.Localization;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
namespace ClaudeDo.Installer.Pages.UiSettingsPage;
|
|
|
|
public partial class UiSettingsPageViewModel : ObservableObject, IInstallerPage
|
|
{
|
|
private readonly InstallContext _context;
|
|
private UiSettingsPageView? _view;
|
|
|
|
public string Title => TrExtension.Localizer?["installer.uiSettings.title"] ?? "UI Settings";
|
|
public string Icon => "\uE771";
|
|
public int Order => 3;
|
|
public bool ShowInWizard => true;
|
|
public bool ShowInSettings => true;
|
|
public UserControl View => _view ??= new UiSettingsPageView { DataContext = this };
|
|
|
|
[ObservableProperty] private string _signalRUrl = "http://127.0.0.1:47821/hub";
|
|
[ObservableProperty] private string _uiDbPath = "~/.todo-app/todo.db";
|
|
[ObservableProperty] private bool _isSynced = true;
|
|
[ObservableProperty] private string? _validationError;
|
|
|
|
public UiSettingsPageViewModel(InstallContext context) => _context = context;
|
|
|
|
partial void OnIsSyncedChanged(bool value)
|
|
{
|
|
if (value) SyncFromContext();
|
|
}
|
|
|
|
private void SyncFromContext()
|
|
{
|
|
SignalRUrl = $"http://127.0.0.1:{_context.SignalRPort}/hub";
|
|
UiDbPath = _context.DbPath;
|
|
}
|
|
|
|
public Task LoadAsync()
|
|
{
|
|
if (IsSynced)
|
|
{
|
|
SyncFromContext();
|
|
}
|
|
else
|
|
{
|
|
var cfg = InstallerAppSettings.Load();
|
|
SignalRUrl = cfg.SignalRUrl;
|
|
UiDbPath = cfg.DbPath;
|
|
}
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task ApplyAsync()
|
|
{
|
|
if (IsSynced) SyncFromContext();
|
|
_context.SignalRUrl = SignalRUrl;
|
|
_context.UiDbPath = UiDbPath;
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public bool Validate()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(SignalRUrl))
|
|
{
|
|
ValidationError = "SignalR URL is required.";
|
|
return false;
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(UiDbPath))
|
|
{
|
|
ValidationError = "Database path is required.";
|
|
return false;
|
|
}
|
|
|
|
if (!Uri.TryCreate(SignalRUrl, UriKind.Absolute, out _))
|
|
{
|
|
ValidationError = "SignalR URL must be a valid URL.";
|
|
return false;
|
|
}
|
|
|
|
ValidationError = null;
|
|
return true;
|
|
}
|
|
}
|