Files
ClaudeDo/src/ClaudeDo.Ui/Views/MainWindow.axaml.cs
mika kuns ca71275fc4 feat(ui): polish worktrees overview modal
- Restyle to match ListSettingsModalView: custom title bar, DeepBrush
  toolbar, LineBrush footer, SurfaceBrush outer border, no system chrome
- Add column header row (TASK / BRANCH / STATE / DIFF / AGE) with
  TextFaintBrush + MonoFont + LetterSpacing, separator line below
- Replace wt-row style with task-row-equivalent: transparent bg,
  CornerRadius 8, 1px border, :pointerover + .selected transitions
- Add IsSelected to WorktreeOverviewRowViewModel; SelectRow() helper
  on modal VM clears previous selection before setting new one
- Wire OnRowTapped in code-behind for click-to-select
- Wire ShowDiff: VM takes Func<WorktreeModalViewModel> factory, builds
  diffVm and delegates window creation to both call sites (MainWindow
  and ListsIslandView); register Func<WorktreeModalViewModel> in DI

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 10:38:19 +02:00

89 lines
3.2 KiB
C#

using System.Linq;
using Avalonia.Controls;
using Avalonia.Input;
using ClaudeDo.Ui.ViewModels;
using ClaudeDo.Ui.ViewModels.Islands;
using ClaudeDo.Ui.ViewModels.Modals;
using ClaudeDo.Ui.Views.Modals;
using ClaudeDo.Ui.Views.Planning;
namespace ClaudeDo.Ui.Views;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
KeyDown += OnWindowKeyDown;
DataContextChanged += OnDataContextChanged;
}
private void OnDataContextChanged(object? sender, EventArgs e)
{
if (DataContext is IslandsShellViewModel vm)
{
vm.ShowConflictDialog = async (conflictVm) =>
{
var modal = new ConflictResolutionView { DataContext = conflictVm };
await modal.ShowDialog(this);
};
vm.ShowAboutModal = async (aboutVm) =>
{
var dlg = new AboutModalView { DataContext = aboutVm };
var tcs = new TaskCompletionSource<bool>();
aboutVm.CloseAction = () => { dlg.Close(); tcs.TrySetResult(true); };
await dlg.ShowDialog(this);
};
vm.ShowWorktreesOverviewModal = async (modal) =>
{
var dlg = new WorktreesOverviewModalView { DataContext = modal };
modal.CloseAction = () => dlg.Close();
modal.JumpToTaskAction = (listId, _) =>
{
if (DataContext is IslandsShellViewModel s)
{
var item = s.Lists?.UserLists.FirstOrDefault(l => l.Id == $"user:{listId}");
if (item is not null && s.Lists is not null) s.Lists.SelectedList = item;
}
};
modal.ShowDiffAction = diffVm =>
{
var diffDlg = new WorktreeModalView { DataContext = diffVm };
diffVm.CloseAction = () => diffDlg.Close();
_ = diffVm.LoadAsync();
_ = diffDlg.ShowDialog(this);
};
await dlg.ShowDialog(this);
};
}
}
private void OnWindowKeyDown(object? sender, KeyEventArgs e)
{
if (e.Key == Key.Space
&& FocusManager?.GetFocusedElement() is not TextBox
&& DataContext is IslandsShellViewModel vm)
{
e.Handled = true;
_ = vm.ToggleSelectedDoneAsync();
}
}
private void OnTitleBarPressed(object? sender, PointerPressedEventArgs e)
{
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
BeginMoveDrag(e);
}
private void OnMinimize(object? s, Avalonia.Interactivity.RoutedEventArgs e) =>
WindowState = WindowState.Minimized;
private void OnToggleMax(object? s, Avalonia.Interactivity.RoutedEventArgs e) =>
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
private void OnClose(object? s, Avalonia.Interactivity.RoutedEventArgs e) => Close();
protected override void OnSizeChanged(SizeChangedEventArgs e)
{
base.OnSizeChanged(e);
if (DataContext is IslandsShellViewModel vm) vm.WindowWidth = Bounds.Width;
}
}