diff --git a/lib/widgets/sidebar_navigation.dart b/lib/widgets/sidebar_navigation.dart index 5c7d305c..37fd8302 100644 --- a/lib/widgets/sidebar_navigation.dart +++ b/lib/widgets/sidebar_navigation.dart @@ -106,6 +106,13 @@ class SidebarNavigation extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ const SizedBox(height: 4), + if (isCollapsed && showCollapseControl) ...[ + SidebarHeader( + isCollapsed: true, + onTap: onExpandFromCollapsed, + ), + const SizedBox(height: AppSpacing.xs), + ], Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -151,7 +158,7 @@ class SidebarNavigation extends StatelessWidget { ), accountSelected: currentSection == WorkspaceDestination.account, - showCollapseControl: showCollapseControl && isCollapsed, + showCollapseControl: false, ), ], ), @@ -189,6 +196,7 @@ class SidebarHeader extends StatelessWidget { child: Align( alignment: Alignment.centerRight, child: InkWell( + key: const Key('sidebar-header-expand-button'), borderRadius: BorderRadius.circular(AppRadius.button), onTap: onTap, child: Padding(padding: EdgeInsets.zero, child: content), diff --git a/test/widgets/sidebar_navigation_suite.dart b/test/widgets/sidebar_navigation_suite.dart index 3e791376..9b4ed8da 100644 --- a/test/widgets/sidebar_navigation_suite.dart +++ b/test/widgets/sidebar_navigation_suite.dart @@ -160,6 +160,47 @@ void main() { ); }); + testWidgets('SidebarNavigation shows collapsed expand button at the top', ( + WidgetTester tester, + ) async { + var expanded = 0; + + await tester.pumpWidget( + MaterialApp( + theme: AppTheme.light(), + home: Scaffold( + body: SidebarNavigation( + currentSection: WorkspaceDestination.assistant, + sidebarState: AppSidebarState.collapsed, + appLanguage: AppLanguage.zh, + themeMode: ThemeMode.light, + onSectionChanged: (_) {}, + onToggleLanguage: () {}, + onCycleSidebarState: () {}, + onExpandFromCollapsed: () => expanded++, + onOpenHome: () {}, + onOpenAccount: () {}, + onOpenThemeToggle: () {}, + accountName: 'Tester', + accountSubtitle: 'Workspace', + onToggleAccountWorkspaceFollowed: () async {}, + ), + ), + ), + ); + await tester.pumpAndSettle(); + + expect(find.byKey(const Key('sidebar-header-expand-button')), findsOneWidget); + expect( + find.byKey(const ValueKey('sidebar-footer-collapse')), + findsNothing, + ); + + await tester.tap(find.byKey(const Key('sidebar-header-expand-button'))); + await tester.pumpAndSettle(); + expect(expanded, 1); + }); + testWidgets('SidebarNavigation merges task controls into the global left bar', ( WidgetTester tester, ) async {