fix(app): shell follows RTL from startup; welcome keeps the keyboard; accessible dialogs and errors
- The rail grows with the longest label (128-200 px); the first-run dialog disables the shell behind it and focuses its chosen option; toasts stay above it; F6 reaches the newest toast. - Confirm and login dialogs are named by their heading, focus the safe button, announce sign-in errors. - Error toasts say what happened only for catalog sentences (ErrorText); other details stay in the log. - Window title, queued-jobs text (plural) and the pause button name come from resources. - Logs, paths and templates in the client styles stay left to right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
12 files changed
+150
-53
No files matched your search
@@ -1,5 +1,9 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.Ui.Controls;
|
||||
|
||||
@@ -14,21 +18,50 @@ public partial class MainWindow : TitanoWindow
|
||||
_shell = shell;
|
||||
DataContext = shell;
|
||||
InitializeComponent();
|
||||
Rail.Width = shell.IsRailCollapsed ? 48 : 128;
|
||||
UpdateConnection();
|
||||
shell.PropertyChanged += (_, e) =>
|
||||
{
|
||||
if (e.PropertyName is nameof(ShellViewModel.IsRailCollapsed) or "")
|
||||
Rail.Width = shell.IsRailCollapsed ? 48 : 128;
|
||||
if (e.PropertyName is nameof(ShellViewModel.IsConnected) or "") UpdateConnection();
|
||||
if (e.PropertyName is nameof(ShellViewModel.IsWelcomeOpen) or "") FocusWelcome();
|
||||
};
|
||||
shell.PendingToasts.CollectionChanged += OnToastRequested;
|
||||
Loaded += (_, _) => FocusWelcome();
|
||||
RestorePlacement();
|
||||
Closing += (_, _) => SavePlacement();
|
||||
}
|
||||
|
||||
/// <summary>F6 moves the keyboard to the newest notification (as in Windows apps), Esc there dismisses it.</summary>
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
if (!e.Handled && e.Key == Key.F6 && Keyboard.Modifiers == ModifierKeys.None) e.Handled = Toasts.FocusNewest();
|
||||
}
|
||||
|
||||
private void UpdateConnection() =>
|
||||
Connection.SetResourceReference(System.Windows.Controls.TextBlock.ForegroundProperty, _shell.IsConnected ? "Brush.Accent" : "Brush.TextMuted");
|
||||
Connection.SetResourceReference(TextBlock.ForegroundProperty, _shell.IsConnected ? "Brush.Accent" : "Brush.TextMuted");
|
||||
|
||||
/// <summary>The first-run dialog takes the keyboard on its chosen option once it is on screen.</summary>
|
||||
private void FocusWelcome()
|
||||
{
|
||||
if (!_shell.IsWelcomeOpen) return;
|
||||
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () =>
|
||||
{
|
||||
if (!_shell.IsWelcomeOpen || !IsLoaded) return;
|
||||
if (FindChecked(WelcomeOverlay) is { } choice) choice.Focus();
|
||||
else WelcomeOverlay.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
|
||||
});
|
||||
}
|
||||
|
||||
private static RadioButton? FindChecked(DependencyObject root)
|
||||
{
|
||||
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(root, i);
|
||||
if (child is RadioButton { IsChecked: true } radio) return radio;
|
||||
if (FindChecked(child) is { } nested) return nested;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void OnToastRequested(object? sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user