Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/features/main_screen/workspace_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class _WorkspacePanelState extends State<WorkspacePanel> {
/// Keeps the last connected workspace mounted so empty↔active can cross-fade.
material.Widget? _cachedActiveBody;

/// Connection id for the cached active body (stable FadeSlide key on empty).
int? _lastConnectedId;

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
Expand All @@ -152,17 +155,27 @@ class _WorkspacePanelState extends State<WorkspacePanel> {
if (activeConn == null) {
activeBody = _cachedActiveBody ?? const material.SizedBox.expand();
} else {
_lastConnectedId = activeConn.id;
activeBody = _buildActiveConnectionBody(theme, activeConn);
_cachedActiveBody = activeBody;
}

// Connection A→B: keyed FadeSlide inside the connected slot (#494).
// Keep last id when deselected so empty↔connected SwitchingBody is undisturbed.
final connKey = activeConn?.id ?? _lastConnectedId ?? 0;

return material.Container(
color: theme.colorScheme.background,
child: QueryaSwitchingBody(
index: activeConn == null ? 0 : 1,
children: [
empty,
material.SizedBox.expand(child: activeBody),
QueryaFadeSlide(
child: material.SizedBox.expand(
key: ValueKey('ws_conn_$connKey'),
child: activeBody,
),
),
],
),
);
Expand Down
44 changes: 44 additions & 0 deletions test/features/main_screen/workspace_panel_layout_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,49 @@ void main() {
expect(find.byType(RedisView), findsOneWidget);
expect(find.byType(QueryaSwitchingBody), findsNWidgets(2));
});

testWidgets('connection A→B morph uses outer QueryaFadeSlide',
(tester) async {
const redisB = ConnectionRow(
id: 43,
type: 'redis',
name: 'redis-b',
host: '127.0.0.1',
port: 6380,
createdAt: '0',
);

await pumpWidgetWithSurfaceSize(
tester,
const material.Size(800, 600),
queryaThemeTestShell(
child: const material.SizedBox.expand(
child: WorkspacePanel(activeConnection: redisConnection),
),
),
);
await tester.pump();

expect(find.byKey(const material.ValueKey('ws_conn_42')), findsOneWidget);
expect(find.byType(RedisView), findsOneWidget);

await pumpWidgetWithSurfaceSize(
tester,
const material.Size(800, 600),
queryaThemeTestShell(
child: const material.SizedBox.expand(
child: WorkspacePanel(activeConnection: redisB),
),
),
);
await tester.pump();
await tester.pump(const Duration(milliseconds: 50));

expect(find.byKey(const material.ValueKey('ws_conn_43')), findsOneWidget);
// Outer empty↔connected FadeSlide + home↔object FadeSlide.
expect(find.byType(QueryaFadeSlide), findsWidgets);
expect(find.byType(RedisView), findsOneWidget);
expect(find.byType(QueryaSwitchingBody), findsNWidgets(2));
});
});
}
Loading