feat(ui): chromeless three-island shell
This commit is contained in:
@@ -1,75 +1,27 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.VisualTree;
|
||||
using ClaudeDo.Ui.ViewModels;
|
||||
|
||||
namespace ClaudeDo.Ui.Views;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
public MainWindow() { InitializeComponent(); }
|
||||
|
||||
private void OnTitleBarPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
InitializeComponent();
|
||||
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 async void OnOpened(EventArgs e)
|
||||
protected override void OnSizeChanged(SizeChangedEventArgs e)
|
||||
{
|
||||
base.OnOpened(e);
|
||||
if (DataContext is MainWindowViewModel vm)
|
||||
await vm.InitializeAsync();
|
||||
}
|
||||
|
||||
private void OnGlobalKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (DataContext is not MainWindowViewModel vm) return;
|
||||
|
||||
var ctrl = e.KeyModifiers.HasFlag(KeyModifiers.Control);
|
||||
var shift = e.KeyModifiers.HasFlag(KeyModifiers.Shift);
|
||||
|
||||
if (ctrl && shift && e.Key == Key.N)
|
||||
{
|
||||
vm.AddListCommand.Execute(null);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (ctrl && e.Key == Key.N)
|
||||
{
|
||||
var taskListView = this.GetVisualDescendants().OfType<TaskListView>().FirstOrDefault();
|
||||
taskListView?.FocusInlineAdd();
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (ctrl && e.Key == Key.L)
|
||||
{
|
||||
this.FindControl<ListBox>("ListsBox")?.Focus();
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (ctrl && e.Key == Key.R)
|
||||
{
|
||||
if (vm.TaskList.SelectedTask is { } task)
|
||||
{
|
||||
task.RunNowCommand.Execute(null);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnListItemDoubleTapped(object? sender, TappedEventArgs e)
|
||||
{
|
||||
if (DataContext is MainWindowViewModel vm)
|
||||
vm.EditListCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnListItemPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
var props = e.GetCurrentPoint(this).Properties;
|
||||
if (!props.IsRightButtonPressed) return;
|
||||
|
||||
if (sender is Grid { DataContext: ListItemViewModel item }
|
||||
&& DataContext is MainWindowViewModel vm)
|
||||
{
|
||||
vm.SelectedList = item;
|
||||
}
|
||||
base.OnSizeChanged(e);
|
||||
if (DataContext is IslandsShellViewModel vm) vm.WindowWidth = Bounds.Width;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user