From aeea90226afcfa3054a78e3171cea65bbbb2152b Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 17 Jan 2026 16:02:56 +0800 Subject: [PATCH] :bug: Fix some bugs in dashboard --- lib/screens/dashboard/dash.dart | 44 +++++++++++++++-------- lib/screens/dashboard/dash_customize.dart | 2 +- lib/widgets/post/post_featured.dart | 5 +-- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/lib/screens/dashboard/dash.dart b/lib/screens/dashboard/dash.dart index 5050416e..6e66405b 100644 --- a/lib/screens/dashboard/dash.dart +++ b/lib/screens/dashboard/dash.dart @@ -117,7 +117,14 @@ class DashboardRenderer { case 'postsColumn': return SizedBox( width: 400, - child: PostFeaturedList(collapsable: false), + child: LayoutBuilder( + builder: (context, constraints) { + return PostFeaturedList( + collapsable: false, + maxHeight: constraints.maxHeight, + ); + }, + ), ); case 'socialColumn': return SizedBox( @@ -153,6 +160,7 @@ class DashboardGrid extends HookConsumerWidget { final devicePadding = MediaQuery.paddingOf(context); final userInfo = ref.watch(userInfoProvider); + final appSettings = ref.watch(appSettingsProvider); final dragging = useState(false); @@ -185,26 +193,32 @@ class DashboardGrid extends HookConsumerWidget { spacing: 16, mainAxisAlignment: MainAxisAlignment.center, children: [ - // Clock card spans full width - if (isWide) + // Clock card spans full width (only if enabled in settings) + if (isWide && + (appSettings.dashboardConfig?.showClockAndCountdown ?? + true)) ClockCard().padding(horizontal: 24) - else + else if (!isWide) Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Gap(8), - Expanded(child: ClockCard(compact: true)), - IconButton( - onPressed: () { - eventBus.fire(CommandPaletteTriggerEvent()); - }, - icon: const Icon(Symbols.search), - tooltip: 'searchAnything'.tr(), - ), + if (appSettings.dashboardConfig?.showClockAndCountdown ?? + true) + Expanded(child: ClockCard(compact: true)), + if (appSettings.dashboardConfig?.showSearchBar ?? true) + IconButton( + onPressed: () { + eventBus.fire(CommandPaletteTriggerEvent()); + }, + icon: const Icon(Symbols.search), + tooltip: 'searchAnything'.tr(), + ), ], ).padding(horizontal: 24), - // Row with two cards side by side - if (isWide) + // Row with two cards side by side (only if enabled in settings) + if (isWide && + (appSettings.dashboardConfig?.showSearchBar ?? true)) Padding( padding: EdgeInsets.symmetric(horizontal: isWide ? 24 : 16), child: SearchBar( @@ -250,7 +264,7 @@ class DashboardGrid extends HookConsumerWidget { ), // Customize button Positioned( - bottom: 16, + bottom: isWide ? 16 : 16 + devicePadding.bottom, right: 16, child: TextButton.icon( onPressed: () { diff --git a/lib/screens/dashboard/dash_customize.dart b/lib/screens/dashboard/dash_customize.dart index 4ca0f7d4..df43517a 100644 --- a/lib/screens/dashboard/dash_customize.dart +++ b/lib/screens/dashboard/dash_customize.dart @@ -285,7 +285,7 @@ class DashboardCustomizationSheet extends HookConsumerWidget { if (availableCards.isNotEmpty) SliverToBoxAdapter( child: Container( - padding: const EdgeInsets.all(16), + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/widgets/post/post_featured.dart b/lib/widgets/post/post_featured.dart index 4e3aaeff..f2b658d3 100644 --- a/lib/widgets/post/post_featured.dart +++ b/lib/widgets/post/post_featured.dart @@ -22,7 +22,8 @@ Future> featuredPosts(Ref ref) async { class PostFeaturedList extends HookConsumerWidget { final bool collapsable; - const PostFeaturedList({super.key, this.collapsable = true}); + final double? maxHeight; + const PostFeaturedList({super.key, this.collapsable = true, this.maxHeight}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -178,7 +179,7 @@ class PostFeaturedList extends HookConsumerWidget { error: (error, stack) => Center(child: Text('Error: $error')), data: (posts) { return SizedBox( - height: 344, + height: maxHeight == null ? 344 : (maxHeight! - 48), child: PageView.builder( controller: pageViewController, scrollDirection: Axis.horizontal,