From bc8cdf07ddbe51c91e8ac36c34a03b6445e19622 Mon Sep 17 00:00:00 2001 From: ngfchl Date: Sun, 19 Jul 2026 13:37:54 +0800 Subject: [PATCH] bound shad sidebar tile width --- lib/pages/workspace_page.dart | 97 ++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/lib/pages/workspace_page.dart b/lib/pages/workspace_page.dart index 174d40e..51ea7e8 100644 --- a/lib/pages/workspace_page.dart +++ b/lib/pages/workspace_page.dart @@ -1862,57 +1862,62 @@ class _SidebarTile extends StatelessWidget { final cs = ShadTheme.of(context).colorScheme; return Padding( padding: const EdgeInsets.only(bottom: 6), - child: ShadButton.ghost( - width: double.infinity, - height: 42, - padding: EdgeInsets.zero, - onPressed: onTap, - child: AnimatedContainer( - duration: const Duration(milliseconds: 140), + child: LayoutBuilder( + builder: (context, constraints) => ShadButton.ghost( + // ShadButton treats double.infinity as an unbounded ConstrainedBox. + // Its label row contains Expanded, so always pass a real width. + width: constraints.maxWidth.isFinite ? constraints.maxWidth : 220, height: 42, - padding: const EdgeInsets.symmetric(horizontal: 9), - decoration: BoxDecoration( - color: selected - ? const Color(0xFFFFB18A).withValues(alpha: 0.72) - : Colors.transparent, - borderRadius: BorderRadius.circular(10), - ), - child: Row( - children: [ - Container( - width: 28, - height: 28, - decoration: BoxDecoration( - color: selected - ? Colors.white.withValues(alpha: 0.36) - : const Color(0xFFFFE4D2).withValues(alpha: 0.82), - borderRadius: BorderRadius.circular(8), + expands: false, + padding: EdgeInsets.zero, + onPressed: onTap, + child: AnimatedContainer( + duration: const Duration(milliseconds: 140), + height: 42, + padding: const EdgeInsets.symmetric(horizontal: 9), + decoration: BoxDecoration( + color: selected + ? const Color(0xFFFFB18A).withValues(alpha: 0.72) + : Colors.transparent, + borderRadius: BorderRadius.circular(10), + ), + child: Row( + children: [ + Container( + width: 28, + height: 28, + decoration: BoxDecoration( + color: selected + ? Colors.white.withValues(alpha: 0.36) + : const Color(0xFFFFE4D2).withValues(alpha: 0.82), + borderRadius: BorderRadius.circular(8), + ), + child: Icon(icon, size: 17, color: cs.primary), ), - child: Icon(icon, size: 17, color: cs.primary), - ), - const SizedBox(width: 10), - Expanded( - child: Text( - label, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 13, - fontWeight: selected ? FontWeight.w800 : FontWeight.w600, - color: selected ? cs.foreground : cs.mutedForeground, + const SizedBox(width: 10), + Expanded( + child: Text( + label, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 13, + fontWeight: selected ? FontWeight.w800 : FontWeight.w600, + color: selected ? cs.foreground : cs.mutedForeground, + ), ), ), - ), - if (count != null) - Text( - count.toString(), - style: TextStyle( - fontSize: 11, - fontWeight: FontWeight.w700, - color: cs.mutedForeground, + if (count != null) + Text( + count.toString(), + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w700, + color: cs.mutedForeground, + ), ), - ), - ], + ], + ), ), ), ),