refactor(desktop): reorganize workspace panels and navigation
This commit is contained in:
1 parent
826745b407
commit
1f73765745
92 files changed
+5811
-2650
No files matched your search
@@ -22,7 +22,6 @@ import 'package:cutdex/integrations/agent/conversation_repository.dart';
|
||||
import 'package:cutdex/integrations/platform/device_experience.dart';
|
||||
import 'package:cutdex/persistence/app_database.dart';
|
||||
import 'package:cutdex/persistence/app_settings_repositories.dart';
|
||||
import 'package:cutdex/shared/layout/workspace_layout_metrics.dart';
|
||||
import 'package:cutdex/workspace/media_availability.dart';
|
||||
import 'package:cutdex/workspace/project_state.dart';
|
||||
import 'package:cutdex/workspace/projects.dart';
|
||||
@@ -139,6 +138,48 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets(
|
||||
'desktop navigation switches sidebar content and retains workspace',
|
||||
(tester) async {
|
||||
final mounted = await mount(tester, const Size(1200, 800));
|
||||
final headerToggle = find.byKey(const Key('project-sidebar-toggle'));
|
||||
final headerTasks = find.byKey(const ValueKey('background-tasks-button'));
|
||||
expect(tester.getSize(headerToggle), const Size.square(28));
|
||||
expect(tester.getSize(headerTasks), const Size.square(28));
|
||||
expect(
|
||||
tester.getRect(headerToggle).center.dx,
|
||||
tester.getRect(find.byKey(const Key('desktop-rail-cut'))).center.dx,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(headerTasks).center.dx -
|
||||
tester.getRect(headerToggle).center.dx,
|
||||
32,
|
||||
);
|
||||
expect(find.byKey(const Key('desktop-rail-agent')), findsNothing);
|
||||
expect(find.byKey(const Key('desktop-rail-cut')), findsOneWidget);
|
||||
final library = find.byKey(const Key('desktop-rail-library'));
|
||||
final editorElement = tester.element(find.byType(EditorWorkspace));
|
||||
await tester.tap(library);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('desktop-library-workspace')), findsNothing);
|
||||
expect(find.byType(EditorWorkspace), findsOneWidget);
|
||||
expect(
|
||||
tester.element(find.byType(EditorWorkspace, skipOffstage: false)),
|
||||
same(editorElement),
|
||||
);
|
||||
expect(find.byType(MediaPanel), findsOneWidget);
|
||||
expect(tester.widget<IconButton>(library).isSelected, isTrue);
|
||||
expect(find.byKey(const Key('project-settings-button')), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('desktop-rail-cut')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('desktop-library-workspace')), findsNothing);
|
||||
expect(tester.element(find.byType(EditorWorkspace)), same(editorElement));
|
||||
expect(find.byType(MediaPanel), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
await mounted.close();
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Windows caption space follows real workspace pane changes', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -160,14 +201,29 @@ void main() {
|
||||
messenger.setMockMethodCallHandler(dropChannel, null);
|
||||
});
|
||||
final mounted = await mount(tester, const Size(1200, 800));
|
||||
final contentRect = tester.getRect(
|
||||
find.byKey(const Key('desktop-content-container')),
|
||||
);
|
||||
expect(
|
||||
contentRect.top,
|
||||
tester.getRect(find.byKey(const Key('desktop-window-header'))).bottom,
|
||||
);
|
||||
expect(
|
||||
contentRect.left,
|
||||
tester.getRect(find.byKey(const Key('desktop-navigation-rail'))).right,
|
||||
);
|
||||
expect(contentRect.right, 1199);
|
||||
expect(contentRect.bottom, 799);
|
||||
for (final mode in [WorkspaceMode.agent, WorkspaceMode.cut]) {
|
||||
await setMode(tester, mounted.container, mode);
|
||||
for (final width in [1200.0, 700.0, 400.0, 1200.0]) {
|
||||
tester.view.physicalSize = Size(width, 800);
|
||||
await tester.pumpAndSettle();
|
||||
final controlsLeft = tester
|
||||
.getTopLeft(find.byKey(const Key('window-minimize')))
|
||||
.dx;
|
||||
final captionRect = tester
|
||||
.getRect(find.byKey(const Key('window-minimize')))
|
||||
.expandToInclude(
|
||||
tester.getRect(find.byKey(const Key('window-close'))),
|
||||
);
|
||||
for (final key in [
|
||||
'editor-media-button',
|
||||
'editor-properties-button',
|
||||
@@ -191,8 +247,8 @@ void main() {
|
||||
});
|
||||
if (rect.isEmpty) continue;
|
||||
expect(
|
||||
rect.right,
|
||||
lessThanOrEqualTo(controlsLeft + 0.1),
|
||||
rect.overlaps(captionRect),
|
||||
isFalse,
|
||||
reason: '$key at $width in $mode',
|
||||
);
|
||||
}
|
||||
@@ -285,69 +341,45 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'desktop tools overlay in limited editor space and restore fixed sidebars',
|
||||
(tester) async {
|
||||
final mounted = await mount(tester, const Size(1200, 800));
|
||||
await setMode(tester, mounted.container, WorkspaceMode.cut);
|
||||
await tester.tap(find.byKey(const Key('editor-media-button')));
|
||||
await tester.tap(find.byKey(const Key('editor-properties-button')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.getSize(find.byType(MediaPanel)).width,
|
||||
WorkspaceLayoutMetrics.mediaPanelWidth,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byType(EditorPropertiesPanel)).width,
|
||||
WorkspaceLayoutMetrics.propertiesPanelWidth,
|
||||
);
|
||||
expect(find.byKey(const Key('editor-tool-surface')), findsNothing);
|
||||
|
||||
await setMode(tester, mounted.container, WorkspaceMode.agent);
|
||||
expect(find.byKey(const Key('editor-tool-surface')), findsOneWidget);
|
||||
expect(find.byType(EditorPropertiesPanel), findsOneWidget);
|
||||
expect(find.byType(PropertiesEditorPage), findsNothing);
|
||||
expect(find.byType(EditorTimelinePanel), findsOneWidget);
|
||||
expect(
|
||||
mounted.container
|
||||
.read(projectViewSettingsProvider(mounted.projectId))
|
||||
.requireValue
|
||||
.propertiesOpen,
|
||||
isTrue,
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('editor-media-button')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(MediaPanel), findsOneWidget);
|
||||
|
||||
expect(find.byType(MediaBrowserDrawer), findsNothing);
|
||||
expect(find.byType(PropertiesToolPanel), findsNothing);
|
||||
expect(
|
||||
tester
|
||||
.widget<IconButton>(find.byKey(const Key('editor-media-button')))
|
||||
.isSelected,
|
||||
isTrue,
|
||||
);
|
||||
await setMode(tester, mounted.container, WorkspaceMode.cut);
|
||||
expect(find.byKey(const Key('editor-tool-surface')), findsNothing);
|
||||
expect(
|
||||
tester.getSize(find.byType(MediaPanel)).width,
|
||||
WorkspaceLayoutMetrics.mediaPanelWidth,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byType(EditorPropertiesPanel)).width,
|
||||
WorkspaceLayoutMetrics.propertiesPanelWidth,
|
||||
);
|
||||
expect(
|
||||
await mounted.container.read(
|
||||
editorTimelineProvider(mounted.projectId, 'project').future,
|
||||
),
|
||||
same(mounted.session),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
await mounted.close();
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('desktop resources retain state across navigation switches', (
|
||||
tester,
|
||||
) async {
|
||||
final mounted = await mount(tester, const Size(1800, 800));
|
||||
await setMode(tester, mounted.container, WorkspaceMode.cut);
|
||||
expect(find.byKey(const Key('editor-media-button')), findsNothing);
|
||||
await tester.tap(find.byKey(const Key('desktop-rail-library')));
|
||||
await tester.pumpAndSettle();
|
||||
final mediaElement = tester.element(find.byType(MediaPanel));
|
||||
expect(
|
||||
tester
|
||||
.getRect(find.byKey(const Key('desktop-project-card')))
|
||||
.contains(tester.getRect(find.byType(MediaPanel)).center),
|
||||
isTrue,
|
||||
);
|
||||
final browser = mounted.container.read(
|
||||
mediaBrowserProvider(mounted.projectId),
|
||||
);
|
||||
browser.filter = MediaFilter.image;
|
||||
browser.selectedAssetId = 'media';
|
||||
await tester.tap(find.byKey(const Key('desktop-rail-cut')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(MediaPanel), findsNothing);
|
||||
await tester.tap(find.byKey(const Key('desktop-rail-library')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.element(find.byType(MediaPanel)), same(mediaElement));
|
||||
expect(browser.filter, MediaFilter.image);
|
||||
expect(browser.selectedAssetId, 'media');
|
||||
expect(find.byKey(const Key('sidebar-tab-resources')), findsNothing);
|
||||
expect(find.byType(EditorWorkspace), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('desktop-rail-cut')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('editor-properties-button')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(EditorPropertiesPanel), findsOneWidget);
|
||||
expect(find.byKey(const Key('editor-media-region')), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
await mounted.close();
|
||||
});
|
||||
testWidgets(
|
||||
'phone tools use independent pages without changing desktop preferences',
|
||||
(tester) async {
|
||||
@@ -449,7 +481,15 @@ void main() {
|
||||
experience: experience,
|
||||
);
|
||||
await setMode(tester, mounted.container, WorkspaceMode.cut);
|
||||
await tester.tap(find.byKey(const Key('editor-media-button')));
|
||||
await tester.tap(
|
||||
find.byKey(
|
||||
Key(
|
||||
experience == DeviceExperience.desktop
|
||||
? 'desktop-rail-library'
|
||||
: 'editor-media-button',
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final browser = mounted.container.read(
|
||||
mediaBrowserProvider(mounted.projectId),
|
||||
@@ -463,8 +503,19 @@ void main() {
|
||||
]) {
|
||||
tester.view.physicalSize = size;
|
||||
await tester.pumpAndSettle();
|
||||
if (experience == DeviceExperience.desktop) {
|
||||
if (size.width < 700) {
|
||||
await tester.tap(find.byKey(const Key('project-sidebar-toggle')));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
await tester.tap(find.byKey(const Key('desktop-rail-library')));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
expect(
|
||||
find.byKey(Key('${experience.name}-workspace-shell')),
|
||||
find.byKey(
|
||||
Key('${experience.name}-workspace-shell'),
|
||||
skipOffstage: false,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
@@ -506,7 +557,10 @@ void main() {
|
||||
);
|
||||
if (experience == DeviceExperience.desktop) {
|
||||
expect(
|
||||
find.byKey(const Key('editor-timeline-resize')),
|
||||
find.byKey(
|
||||
const Key('editor-timeline-resize'),
|
||||
skipOffstage: false,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
}
|
||||
@@ -517,6 +571,10 @@ void main() {
|
||||
expect(browser.filter, MediaFilter.image);
|
||||
expect(browser.selectedAssetId, 'media');
|
||||
expect(tester.takeException(), isNull);
|
||||
if (experience == DeviceExperience.desktop && size.width < 700) {
|
||||
Scaffold.of(tester.element(find.byType(MediaPanel))).closeDrawer();
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
}
|
||||
await mounted.close();
|
||||
},
|
||||
@@ -957,14 +1015,17 @@ void main() {
|
||||
}
|
||||
resolver.gate.complete();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(SnackBar), findsNothing);
|
||||
expect(find.byKey(const Key('global-error-notification')), findsNothing);
|
||||
if (target == 'media') {
|
||||
await tester.tap(find.byKey(const Key('editor-media-button')));
|
||||
await tester.pumpAndSettle();
|
||||
} else {
|
||||
await setMode(tester, mounted.container, WorkspaceMode.agent);
|
||||
}
|
||||
expect(find.byType(SnackBar), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(const Key('global-error-notification')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.textContaining('bad.mov:'), findsOneWidget);
|
||||
final feedback = target == 'media'
|
||||
? mounted.container
|
||||
@@ -980,8 +1041,7 @@ void main() {
|
||||
)
|
||||
.feedback;
|
||||
expect(feedback.hasPending, isFalse);
|
||||
ScaffoldMessenger.of(tester.element(find.byType(SnackBar)))
|
||||
.removeCurrentSnackBar();
|
||||
await tester.tap(find.byKey(const Key('close-error-button')));
|
||||
await tester.pumpAndSettle();
|
||||
await setMode(tester, mounted.container, WorkspaceMode.cut);
|
||||
await setMode(tester, mounted.container, WorkspaceMode.agent);
|
||||
@@ -990,7 +1050,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('editor-media-button')));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
expect(find.byType(SnackBar), findsNothing);
|
||||
expect(find.byKey(const Key('global-error-notification')), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -1002,14 +1062,9 @@ void main() {
|
||||
expect(find.byKey(const Key('desktop-workspace-shell')), findsOneWidget);
|
||||
expect(find.byKey(const Key('agent-panel-resize')), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
tester.view.physicalSize = const Size(240, 800);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('agent-panel-resize')), findsOneWidget);
|
||||
await tester.drag(
|
||||
find.byKey(const Key('agent-panel-resize')),
|
||||
const Offset(-20, 0),
|
||||
);
|
||||
tester.view.physicalSize = const Size(308, 800);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('agent-panel-resize')), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
tester.view.physicalSize = const Size(200, 800);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
Reference in new issue
Block a user