- Drag-to-reorder user lists in the sidebar, persisted via a new list sort_order column (AddListSortOrder migration, backfilled by creation time) and ListRepository.ReorderAsync - "Open in Explorer" / "Open in Terminal" context-menu actions on lists - "Clear all completed" button on the Tasks island - Inline-edit subtask titles (empty text deletes the step) and click-to-copy task ID in the Details island - Make modal and planning windows resizable (BorderOnly decorations with min sizes) instead of fixed-size borderless Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
175 lines
6.0 KiB
C#
175 lines
6.0 KiB
C#
using System.Linq;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Input;
|
|
using Avalonia.Input.Platform;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Layout;
|
|
using Avalonia.Media;
|
|
using Avalonia.Threading;
|
|
using Avalonia.VisualTree;
|
|
using ClaudeDo.Ui.ViewModels.Islands;
|
|
using ClaudeDo.Ui.Views.Modals;
|
|
using ClaudeDo.Ui.Views.Planning;
|
|
|
|
namespace ClaudeDo.Ui.Views.Islands;
|
|
|
|
public partial class DetailsIslandView : UserControl
|
|
{
|
|
public DetailsIslandView()
|
|
{
|
|
InitializeComponent();
|
|
DataContextChanged += OnDataContextChanged;
|
|
}
|
|
|
|
private void OnDataContextChanged(object? sender, EventArgs e)
|
|
{
|
|
if (DataContext is DetailsIslandViewModel vm)
|
|
{
|
|
vm.ShowDiffModal = async (diffVm) =>
|
|
{
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner == null) return;
|
|
var modal = new DiffModalView { DataContext = diffVm };
|
|
await modal.ShowDialog(owner);
|
|
};
|
|
|
|
vm.ShowMergeModal = async (mergeVm) =>
|
|
{
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner == null) return;
|
|
var modal = new MergeModalView { DataContext = mergeVm };
|
|
await modal.ShowDialog(owner);
|
|
};
|
|
|
|
vm.ShowPlanningDiffModal = async (planningDiffVm) =>
|
|
{
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner == null) return;
|
|
var modal = new PlanningDiffView { DataContext = planningDiffVm };
|
|
await modal.ShowDialog(owner);
|
|
};
|
|
|
|
vm.ConfirmAsync = ShowConfirmAsync;
|
|
vm.ShowErrorAsync = ShowErrorDialogAsync;
|
|
}
|
|
}
|
|
|
|
private async System.Threading.Tasks.Task ShowErrorDialogAsync(string message)
|
|
{
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner == null) return;
|
|
|
|
var ok = new Button { Content = "OK", MinWidth = 90 };
|
|
|
|
var dialog = new Window
|
|
{
|
|
Title = "Error",
|
|
Width = 360,
|
|
SizeToContent = SizeToContent.Height,
|
|
CanResize = false,
|
|
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
|
ShowInTaskbar = false,
|
|
Background = this.FindResource("SurfaceBrush") as IBrush,
|
|
Content = new StackPanel
|
|
{
|
|
Spacing = 16,
|
|
Margin = new Thickness(20),
|
|
Children =
|
|
{
|
|
new TextBlock { Text = message, TextWrapping = TextWrapping.Wrap },
|
|
new StackPanel
|
|
{
|
|
Orientation = Orientation.Horizontal,
|
|
Spacing = 8,
|
|
HorizontalAlignment = HorizontalAlignment.Right,
|
|
Children = { ok }
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
ok.Click += (_, _) => dialog.Close();
|
|
|
|
await dialog.ShowDialog(owner);
|
|
}
|
|
|
|
private async System.Threading.Tasks.Task<bool> ShowConfirmAsync(string message)
|
|
{
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner == null) return false;
|
|
|
|
var tcs = new TaskCompletionSource<bool>();
|
|
|
|
var cancel = new Button { Content = "Cancel", MinWidth = 90 };
|
|
var confirm = new Button { Content = "Delete", MinWidth = 90, Classes = { "danger" } };
|
|
|
|
var dialog = new Window
|
|
{
|
|
Title = "Confirm",
|
|
Width = 360,
|
|
SizeToContent = SizeToContent.Height,
|
|
CanResize = false,
|
|
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
|
ShowInTaskbar = false,
|
|
Background = this.FindResource("SurfaceBrush") as IBrush,
|
|
Content = new StackPanel
|
|
{
|
|
Spacing = 16,
|
|
Margin = new Thickness(20),
|
|
Children =
|
|
{
|
|
new TextBlock { Text = message, TextWrapping = TextWrapping.Wrap },
|
|
new StackPanel
|
|
{
|
|
Orientation = Orientation.Horizontal,
|
|
Spacing = 8,
|
|
HorizontalAlignment = HorizontalAlignment.Right,
|
|
Children = { cancel, confirm }
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
cancel.Click += (_, _) => { tcs.TrySetResult(false); dialog.Close(); };
|
|
confirm.Click += (_, _) => { tcs.TrySetResult(true); dialog.Close(); };
|
|
dialog.Closed += (_, _) => tcs.TrySetResult(false);
|
|
|
|
_ = dialog.ShowDialog(owner);
|
|
return await tcs.Task;
|
|
}
|
|
|
|
private void OnSubtaskTitleTapped(object? sender, TappedEventArgs e)
|
|
{
|
|
if (sender is not Control c || c.DataContext is not SubtaskRowViewModel row) return;
|
|
row.IsEditing = true;
|
|
|
|
var box = (c.GetVisualParent() as Panel)?.GetVisualDescendants().OfType<TextBox>().FirstOrDefault();
|
|
if (box is not null)
|
|
Dispatcher.UIThread.Post(() => { box.Focus(); box.SelectAll(); }, DispatcherPriority.Background);
|
|
}
|
|
|
|
private void OnSubtaskEditLostFocus(object? sender, RoutedEventArgs e)
|
|
{
|
|
if (DataContext is DetailsIslandViewModel vm
|
|
&& sender is Control c && c.DataContext is SubtaskRowViewModel row)
|
|
vm.CommitSubtaskEditCommand.Execute(row);
|
|
}
|
|
|
|
private async void OnTaskIdTapped(object? sender, TappedEventArgs e)
|
|
{
|
|
if (DataContext is not DetailsIslandViewModel vm || vm.Task is null) return;
|
|
var clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
|
|
if (clipboard is null) return;
|
|
await clipboard.SetTextAsync(vm.Task.Id);
|
|
}
|
|
|
|
private async void OnCopyDescriptionClick(object? sender, RoutedEventArgs e)
|
|
{
|
|
if (DataContext is not DetailsIslandViewModel vm) return;
|
|
var clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
|
|
if (clipboard is null) return;
|
|
await clipboard.SetTextAsync(vm.EditableDescription ?? string.Empty);
|
|
}
|
|
}
|