Files
Chronos/src/Titano.App/Sections/Sections.cs
T
Claude c40b6a7cd3 feat: Phase 0 shells, design system, server skeleton, Docker and CI
- Titano.Ui: DESIGN.md tokens (dark/light), generated 16-px icon set,
  styles for all standard controls, custom chrome window with snap
  layouts, rail, job bar, Auto/manual slider, chips, toasts.
- Titano desktop shell with sections, Settings (language, theme),
  About and a --capture screenshot mode.
- Titano Server skeleton: env/server.json configuration, self-signed
  TLS with fingerprint, /health, /server/info, i18n endpoint and the
  embedded admin panel; in-process server tests.
- Docker image (multi-arch, PUID/PGID, health check), compose file,
  Unraid template; CI, release and nightly workflows; changelog tool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
2026-10-02 09:35:03 +00:00

165 lines
5.3 KiB
C#

using System.Reflection;
using System.Windows.Input;
using Titano.App.Infrastructure;
using Titano.App.Shell;
using Titano.Core.Localization;
using Titano.Ui.Mvvm;
using Titano.Ui.Theming;
namespace Titano.App.Sections;
/// <summary>Library (home): sequences of the archive (BRIEF §12.2).</summary>
public sealed class LibraryViewModel(ShellViewModel shell) : SectionViewModel(SectionKey.Library, "Icon.Library")
{
public ShellViewModel Shell { get; } = shell;
public ICommand ImportCardCommand => new RelayCommand(() => Shell.Navigate(SectionKey.Import));
public ICommand OpenArchiveCommand => new RelayCommand(() => Shell.Navigate(SectionKey.Archive));
public ICommand ConnectCommand => new RelayCommand(() => Shell.Navigate(SectionKey.Server));
}
/// <summary>Card and folder import (BRIEF §12.4).</summary>
public sealed class ImportViewModel(ShellViewModel shell) : SectionViewModel(SectionKey.Import, "Icon.Import")
{
public ShellViewModel Shell { get; } = shell;
}
/// <summary>Sequence editor (BRIEF §12.3).</summary>
public sealed class SequenceViewModel(ShellViewModel shell) : SectionViewModel(SectionKey.Sequence, "Icon.Sequence")
{
public ShellViewModel Shell { get; } = shell;
public ICommand OpenLibraryCommand => new RelayCommand(() => Shell.Navigate(SectionKey.Library));
}
/// <summary>Archive manager (BRIEF §12.5).</summary>
public sealed class ArchiveViewModel(ShellViewModel shell) : SectionViewModel(SectionKey.Archive, "Icon.Archive")
{
public ShellViewModel Shell { get; } = shell;
}
/// <summary>Job queue and history (BRIEF §12.6).</summary>
public sealed class JobsViewModel(ShellViewModel shell) : SectionViewModel(SectionKey.Jobs, "Icon.Jobs")
{
public ShellViewModel Shell { get; } = shell;
}
/// <summary>Server connection and sync (BRIEF §12.7).</summary>
public sealed class ServerViewModel(ShellViewModel shell) : SectionViewModel(SectionKey.Server, "Icon.Server")
{
public ShellViewModel Shell { get; } = shell;
}
public sealed record LanguageOption(string Code, string Name);
/// <summary>Settings (BRIEF §12.8): section list on the left, controls on the right, tooltips only.</summary>
public sealed class SettingsViewModel : SectionViewModel
{
private readonly AppSettings _settings;
private string _page = "General";
public SettingsViewModel(ShellViewModel shell, AppSettings settings)
: base(SectionKey.Settings, "Icon.Settings")
{
Shell = shell;
_settings = settings;
Languages = Core.Localization.Languages.Shipped
.Select(c => new LanguageOption(c, Core.Localization.Languages.NativeName(c)))
.ToList();
SelectPageCommand = new RelayCommand(p =>
{
if (p is string page) Page = page;
});
}
public ShellViewModel Shell { get; }
public IReadOnlyList<string> Pages { get; } = ["General", "Advanced"];
public ICommand SelectPageCommand { get; }
public string Page
{
get => _page;
set => Set(ref _page, value);
}
public IReadOnlyList<LanguageOption> Languages { get; }
public LanguageOption SelectedLanguage
{
get => Languages.FirstOrDefault(l => l.Code.Equals(Loc.Culture.Name, StringComparison.OrdinalIgnoreCase)) ?? Languages[0];
set
{
if (value is null) return;
_settings.Language = value.Code;
App.Current.ApplyLanguage(value.Code);
App.Current.SaveSettings();
}
}
public bool IsDarkTheme
{
get => _settings.Theme == AppTheme.Dark;
set
{
if (value) ApplyTheme(AppTheme.Dark);
}
}
public bool IsLightTheme
{
get => _settings.Theme == AppTheme.Light;
set
{
if (value) ApplyTheme(AppTheme.Light);
}
}
public bool IsSystemTheme
{
get => _settings.Theme == AppTheme.System;
set
{
if (value) ApplyTheme(AppTheme.System);
}
}
public bool CheckForUpdates
{
get => _settings.CheckForUpdates;
set
{
_settings.CheckForUpdates = value;
App.Current.SaveSettings();
OnPropertyChanged();
}
}
private void ApplyTheme(AppTheme theme)
{
_settings.Theme = theme;
ThemeManager.Apply(theme);
App.Current.SaveSettings();
OnPropertyChanged(nameof(IsDarkTheme));
OnPropertyChanged(nameof(IsLightTheme));
OnPropertyChanged(nameof(IsSystemTheme));
}
}
/// <summary>About (BRIEF §12.9).</summary>
public sealed class AboutViewModel(ShellViewModel shell) : SectionViewModel(SectionKey.About, "Icon.About")
{
public ShellViewModel Shell { get; } = shell;
public string Version => typeof(App).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "0.0.0";
public string Runtime => System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
public string OperatingSystem => System.Runtime.InteropServices.RuntimeInformation.OSDescription;
public string DataFolder => App.Current.Environment.DataDirectory;
public ICommand OpenDataFolderCommand => new RelayCommand(() => ShellActions.OpenFolder(DataFolder));
public ICommand OpenReleasesCommand => new RelayCommand(() => ShellActions.OpenUrl(ProductLinks.Releases));
}