From 8b8b4a5747f10022e09a3f8604f1ed0ac2a467e8 Mon Sep 17 00:00:00 2001 From: ngfchl Date: Sun, 19 Jul 2026 13:56:07 +0800 Subject: [PATCH] keep mobile sidebar open during mode switch --- lib/pages/workspace_page.dart | 148 +++++++++++++++++----------------- 1 file changed, 75 insertions(+), 73 deletions(-) diff --git a/lib/pages/workspace_page.dart b/lib/pages/workspace_page.dart index d7ab0d7..8f0edb7 100644 --- a/lib/pages/workspace_page.dart +++ b/lib/pages/workspace_page.dart @@ -380,82 +380,84 @@ class _WorkspacePageState extends ConsumerState { showShadSheet( context: context, side: ShadSheetSide.left, - builder: (sheetContext) => ShadSheet( - constraints: BoxConstraints.tightFor(width: width), - padding: EdgeInsets.zero, - scrollable: false, - child: Material( - color: Colors.transparent, - child: Column( - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(12, 12, 12, 8), - child: Row( - children: [ - Expanded( - child: _SegmentButton( - icon: Icons.folder_rounded, - label: '光鸭云盘', - compact: false, - selected: _mode == WorkspaceMode.cloud, - onTap: () { - Navigator.of(sheetContext).pop(); - _changeMode(WorkspaceMode.cloud); - }, + builder: (sheetContext) => StatefulBuilder( + builder: (sheetContext, setSheetState) => ShadSheet( + constraints: BoxConstraints.tightFor(width: width), + padding: EdgeInsets.zero, + scrollable: false, + child: Material( + color: Colors.transparent, + child: Column( + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(12, 12, 12, 8), + child: Row( + children: [ + Expanded( + child: _SegmentButton( + icon: Icons.folder_rounded, + label: '光鸭云盘', + compact: false, + selected: _mode == WorkspaceMode.cloud, + onTap: () { + _changeMode(WorkspaceMode.cloud); + setSheetState(() {}); + }, + ), ), - ), - const SizedBox(width: 6), - Expanded( - child: _SegmentButton( - icon: Icons.movie_rounded, - label: '光鸭影视', - compact: false, - selected: _mode == WorkspaceMode.media, - onTap: () { - Navigator.of(sheetContext).pop(); - _changeMode(WorkspaceMode.media); - }, + const SizedBox(width: 6), + Expanded( + child: _SegmentButton( + icon: Icons.movie_rounded, + label: '光鸭影视', + compact: false, + selected: _mode == WorkspaceMode.media, + onTap: () { + _changeMode(WorkspaceMode.media); + setSheetState(() {}); + }, + ), ), - ), - ], + ], + ), ), - ), - const ShadSeparator.horizontal(), - Expanded( - child: _mode == WorkspaceMode.cloud - ? _CloudSidebar( - state: ref.read(fileProvider), - width: width, - onSection: (section) { - Navigator.of(sheetContext).pop(); - ref.read(fileProvider.notifier).setSection(section); - }, - onSettings: () { - Navigator.of(sheetContext).pop(); - _showSettings(context); - }, - onSignOut: () { - Navigator.of(sheetContext).pop(); - ref.read(authProvider.notifier).signOut(); - }, - onTool: (tool) { - Navigator.of(sheetContext).pop(); - _openTool(tool); - }, - ) - : _MediaSidebar( - width: width, - onCreate: () { - Navigator.of(sheetContext).pop(); - MediaLibraryPage.showCreateDialog(context, ref); - }, - onTool: (tool) { - Navigator.of(sheetContext).pop(); - _openTool(tool); - }, - ), - ), - ], + const ShadSeparator.horizontal(), + Expanded( + child: _mode == WorkspaceMode.cloud + ? _CloudSidebar( + state: ref.read(fileProvider), + width: width, + onSection: (section) { + Navigator.of(sheetContext).pop(); + ref.read(fileProvider.notifier).setSection(section); + }, + onSettings: () { + Navigator.of(sheetContext).pop(); + _showSettings(context); + }, + onSignOut: () { + Navigator.of(sheetContext).pop(); + ref.read(authProvider.notifier).signOut(); + }, + onTool: (tool) { + Navigator.of(sheetContext).pop(); + _openTool(tool); + }, + ) + : _MediaSidebar( + width: width, + onCreate: () { + Navigator.of(sheetContext).pop(); + MediaLibraryPage.showCreateDialog(context, ref); + }, + onTool: (tool) { + Navigator.of(sheetContext).pop(); + _openTool(tool); + }, + ), + ), + ], + ), ), ), ),