чето с папками нахуевёртил

This commit is contained in:
Ваше Имя
2026-04-04 23:50:04 +07:00
parent 095155fcf9
commit f5f1c873f8
+115 -53
View File
@@ -201,8 +201,21 @@ class _ChatListScreenState extends State<ChatListScreen>
final p = await AppDatabase.loadActiveProfile(); final p = await AppDatabase.loadActiveProfile();
if (p != null) { if (p != null) {
final chats = await ChatsModule.getChats(p.id); final chats = await ChatsModule.getChats(p.id);
final folders = await FoldersModule.loadFolders(p.id); var folders = await FoldersModule.loadFolders(p.id);
final foldersKnown = await FoldersModule.hasReceivedFoldersList(p.id); final foldersKnown = await FoldersModule.hasReceivedFoldersList(p.id);
final allChatsFolder = ChatFolder(
id: 'all.chat.folder',
title: 'Все чаты',
filters: [],
hideEmpty: false,
widgets: [],
);
if (!folders.any((f) => FoldersModule.isAllChatsFolder(f))) {
folders = [allChatsFolder, ...folders];
}
final pageCount = folders.isEmpty ? 1 : folders.length; final pageCount = folders.isEmpty ? 1 : folders.length;
_syncFolderChatScrollControllersForCount(pageCount); _syncFolderChatScrollControllersForCount(pageCount);
if (mounted) { if (mounted) {
@@ -865,40 +878,75 @@ class _ChatListScreenState extends State<ChatListScreen>
), ),
), ),
), ),
AnimatedContainer( if (_folders.length > 1)
duration: const Duration(milliseconds: 300), AnimatedContainer(
curve: Curves.easeOutCubic, duration: const Duration(milliseconds: 300),
height: 48, curve: Curves.easeOutCubic,
color: cs.surface, height: 48,
child: ScrollConfiguration( color: cs.surface,
behavior: ScrollConfiguration.of(context).copyWith( child: ScrollConfiguration(
dragDevices: { behavior: ScrollConfiguration.of(context).copyWith(
ui.PointerDeviceKind.touch, dragDevices: {
ui.PointerDeviceKind.mouse, ui.PointerDeviceKind.touch,
ui.PointerDeviceKind.trackpad, ui.PointerDeviceKind.mouse,
}, ui.PointerDeviceKind.trackpad,
), },
child: _showFoldersShimmer ),
? _buildFolderStripShimmer(cs) child: _showFoldersShimmer
: ListView( ? _buildFolderStripShimmer(cs)
scrollDirection: Axis.horizontal, : LayoutBuilder(
padding: const EdgeInsets.symmetric( builder: (context, constraints) {
horizontal: 20, final availableWidth = constraints.maxWidth - 40;
vertical: 4, final folderCount = _folders.length;
final minWidthPerFolder = 80.0;
final totalMinWidth =
folderCount * minWidthPerFolder +
(folderCount - 1) * 8;
final needsScroll = totalMinWidth > availableWidth;
if (needsScroll) {
return ListView(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 4,
),
physics: const BouncingScrollPhysics(),
children: [
for (var i = 0; i < _folders.length; i++) ...[
if (i > 0) const SizedBox(width: 8),
_buildFolderChip(
_folderChipLabel(_folders[i]),
folderId: _folders[i].id,
),
],
],
);
} else {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 4,
),
child: Row(
children: [
for (var i = 0; i < _folders.length; i++) ...[
if (i > 0) const SizedBox(width: 8),
Expanded(
child: _buildFolderChip(
_folderChipLabel(_folders[i]),
folderId: _folders[i].id,
),
),
],
],
),
);
}
},
), ),
physics: const BouncingScrollPhysics(), ),
children: [
for (var i = 0; i < _folders.length; i++) ...[
if (i > 0) const SizedBox(width: 8),
_buildFolderChip(
_folderChipLabel(_folders[i]),
folderId: _folders[i].id,
),
],
],
),
), ),
),
], ],
), ),
); );
@@ -907,6 +955,7 @@ class _ChatListScreenState extends State<ChatListScreen>
Widget _buildFolderChatPage(int pageIndex) { Widget _buildFolderChatPage(int pageIndex) {
final chats = _chatsForPageIndex(pageIndex); final chats = _chatsForPageIndex(pageIndex);
final sc = _folderChatScrollControllers[pageIndex]; final sc = _folderChatScrollControllers[pageIndex];
final cs = Theme.of(context).colorScheme;
return NotificationListener<ScrollNotification>( return NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification n) { onNotification: (ScrollNotification n) {
if (_currentNavIndex != 0) return false; if (_currentNavIndex != 0) return false;
@@ -931,26 +980,39 @@ class _ChatListScreenState extends State<ChatListScreen>
parent: const AlwaysScrollableScrollPhysics(), parent: const AlwaysScrollableScrollPhysics(),
), ),
slivers: [ slivers: [
SliverList( if (chats.isEmpty && !_isInitialLoading)
delegate: SliverChildBuilderDelegate((context, index) { SliverFillRemaining(
if (_isInitialLoading) { child: Center(
return _buildChatShimmer(); child: Text(
} 'Кажется, тут пусто...',
final chat = chats[index]; style: TextStyle(
return _buildChatItem( color: cs.onSurface.withOpacity(0.6),
chat.id.toString(), fontSize: 16,
chat.title ?? 'Чат', ),
chat.lastMsgText ?? '', ),
_formatTime(chat.lastMsgTime), ),
(chat.iconUrl != null && chat.iconUrl!.isNotEmpty) )
? chat.iconUrl! else
: '', SliverList(
isOnline: chat.isOnline, delegate: SliverChildBuilderDelegate((context, index) {
unreadCount: chat.unreadCount, if (_isInitialLoading) {
isMuted: chat.dontDisturbUntil > 0, return _buildChatShimmer();
); }
}, childCount: _isInitialLoading ? 10 : chats.length), final chat = chats[index];
), return _buildChatItem(
chat.id.toString(),
chat.title ?? 'Чат',
chat.lastMsgText ?? '',
_formatTime(chat.lastMsgTime),
(chat.iconUrl != null && chat.iconUrl!.isNotEmpty)
? chat.iconUrl!
: '',
isOnline: chat.isOnline,
unreadCount: chat.unreadCount,
isMuted: chat.dontDisturbUntil > 0,
);
}, childCount: _isInitialLoading ? 10 : chats.length),
),
SliverPadding( SliverPadding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: MediaQuery.viewPaddingOf(context).bottom + 100, bottom: MediaQuery.viewPaddingOf(context).bottom + 100,