From e16a04bd5a5e06e32578bea542fe1fcc3d12c4c8 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 21 Dec 2025 02:29:43 +0800 Subject: [PATCH] :bug: Fix bugs in the new changes --- lib/screens/dashboard/dash.dart | 56 +++++++-------- lib/widgets/cmp/pattle.dart | 115 ++++++++++++++++-------------- lib/widgets/realm/realm_list.dart | 2 +- pubspec.yaml | 2 +- 4 files changed, 89 insertions(+), 86 deletions(-) diff --git a/lib/screens/dashboard/dash.dart b/lib/screens/dashboard/dash.dart index 44e1e9ed..b0208b03 100644 --- a/lib/screens/dashboard/dash.dart +++ b/lib/screens/dashboard/dash.dart @@ -8,6 +8,7 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:island/pods/chat/chat_room.dart'; import 'package:island/pods/event_calendar.dart'; +import 'package:island/pods/userinfo.dart'; import 'package:island/screens/chat/chat.dart'; import 'package:island/services/event_bus.dart'; import 'package:island/services/responsive.dart'; @@ -41,6 +42,8 @@ class DashboardGrid extends HookConsumerWidget { final isWide = isWideScreen(context); final devicePadding = MediaQuery.paddingOf(context); + final userInfo = ref.watch(userInfoProvider); + return Container( constraints: BoxConstraints( maxHeight: isWide @@ -52,6 +55,7 @@ class DashboardGrid extends HookConsumerWidget { : EdgeInsets.only(top: 24 + devicePadding.top), child: Column( spacing: 16, + mainAxisAlignment: MainAxisAlignment.center, children: [ // Clock card spans full width ClockCard().padding(horizontal: isWide ? 24 : 16), @@ -68,23 +72,26 @@ class DashboardGrid extends HookConsumerWidget { }, ), ), - Expanded( - child: - SingleChildScrollView( - padding: isWide - ? const EdgeInsets.symmetric(horizontal: 24) - : const EdgeInsets.only(bottom: 64), - scrollDirection: isWide ? Axis.horizontal : Axis.vertical, - child: isWide - ? _DashboardGridWide() - : _DashboardGridNarrow(), - ) - .clipRRect( - topLeft: isWide ? 0 : 12, - topRight: isWide ? 0 : 12, - ) - .padding(horizontal: isWide ? 0 : 16), - ), + if (userInfo.value != null) + Expanded( + child: + SingleChildScrollView( + padding: isWide + ? const EdgeInsets.symmetric(horizontal: 24) + : const EdgeInsets.only(bottom: 64), + scrollDirection: isWide + ? Axis.horizontal + : Axis.vertical, + child: isWide + ? _DashboardGridWide() + : _DashboardGridNarrow(), + ) + .clipRRect( + topLeft: isWide ? 0 : 12, + topRight: isWide ? 0 : 12, + ) + .padding(horizontal: isWide ? 0 : 16), + ), ], ), ); @@ -365,9 +372,7 @@ class NotificationsCard extends HookConsumerWidget { final notifications = ref.watch(notificationListProvider); return Card( - elevation: 4, margin: EdgeInsets.zero, - color: Theme.of(context).colorScheme.surfaceContainer, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(12)), ), @@ -454,9 +459,7 @@ class ChatListCard extends HookConsumerWidget { final chatRooms = ref.watch(chatRoomJoinedProvider); return Card( - elevation: 4, margin: EdgeInsets.zero, - color: Theme.of(context).colorScheme.surfaceContainer, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(12)), ), @@ -490,11 +493,8 @@ class ChatListCard extends HookConsumerWidget { } // Take only the first 5 rooms final recentRooms = rooms.take(5).toList(); - return ListView.builder( - shrinkWrap: true, - itemCount: recentRooms.length, - itemBuilder: (context, index) { - final room = recentRooms[index]; + return Column( + children: recentRooms.map((room) { return ChatRoomListTile( room: room, isDirect: room.type == 1, @@ -505,7 +505,7 @@ class ChatListCard extends HookConsumerWidget { ); }, ); - }, + }).toList(), ); }, ), @@ -556,9 +556,7 @@ class FortuneCard extends HookWidget { }); return Card( - elevation: 4, margin: EdgeInsets.zero, - color: Theme.of(context).colorScheme.surfaceContainer, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(12)), ), diff --git a/lib/widgets/cmp/pattle.dart b/lib/widgets/cmp/pattle.dart index 2ad6e220..e3306189 100644 --- a/lib/widgets/cmp/pattle.dart +++ b/lib/widgets/cmp/pattle.dart @@ -388,61 +388,66 @@ class CommandPattleWidget extends HookConsumerWidget { ), ], ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - SearchBar( - controller: textController, - focusNode: focusNode, - hintText: 'Search chats and pages...', - leading: CircleAvatar( - child: const Icon(Symbols.keyboard_command_key), - ).padding(horizontal: 8), - ), - AnimatedSize( - duration: const Duration(milliseconds: 200), - curve: Curves.easeOut, - child: allResults.isNotEmpty - ? ConstrainedBox( - constraints: const BoxConstraints( - maxHeight: 300, - ), - child: ListView.builder( - controller: scrollController, - shrinkWrap: true, - itemCount: allResults.length, - itemBuilder: (context, index) { - final item = allResults[index]; - if (item is SnChatRoom) { - return _ChatRoomSearchResult( - room: item, - isFocused: - index == focusedIndex.value, - onTap: () => _navigateToChat( - context, - ref, - item, - ), - ); - } else if (item is RouteItem) { - return _RouteSearchResult( - route: item, - isFocused: - index == focusedIndex.value, - onTap: () => _navigateToRoute( - context, - ref, - item, - ), - ); - } - return const SizedBox.shrink(); - }, - ), - ) - : const SizedBox.shrink(), - ), - ], + child: Material( + color: Theme.of(context).colorScheme.surface, + borderRadius: BorderRadius.circular(24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + SearchBar( + controller: textController, + focusNode: focusNode, + hintText: 'Search chats and pages...', + leading: CircleAvatar( + child: const Icon(Symbols.keyboard_command_key), + ).padding(horizontal: 8), + ), + AnimatedSize( + duration: const Duration(milliseconds: 200), + curve: Curves.easeOut, + child: allResults.isNotEmpty + ? ConstrainedBox( + constraints: const BoxConstraints( + maxHeight: 300, + ), + child: ListView.builder( + padding: EdgeInsets.zero, + controller: scrollController, + shrinkWrap: true, + itemCount: allResults.length, + itemBuilder: (context, index) { + final item = allResults[index]; + if (item is SnChatRoom) { + return _ChatRoomSearchResult( + room: item, + isFocused: + index == focusedIndex.value, + onTap: () => _navigateToChat( + context, + ref, + item, + ), + ); + } else if (item is RouteItem) { + return _RouteSearchResult( + route: item, + isFocused: + index == focusedIndex.value, + onTap: () => _navigateToRoute( + context, + ref, + item, + ), + ); + } + return const SizedBox.shrink(); + }, + ), + ) + : const SizedBox.shrink(), + ), + ], + ), ), ), ), diff --git a/lib/widgets/realm/realm_list.dart b/lib/widgets/realm/realm_list.dart index aa4f2066..a374cf25 100644 --- a/lib/widgets/realm/realm_list.dart +++ b/lib/widgets/realm/realm_list.dart @@ -54,7 +54,7 @@ class SliverRealmList extends HookConsumerWidget { itemBuilder: (context, index, realm) { return ConstrainedBox( constraints: const BoxConstraints(maxWidth: 540), - child: RealmListTile(realm: realm), + child: RealmListTile(realm: realm).padding(horizontal: 8), ).center(); }, ); diff --git a/pubspec.yaml b/pubspec.yaml index 8b1b9db6..77f6944d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 3.5.0+152 +version: 3.5.0+153 environment: sdk: ^3.8.0