chore: follow up fix

This commit is contained in:
Krille Fear 2022-12-26 16:02:45 +01:00
parent 7cdeb98671
commit 8f89d539d0
2 changed files with 378 additions and 390 deletions

View File

@ -10,6 +10,7 @@ import 'package:fluffychat/pages/chat_list/chat_list_item.dart';
import 'package:fluffychat/pages/chat_list/search_title.dart';
import 'package:fluffychat/pages/chat_list/space_view.dart';
import 'package:fluffychat/pages/chat_list/stories_header.dart';
import 'package:fluffychat/utils/stream_extension.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/profile_bottom_sheet.dart';
import 'package:fluffychat/widgets/public_room_bottom_sheet.dart';
@ -41,7 +42,14 @@ class ChatListViewBody extends StatelessWidget {
child: child,
);
},
child: Builder(builder: (context) {
child: StreamBuilder(
key: ValueKey(client.userID.toString() +
controller.activeFilter.toString() +
controller.activeSpaceId.toString()),
stream: client.onSync.stream
.where((s) => s.hasRoomUpdate)
.rateLimit(const Duration(seconds: 1)),
builder: (context, _) {
if (controller.activeFilter == ActiveFilter.spaces &&
!controller.isSearchMode) {
return SpaceView(
@ -87,8 +95,8 @@ class ChatListViewBody extends StatelessWidget {
onPressed: () => showModalBottomSheet(
context: context,
builder: (c) => PublicRoomBottomSheet(
roomAlias:
roomSearchResult.chunk[i].canonicalAlias ??
roomAlias: roomSearchResult
.chunk[i].canonicalAlias ??
roomSearchResult.chunk[i].roomId,
outerContext: context,
chunk: roomSearchResult.chunk[i],
@ -112,8 +120,10 @@ class ChatListViewBody extends StatelessWidget {
scrollDirection: Axis.horizontal,
itemCount: userSearchResult.results.length,
itemBuilder: (context, i) => _SearchItem(
title: userSearchResult.results[i].displayName ??
userSearchResult.results[i].userId.localpart ??
title:
userSearchResult.results[i].displayName ??
userSearchResult
.results[i].userId.localpart ??
L10n.of(context)!.unknownDevice,
avatar: userSearchResult.results[i].avatarUrl,
onPressed: () => showModalBottomSheet(
@ -149,8 +159,10 @@ class ChatListViewBody extends StatelessWidget {
child: ListTile(
leading: const Icon(Icons.vpn_key),
title: Text(L10n.of(context)!.dehydrateTor),
subtitle: Text(L10n.of(context)!.dehydrateTorLong),
trailing: const Icon(Icons.chevron_right_outlined),
subtitle:
Text(L10n.of(context)!.dehydrateTorLong),
trailing:
const Icon(Icons.chevron_right_outlined),
onTap: controller.dehydrate,
),
),
@ -172,7 +184,9 @@ class ChatListViewBody extends StatelessWidget {
),
Divider(
height: 1,
color: Theme.of(context).colorScheme.onBackground,
color: Theme.of(context)
.colorScheme
.onBackground,
),
const SizedBox(height: 32),
FloatingActionButton.extended(
@ -192,10 +206,8 @@ class ChatListViewBody extends StatelessWidget {
);
}
i--;
if (!rooms[i]
.displayname
.toLowerCase()
.contains(controller.searchController.text.toLowerCase())) {
if (!rooms[i].displayname.toLowerCase().contains(
controller.searchController.text.toLowerCase())) {
return Container();
}
return ChatListItem(

View File

@ -4,13 +4,11 @@ import 'package:flutter/services.dart';
import 'package:badges/badges.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
import 'package:matrix/matrix.dart';
import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:fluffychat/utils/stream_extension.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/unread_rooms_badge.dart';
import '../../widgets/matrix.dart';
@ -105,21 +103,12 @@ class ChatListView extends StatelessWidget {
return;
}
},
child: StreamBuilder<Object>(
key: ValueKey(client.userID.toString() +
controller.activeFilter.toString() +
controller.activeSpaceId.toString()),
stream: client.onSync.stream
.where((s) => s.hasRoomUpdate)
.rateLimit(const Duration(seconds: 1)),
builder: (context, snapshot) {
return Row(
child: Row(
children: [
if (FluffyThemes.isColumnMode(context) &&
FluffyThemes.getDisplayNavigationRail(context)) ...[
Builder(builder: (context) {
final allSpaces =
client.rooms.where((room) => room.isSpace);
final allSpaces = client.rooms.where((room) => room.isSpace);
final rootSpaces = allSpaces
.where(
(space) => !allSpaces.any(
@ -137,8 +126,7 @@ class ChatListView extends StatelessWidget {
itemCount: rootSpaces.length + destinations.length,
itemBuilder: (context, i) {
if (i < destinations.length) {
final isSelected =
i == controller.selectedIndex;
final isSelected = i == controller.selectedIndex;
return Container(
height: 64,
width: 64,
@ -147,15 +135,12 @@ class ChatListView extends StatelessWidget {
bottom: i == (destinations.length - 1)
? BorderSide(
width: 1,
color: Theme.of(context)
.dividerColor,
color: Theme.of(context).dividerColor,
)
: BorderSide.none,
left: BorderSide(
color: isSelected
? Theme.of(context)
.colorScheme
.primary
? Theme.of(context).colorScheme.primary
: Colors.transparent,
width: 4,
),
@ -168,15 +153,11 @@ class ChatListView extends StatelessWidget {
alignment: Alignment.center,
child: IconButton(
color: isSelected
? Theme.of(context)
.colorScheme
.secondary
? Theme.of(context).colorScheme.secondary
: null,
icon: CircleAvatar(
backgroundColor: isSelected
? Theme.of(context)
.colorScheme
.secondary
? Theme.of(context).colorScheme.secondary
: Theme.of(context)
.colorScheme
.background,
@ -198,8 +179,8 @@ class ChatListView extends StatelessWidget {
);
}
i -= destinations.length;
final isSelected = controller.activeFilter ==
ActiveFilter.spaces &&
final isSelected =
controller.activeFilter == ActiveFilter.spaces &&
rootSpaces[i].id == controller.activeSpaceId;
return Container(
height: 64,
@ -208,9 +189,7 @@ class ChatListView extends StatelessWidget {
border: Border(
left: BorderSide(
color: isSelected
? Theme.of(context)
.colorScheme
.secondary
? Theme.of(context).colorScheme.secondary
: Colors.transparent,
width: 4,
),
@ -229,8 +208,8 @@ class ChatListView extends StatelessWidget {
size: 32,
fontSize: 12,
),
onPressed: () => controller
.setActiveSpace(rootSpaces[i].id),
onPressed: () =>
controller.setActiveSpace(rootSpaces[i].id),
),
);
},
@ -252,12 +231,10 @@ class ChatListView extends StatelessWidget {
selectedIndex: controller.selectedIndex,
onDestinationSelected:
controller.onDestinationSelected,
destinations:
getNavigationDestinations(context),
destinations: getNavigationDestinations(context),
)
: null,
floatingActionButton: controller
.filteredRooms.isNotEmpty &&
floatingActionButton: controller.filteredRooms.isNotEmpty &&
selectMode == SelectMode.normal
? KeyBoardShortcuts(
keysToPress: {
@ -274,8 +251,7 @@ class ChatListView extends StatelessWidget {
),
),
],
);
}),
),
);
},
);