From 33686b83e32ffa40588d182a6c16c48be0b5d176 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 22 Dec 2025 23:31:40 +0800 Subject: [PATCH] :lipstick: Dynamic hide pinned chat if no need --- lib/screens/chat/chat.dart | 65 +++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/lib/screens/chat/chat.dart b/lib/screens/chat/chat.dart index 07e1de12..14f3d306 100644 --- a/lib/screens/chat/chat.dart +++ b/lib/screens/chat/chat.dart @@ -79,38 +79,39 @@ class ChatListBodyWidget extends HookConsumerWidget { child: Column( children: [ // Always show pinned chats in their own section - ExpansionTile( - backgroundColor: Theme.of( - context, - ).colorScheme.surfaceContainer.withOpacity(0.5), - collapsedBackgroundColor: Theme.of( - context, - ).colorScheme.surfaceContainer.withOpacity(0.5), - title: Text('pinnedChatRoom'.tr()), - leading: const Icon(Symbols.keep, fill: 1), - tilePadding: const EdgeInsets.symmetric(horizontal: 24), - initiallyExpanded: true, - children: [ - for (final item in pinnedItems) - ChatRoomListTile( - room: item, - isDirect: item.type == 1, - onTap: () { - if (isWideScreen(context)) { - context.replaceNamed( - 'chatRoom', - pathParameters: {'id': item.id}, - ); - } else { - context.pushNamed( - 'chatRoom', - pathParameters: {'id': item.id}, - ); - } - }, - ), - ], - ), + if (pinnedItems.isNotEmpty) + ExpansionTile( + backgroundColor: Theme.of( + context, + ).colorScheme.surfaceContainer.withOpacity(0.5), + collapsedBackgroundColor: Theme.of( + context, + ).colorScheme.surfaceContainer.withOpacity(0.5), + title: Text('pinnedChatRoom'.tr()), + leading: const Icon(Symbols.keep, fill: 1), + tilePadding: const EdgeInsets.symmetric(horizontal: 24), + initiallyExpanded: true, + children: [ + for (final item in pinnedItems) + ChatRoomListTile( + room: item, + isDirect: item.type == 1, + onTap: () { + if (isWideScreen(context)) { + context.replaceNamed( + 'chatRoom', + pathParameters: {'id': item.id}, + ); + } else { + context.pushNamed( + 'chatRoom', + pathParameters: {'id': item.id}, + ); + } + }, + ), + ], + ), Expanded( child: Consumer( builder: (context, ref, _) {