refactor(desktop): reorganize workspace panels and navigation
Gitea CI / Windows x64 and Android (pull_request) Successful in 16m21s
Gitea CI / Gitea CI passed (pull_request) Successful in 3s

This commit is contained in:
lingjhf committed 2026-10-06 12:11:59 +08:00
1 parent 826745b407
commit 1f73765745
92 files changed
+5811 -2650

No files matched your search

+105
View File
@@ -0,0 +1,105 @@
import 'package:cutdex/shared/widgets/workspace_resize_handle.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
for (final axis in Axis.values) {
for (final finish in ['release', 'cancel', 'unmount']) {
testWidgets('$axis resize cursor stays locked until $finish', (
tester,
) async {
var showHandle = true;
var taps = 0;
var ends = 0;
var updates = 0;
late StateSetter update;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: StatefulBuilder(
builder: (context, setState) {
update = setState;
return Stack(
children: [
Positioned(
left: 400,
top: 400,
width: 100,
height: 60,
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
key: const Key('button'),
onTap: () => taps++,
child: const ColoredBox(color: Colors.blue),
),
),
),
if (showHandle)
Positioned(
left: 100,
top: 100,
width: axis == Axis.horizontal ? 5 : 200,
height: axis == Axis.horizontal ? 200 : 5,
child: WorkspaceResizeHandle(
key: const Key('handle'),
axis: axis,
initialValue: 100,
onResize: (_) => updates++,
onEnd: () => ends++,
),
),
],
);
},
),
),
),
);
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
final start = tester.getCenter(find.byKey(const Key('handle')));
final button = tester.getCenter(find.byKey(const Key('button')));
await mouse.addPointer(location: start);
await mouse.down(start);
await mouse.moveBy(
axis == Axis.horizontal ? const Offset(30, 0) : const Offset(0, 30),
);
await tester.pump();
await mouse.moveTo(button);
await tester.pump();
expect(updates, greaterThan(0));
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
axis == Axis.horizontal
? SystemMouseCursors.resizeColumn
: SystemMouseCursors.resizeRow,
);
// A second pointer still reaches the control through the cursor overlay.
await tester.tap(find.byKey(const Key('button')));
expect(taps, 1);
if (finish == 'unmount') {
update(() => showHandle = false);
await tester.pumpAndSettle();
await mouse.up();
} else if (finish == 'cancel') {
await mouse.cancel();
} else {
await mouse.up();
}
await tester.pumpAndSettle();
await mouse.moveTo(button + const Offset(1, 0));
await tester.pump();
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.click,
);
expect(ends, finish == 'unmount' ? 0 : 1);
await mouse.removePointer();
expect(tester.takeException(), isNull);
});
}
}
}