🐛 Fix some bugs in dashboard

This commit is contained in:
2026-01-17 16:02:56 +08:00
parent c36a5eaa73
commit aeea90226a
3 changed files with 33 additions and 18 deletions

View File

@@ -117,7 +117,14 @@ class DashboardRenderer {
case 'postsColumn': case 'postsColumn':
return SizedBox( return SizedBox(
width: 400, width: 400,
child: PostFeaturedList(collapsable: false), child: LayoutBuilder(
builder: (context, constraints) {
return PostFeaturedList(
collapsable: false,
maxHeight: constraints.maxHeight,
);
},
),
); );
case 'socialColumn': case 'socialColumn':
return SizedBox( return SizedBox(
@@ -153,6 +160,7 @@ class DashboardGrid extends HookConsumerWidget {
final devicePadding = MediaQuery.paddingOf(context); final devicePadding = MediaQuery.paddingOf(context);
final userInfo = ref.watch(userInfoProvider); final userInfo = ref.watch(userInfoProvider);
final appSettings = ref.watch(appSettingsProvider);
final dragging = useState(false); final dragging = useState(false);
@@ -185,26 +193,32 @@ class DashboardGrid extends HookConsumerWidget {
spacing: 16, spacing: 16,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
// Clock card spans full width // Clock card spans full width (only if enabled in settings)
if (isWide) if (isWide &&
(appSettings.dashboardConfig?.showClockAndCountdown ??
true))
ClockCard().padding(horizontal: 24) ClockCard().padding(horizontal: 24)
else else if (!isWide)
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
const Gap(8), const Gap(8),
Expanded(child: ClockCard(compact: true)), if (appSettings.dashboardConfig?.showClockAndCountdown ??
IconButton( true)
onPressed: () { Expanded(child: ClockCard(compact: true)),
eventBus.fire(CommandPaletteTriggerEvent()); if (appSettings.dashboardConfig?.showSearchBar ?? true)
}, IconButton(
icon: const Icon(Symbols.search), onPressed: () {
tooltip: 'searchAnything'.tr(), eventBus.fire(CommandPaletteTriggerEvent());
), },
icon: const Icon(Symbols.search),
tooltip: 'searchAnything'.tr(),
),
], ],
).padding(horizontal: 24), ).padding(horizontal: 24),
// Row with two cards side by side // Row with two cards side by side (only if enabled in settings)
if (isWide) if (isWide &&
(appSettings.dashboardConfig?.showSearchBar ?? true))
Padding( Padding(
padding: EdgeInsets.symmetric(horizontal: isWide ? 24 : 16), padding: EdgeInsets.symmetric(horizontal: isWide ? 24 : 16),
child: SearchBar( child: SearchBar(
@@ -250,7 +264,7 @@ class DashboardGrid extends HookConsumerWidget {
), ),
// Customize button // Customize button
Positioned( Positioned(
bottom: 16, bottom: isWide ? 16 : 16 + devicePadding.bottom,
right: 16, right: 16,
child: TextButton.icon( child: TextButton.icon(
onPressed: () { onPressed: () {

View File

@@ -285,7 +285,7 @@ class DashboardCustomizationSheet extends HookConsumerWidget {
if (availableCards.isNotEmpty) if (availableCards.isNotEmpty)
SliverToBoxAdapter( SliverToBoxAdapter(
child: Container( child: Container(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [

View File

@@ -22,7 +22,8 @@ Future<List<SnPost>> featuredPosts(Ref ref) async {
class PostFeaturedList extends HookConsumerWidget { class PostFeaturedList extends HookConsumerWidget {
final bool collapsable; final bool collapsable;
const PostFeaturedList({super.key, this.collapsable = true}); final double? maxHeight;
const PostFeaturedList({super.key, this.collapsable = true, this.maxHeight});
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
@@ -178,7 +179,7 @@ class PostFeaturedList extends HookConsumerWidget {
error: (error, stack) => Center(child: Text('Error: $error')), error: (error, stack) => Center(child: Text('Error: $error')),
data: (posts) { data: (posts) {
return SizedBox( return SizedBox(
height: 344, height: maxHeight == null ? 344 : (maxHeight! - 48),
child: PageView.builder( child: PageView.builder(
controller: pageViewController, controller: pageViewController,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,