mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 06:52:35 +01:00
chore: follow up fix
This commit is contained in:
parent
7cdeb98671
commit
8f89d539d0
@ -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/search_title.dart';
|
||||||
import 'package:fluffychat/pages/chat_list/space_view.dart';
|
import 'package:fluffychat/pages/chat_list/space_view.dart';
|
||||||
import 'package:fluffychat/pages/chat_list/stories_header.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/avatar.dart';
|
||||||
import 'package:fluffychat/widgets/profile_bottom_sheet.dart';
|
import 'package:fluffychat/widgets/profile_bottom_sheet.dart';
|
||||||
import 'package:fluffychat/widgets/public_room_bottom_sheet.dart';
|
import 'package:fluffychat/widgets/public_room_bottom_sheet.dart';
|
||||||
@ -41,237 +42,248 @@ class ChatListViewBody extends StatelessWidget {
|
|||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Builder(builder: (context) {
|
child: StreamBuilder(
|
||||||
if (controller.activeFilter == ActiveFilter.spaces &&
|
key: ValueKey(client.userID.toString() +
|
||||||
!controller.isSearchMode) {
|
controller.activeFilter.toString() +
|
||||||
return SpaceView(
|
controller.activeSpaceId.toString()),
|
||||||
controller,
|
stream: client.onSync.stream
|
||||||
scrollController: controller.scrollController,
|
.where((s) => s.hasRoomUpdate)
|
||||||
key: Key(controller.activeSpaceId ?? 'Spaces'),
|
.rateLimit(const Duration(seconds: 1)),
|
||||||
);
|
builder: (context, _) {
|
||||||
}
|
if (controller.activeFilter == ActiveFilter.spaces &&
|
||||||
if (controller.waitForFirstSync && client.prevBatch != null) {
|
!controller.isSearchMode) {
|
||||||
final rooms = controller.filteredRooms;
|
return SpaceView(
|
||||||
final displayStoriesHeader = {
|
controller,
|
||||||
ActiveFilter.allChats,
|
scrollController: controller.scrollController,
|
||||||
ActiveFilter.messages,
|
key: Key(controller.activeSpaceId ?? 'Spaces'),
|
||||||
}.contains(controller.activeFilter);
|
|
||||||
return ListView.builder(
|
|
||||||
controller: controller.scrollController,
|
|
||||||
// add +1 space below in order to properly scroll below the spaces bar
|
|
||||||
itemCount: rooms.length + 1,
|
|
||||||
itemBuilder: (BuildContext context, int i) {
|
|
||||||
if (i == 0) {
|
|
||||||
return Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
if (roomSearchResult != null) ...[
|
|
||||||
SearchTitle(
|
|
||||||
title: L10n.of(context)!.publicRooms,
|
|
||||||
icon: const Icon(Icons.explore_outlined),
|
|
||||||
),
|
|
||||||
AnimatedContainer(
|
|
||||||
height: roomSearchResult.chunk.isEmpty ? 0 : 106,
|
|
||||||
duration: const Duration(milliseconds: 250),
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
decoration: const BoxDecoration(),
|
|
||||||
child: ListView.builder(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
itemCount: roomSearchResult.chunk.length,
|
|
||||||
itemBuilder: (context, i) => _SearchItem(
|
|
||||||
title: roomSearchResult.chunk[i].name ??
|
|
||||||
roomSearchResult
|
|
||||||
.chunk[i].canonicalAlias?.localpart ??
|
|
||||||
L10n.of(context)!.group,
|
|
||||||
avatar: roomSearchResult.chunk[i].avatarUrl,
|
|
||||||
onPressed: () => showModalBottomSheet(
|
|
||||||
context: context,
|
|
||||||
builder: (c) => PublicRoomBottomSheet(
|
|
||||||
roomAlias:
|
|
||||||
roomSearchResult.chunk[i].canonicalAlias ??
|
|
||||||
roomSearchResult.chunk[i].roomId,
|
|
||||||
outerContext: context,
|
|
||||||
chunk: roomSearchResult.chunk[i],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
if (userSearchResult != null) ...[
|
|
||||||
SearchTitle(
|
|
||||||
title: L10n.of(context)!.users,
|
|
||||||
icon: const Icon(Icons.group_outlined),
|
|
||||||
),
|
|
||||||
AnimatedContainer(
|
|
||||||
height: userSearchResult.results.isEmpty ? 0 : 106,
|
|
||||||
duration: const Duration(milliseconds: 250),
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
decoration: const BoxDecoration(),
|
|
||||||
child: ListView.builder(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
itemCount: userSearchResult.results.length,
|
|
||||||
itemBuilder: (context, i) => _SearchItem(
|
|
||||||
title: userSearchResult.results[i].displayName ??
|
|
||||||
userSearchResult.results[i].userId.localpart ??
|
|
||||||
L10n.of(context)!.unknownDevice,
|
|
||||||
avatar: userSearchResult.results[i].avatarUrl,
|
|
||||||
onPressed: () => showModalBottomSheet(
|
|
||||||
context: context,
|
|
||||||
builder: (c) => ProfileBottomSheet(
|
|
||||||
userId: userSearchResult.results[i].userId,
|
|
||||||
outerContext: context,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
if (controller.isSearchMode)
|
|
||||||
SearchTitle(
|
|
||||||
title: L10n.of(context)!.stories,
|
|
||||||
icon: const Icon(Icons.camera_alt_outlined),
|
|
||||||
),
|
|
||||||
if (displayStoriesHeader)
|
|
||||||
StoriesHeader(
|
|
||||||
key: const Key('stories_header'),
|
|
||||||
filter: controller.searchController.text,
|
|
||||||
),
|
|
||||||
const ConnectionStatusHeader(),
|
|
||||||
AnimatedContainer(
|
|
||||||
height: controller.isTorBrowser ? 64 : 0,
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
curve: Curves.bounceInOut,
|
|
||||||
decoration: const BoxDecoration(),
|
|
||||||
child: Material(
|
|
||||||
color: Theme.of(context).colorScheme.surface,
|
|
||||||
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),
|
|
||||||
onTap: controller.dehydrate,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (controller.isSearchMode)
|
|
||||||
SearchTitle(
|
|
||||||
title: L10n.of(context)!.chats,
|
|
||||||
icon: const Icon(Icons.chat_outlined),
|
|
||||||
),
|
|
||||||
if (rooms.isEmpty && !controller.isSearchMode)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(32.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 32),
|
|
||||||
Image.asset(
|
|
||||||
'assets/start_chat.png',
|
|
||||||
),
|
|
||||||
Divider(
|
|
||||||
height: 1,
|
|
||||||
color: Theme.of(context).colorScheme.onBackground,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 32),
|
|
||||||
FloatingActionButton.extended(
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).colorScheme.primary,
|
|
||||||
foregroundColor:
|
|
||||||
Theme.of(context).colorScheme.onPrimary,
|
|
||||||
icon: const Icon(Icons.edit_outlined),
|
|
||||||
onPressed: () =>
|
|
||||||
VRouter.of(context).to('/newprivatechat'),
|
|
||||||
label: Text(L10n.of(context)!.startFirstChat),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
i--;
|
|
||||||
if (!rooms[i]
|
|
||||||
.displayname
|
|
||||||
.toLowerCase()
|
|
||||||
.contains(controller.searchController.text.toLowerCase())) {
|
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
return ChatListItem(
|
|
||||||
rooms[i],
|
|
||||||
key: Key('chat_list_item_${rooms[i].id}'),
|
|
||||||
selected: controller.selectedRoomIds.contains(rooms[i].id),
|
|
||||||
onTap: controller.selectMode == SelectMode.select
|
|
||||||
? () => controller.toggleSelection(rooms[i].id)
|
|
||||||
: null,
|
|
||||||
onLongPress: () => controller.toggleSelection(rooms[i].id),
|
|
||||||
activeChat: controller.activeChat == rooms[i].id,
|
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
);
|
if (controller.waitForFirstSync && client.prevBatch != null) {
|
||||||
}
|
final rooms = controller.filteredRooms;
|
||||||
const dummyChatCount = 5;
|
final displayStoriesHeader = {
|
||||||
final titleColor =
|
ActiveFilter.allChats,
|
||||||
Theme.of(context).textTheme.bodyText1!.color!.withAlpha(100);
|
ActiveFilter.messages,
|
||||||
final subtitleColor =
|
}.contains(controller.activeFilter);
|
||||||
Theme.of(context).textTheme.bodyText1!.color!.withAlpha(50);
|
return ListView.builder(
|
||||||
return ListView.builder(
|
controller: controller.scrollController,
|
||||||
key: const Key('dummychats'),
|
// add +1 space below in order to properly scroll below the spaces bar
|
||||||
itemCount: dummyChatCount,
|
itemCount: rooms.length + 1,
|
||||||
itemBuilder: (context, i) => Opacity(
|
itemBuilder: (BuildContext context, int i) {
|
||||||
opacity: (dummyChatCount - i) / dummyChatCount,
|
if (i == 0) {
|
||||||
child: ListTile(
|
return Column(
|
||||||
leading: CircleAvatar(
|
mainAxisSize: MainAxisSize.min,
|
||||||
backgroundColor: titleColor,
|
children: [
|
||||||
child: CircularProgressIndicator(
|
if (roomSearchResult != null) ...[
|
||||||
strokeWidth: 1,
|
SearchTitle(
|
||||||
color: Theme.of(context).textTheme.bodyText1!.color,
|
title: L10n.of(context)!.publicRooms,
|
||||||
),
|
icon: const Icon(Icons.explore_outlined),
|
||||||
),
|
),
|
||||||
title: Row(
|
AnimatedContainer(
|
||||||
children: [
|
height: roomSearchResult.chunk.isEmpty ? 0 : 106,
|
||||||
Expanded(
|
duration: const Duration(milliseconds: 250),
|
||||||
child: Container(
|
clipBehavior: Clip.hardEdge,
|
||||||
height: 14,
|
decoration: const BoxDecoration(),
|
||||||
decoration: BoxDecoration(
|
child: ListView.builder(
|
||||||
color: titleColor,
|
scrollDirection: Axis.horizontal,
|
||||||
borderRadius: BorderRadius.circular(3),
|
itemCount: roomSearchResult.chunk.length,
|
||||||
|
itemBuilder: (context, i) => _SearchItem(
|
||||||
|
title: roomSearchResult.chunk[i].name ??
|
||||||
|
roomSearchResult
|
||||||
|
.chunk[i].canonicalAlias?.localpart ??
|
||||||
|
L10n.of(context)!.group,
|
||||||
|
avatar: roomSearchResult.chunk[i].avatarUrl,
|
||||||
|
onPressed: () => showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (c) => PublicRoomBottomSheet(
|
||||||
|
roomAlias: roomSearchResult
|
||||||
|
.chunk[i].canonicalAlias ??
|
||||||
|
roomSearchResult.chunk[i].roomId,
|
||||||
|
outerContext: context,
|
||||||
|
chunk: roomSearchResult.chunk[i],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (userSearchResult != null) ...[
|
||||||
|
SearchTitle(
|
||||||
|
title: L10n.of(context)!.users,
|
||||||
|
icon: const Icon(Icons.group_outlined),
|
||||||
|
),
|
||||||
|
AnimatedContainer(
|
||||||
|
height: userSearchResult.results.isEmpty ? 0 : 106,
|
||||||
|
duration: const Duration(milliseconds: 250),
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
decoration: const BoxDecoration(),
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: userSearchResult.results.length,
|
||||||
|
itemBuilder: (context, i) => _SearchItem(
|
||||||
|
title:
|
||||||
|
userSearchResult.results[i].displayName ??
|
||||||
|
userSearchResult
|
||||||
|
.results[i].userId.localpart ??
|
||||||
|
L10n.of(context)!.unknownDevice,
|
||||||
|
avatar: userSearchResult.results[i].avatarUrl,
|
||||||
|
onPressed: () => showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (c) => ProfileBottomSheet(
|
||||||
|
userId: userSearchResult.results[i].userId,
|
||||||
|
outerContext: context,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (controller.isSearchMode)
|
||||||
|
SearchTitle(
|
||||||
|
title: L10n.of(context)!.stories,
|
||||||
|
icon: const Icon(Icons.camera_alt_outlined),
|
||||||
|
),
|
||||||
|
if (displayStoriesHeader)
|
||||||
|
StoriesHeader(
|
||||||
|
key: const Key('stories_header'),
|
||||||
|
filter: controller.searchController.text,
|
||||||
|
),
|
||||||
|
const ConnectionStatusHeader(),
|
||||||
|
AnimatedContainer(
|
||||||
|
height: controller.isTorBrowser ? 64 : 0,
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
curve: Curves.bounceInOut,
|
||||||
|
decoration: const BoxDecoration(),
|
||||||
|
child: Material(
|
||||||
|
color: Theme.of(context).colorScheme.surface,
|
||||||
|
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),
|
||||||
|
onTap: controller.dehydrate,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (controller.isSearchMode)
|
||||||
|
SearchTitle(
|
||||||
|
title: L10n.of(context)!.chats,
|
||||||
|
icon: const Icon(Icons.chat_outlined),
|
||||||
|
),
|
||||||
|
if (rooms.isEmpty && !controller.isSearchMode)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(32.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
Image.asset(
|
||||||
|
'assets/start_chat.png',
|
||||||
|
),
|
||||||
|
Divider(
|
||||||
|
height: 1,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onBackground,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
FloatingActionButton.extended(
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).colorScheme.primary,
|
||||||
|
foregroundColor:
|
||||||
|
Theme.of(context).colorScheme.onPrimary,
|
||||||
|
icon: const Icon(Icons.edit_outlined),
|
||||||
|
onPressed: () =>
|
||||||
|
VRouter.of(context).to('/newprivatechat'),
|
||||||
|
label: Text(L10n.of(context)!.startFirstChat),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
i--;
|
||||||
|
if (!rooms[i].displayname.toLowerCase().contains(
|
||||||
|
controller.searchController.text.toLowerCase())) {
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
return ChatListItem(
|
||||||
|
rooms[i],
|
||||||
|
key: Key('chat_list_item_${rooms[i].id}'),
|
||||||
|
selected: controller.selectedRoomIds.contains(rooms[i].id),
|
||||||
|
onTap: controller.selectMode == SelectMode.select
|
||||||
|
? () => controller.toggleSelection(rooms[i].id)
|
||||||
|
: null,
|
||||||
|
onLongPress: () => controller.toggleSelection(rooms[i].id),
|
||||||
|
activeChat: controller.activeChat == rooms[i].id,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const dummyChatCount = 5;
|
||||||
|
final titleColor =
|
||||||
|
Theme.of(context).textTheme.bodyText1!.color!.withAlpha(100);
|
||||||
|
final subtitleColor =
|
||||||
|
Theme.of(context).textTheme.bodyText1!.color!.withAlpha(50);
|
||||||
|
return ListView.builder(
|
||||||
|
key: const Key('dummychats'),
|
||||||
|
itemCount: dummyChatCount,
|
||||||
|
itemBuilder: (context, i) => Opacity(
|
||||||
|
opacity: (dummyChatCount - i) / dummyChatCount,
|
||||||
|
child: ListTile(
|
||||||
|
leading: CircleAvatar(
|
||||||
|
backgroundColor: titleColor,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 1,
|
||||||
|
color: Theme.of(context).textTheme.bodyText1!.color,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
height: 14,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: titleColor,
|
||||||
|
borderRadius: BorderRadius.circular(3),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 36),
|
||||||
|
Container(
|
||||||
|
height: 14,
|
||||||
|
width: 14,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: subtitleColor,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Container(
|
||||||
|
height: 14,
|
||||||
|
width: 14,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: subtitleColor,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(width: 36),
|
subtitle: Container(
|
||||||
Container(
|
|
||||||
height: 14,
|
|
||||||
width: 14,
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: subtitleColor,
|
color: subtitleColor,
|
||||||
borderRadius: BorderRadius.circular(14),
|
borderRadius: BorderRadius.circular(3),
|
||||||
),
|
),
|
||||||
|
height: 12,
|
||||||
|
margin: const EdgeInsets.only(right: 22),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
|
||||||
Container(
|
|
||||||
height: 14,
|
|
||||||
width: 14,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: subtitleColor,
|
|
||||||
borderRadius: BorderRadius.circular(14),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
subtitle: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: subtitleColor,
|
|
||||||
borderRadius: BorderRadius.circular(3),
|
|
||||||
),
|
),
|
||||||
height: 12,
|
|
||||||
margin: const EdgeInsets.only(right: 22),
|
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
),
|
}),
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,11 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:badges/badges.dart';
|
import 'package:badges/badges.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
|
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
|
||||||
import 'package:vrouter/vrouter.dart';
|
import 'package:vrouter/vrouter.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/config/app_config.dart';
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
import 'package:fluffychat/config/themes.dart';
|
import 'package:fluffychat/config/themes.dart';
|
||||||
import 'package:fluffychat/pages/chat_list/chat_list.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/avatar.dart';
|
||||||
import 'package:fluffychat/widgets/unread_rooms_badge.dart';
|
import 'package:fluffychat/widgets/unread_rooms_badge.dart';
|
||||||
import '../../widgets/matrix.dart';
|
import '../../widgets/matrix.dart';
|
||||||
@ -105,177 +103,155 @@ class ChatListView extends StatelessWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: StreamBuilder<Object>(
|
child: Row(
|
||||||
key: ValueKey(client.userID.toString() +
|
children: [
|
||||||
controller.activeFilter.toString() +
|
if (FluffyThemes.isColumnMode(context) &&
|
||||||
controller.activeSpaceId.toString()),
|
FluffyThemes.getDisplayNavigationRail(context)) ...[
|
||||||
stream: client.onSync.stream
|
Builder(builder: (context) {
|
||||||
.where((s) => s.hasRoomUpdate)
|
final allSpaces = client.rooms.where((room) => room.isSpace);
|
||||||
.rateLimit(const Duration(seconds: 1)),
|
final rootSpaces = allSpaces
|
||||||
builder: (context, snapshot) {
|
.where(
|
||||||
return Row(
|
(space) => !allSpaces.any(
|
||||||
children: [
|
(parentSpace) => parentSpace.spaceChildren
|
||||||
if (FluffyThemes.isColumnMode(context) &&
|
.any((child) => child.roomId == space.id),
|
||||||
FluffyThemes.getDisplayNavigationRail(context)) ...[
|
),
|
||||||
Builder(builder: (context) {
|
)
|
||||||
final allSpaces =
|
.toList();
|
||||||
client.rooms.where((room) => room.isSpace);
|
final destinations = getNavigationDestinations(context);
|
||||||
final rootSpaces = allSpaces
|
|
||||||
.where(
|
|
||||||
(space) => !allSpaces.any(
|
|
||||||
(parentSpace) => parentSpace.spaceChildren
|
|
||||||
.any((child) => child.roomId == space.id),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
final destinations = getNavigationDestinations(context);
|
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
|
width: 64,
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
itemCount: rootSpaces.length + destinations.length,
|
||||||
|
itemBuilder: (context, i) {
|
||||||
|
if (i < destinations.length) {
|
||||||
|
final isSelected = i == controller.selectedIndex;
|
||||||
|
return Container(
|
||||||
|
height: 64,
|
||||||
|
width: 64,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
bottom: i == (destinations.length - 1)
|
||||||
|
? BorderSide(
|
||||||
|
width: 1,
|
||||||
|
color: Theme.of(context).dividerColor,
|
||||||
|
)
|
||||||
|
: BorderSide.none,
|
||||||
|
left: BorderSide(
|
||||||
|
color: isSelected
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Colors.transparent,
|
||||||
|
width: 4,
|
||||||
|
),
|
||||||
|
right: const BorderSide(
|
||||||
|
color: Colors.transparent,
|
||||||
|
width: 4,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: IconButton(
|
||||||
|
color: isSelected
|
||||||
|
? Theme.of(context).colorScheme.secondary
|
||||||
|
: null,
|
||||||
|
icon: CircleAvatar(
|
||||||
|
backgroundColor: isSelected
|
||||||
|
? Theme.of(context).colorScheme.secondary
|
||||||
|
: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.background,
|
||||||
|
foregroundColor: isSelected
|
||||||
|
? Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSecondary
|
||||||
|
: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onBackground,
|
||||||
|
child: i == controller.selectedIndex
|
||||||
|
? destinations[i].selectedIcon ??
|
||||||
|
destinations[i].icon
|
||||||
|
: destinations[i].icon),
|
||||||
|
tooltip: destinations[i].label,
|
||||||
|
onPressed: () =>
|
||||||
|
controller.onDestinationSelected(i),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
i -= destinations.length;
|
||||||
|
final isSelected =
|
||||||
|
controller.activeFilter == ActiveFilter.spaces &&
|
||||||
|
rootSpaces[i].id == controller.activeSpaceId;
|
||||||
|
return Container(
|
||||||
|
height: 64,
|
||||||
width: 64,
|
width: 64,
|
||||||
child: ListView.builder(
|
decoration: BoxDecoration(
|
||||||
scrollDirection: Axis.vertical,
|
border: Border(
|
||||||
itemCount: rootSpaces.length + destinations.length,
|
left: BorderSide(
|
||||||
itemBuilder: (context, i) {
|
color: isSelected
|
||||||
if (i < destinations.length) {
|
? Theme.of(context).colorScheme.secondary
|
||||||
final isSelected =
|
: Colors.transparent,
|
||||||
i == controller.selectedIndex;
|
width: 4,
|
||||||
return Container(
|
),
|
||||||
height: 64,
|
right: const BorderSide(
|
||||||
width: 64,
|
color: Colors.transparent,
|
||||||
decoration: BoxDecoration(
|
width: 4,
|
||||||
border: Border(
|
),
|
||||||
bottom: i == (destinations.length - 1)
|
),
|
||||||
? BorderSide(
|
),
|
||||||
width: 1,
|
alignment: Alignment.center,
|
||||||
color: Theme.of(context)
|
child: IconButton(
|
||||||
.dividerColor,
|
tooltip: rootSpaces[i].displayname,
|
||||||
)
|
icon: Avatar(
|
||||||
: BorderSide.none,
|
mxContent: rootSpaces[i].avatar,
|
||||||
left: BorderSide(
|
name: rootSpaces[i].displayname,
|
||||||
color: isSelected
|
size: 32,
|
||||||
? Theme.of(context)
|
fontSize: 12,
|
||||||
.colorScheme
|
),
|
||||||
.primary
|
onPressed: () =>
|
||||||
: Colors.transparent,
|
controller.setActiveSpace(rootSpaces[i].id),
|
||||||
width: 4,
|
|
||||||
),
|
|
||||||
right: const BorderSide(
|
|
||||||
color: Colors.transparent,
|
|
||||||
width: 4,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: IconButton(
|
|
||||||
color: isSelected
|
|
||||||
? Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.secondary
|
|
||||||
: null,
|
|
||||||
icon: CircleAvatar(
|
|
||||||
backgroundColor: isSelected
|
|
||||||
? Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.secondary
|
|
||||||
: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.background,
|
|
||||||
foregroundColor: isSelected
|
|
||||||
? Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onSecondary
|
|
||||||
: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onBackground,
|
|
||||||
child: i == controller.selectedIndex
|
|
||||||
? destinations[i].selectedIcon ??
|
|
||||||
destinations[i].icon
|
|
||||||
: destinations[i].icon),
|
|
||||||
tooltip: destinations[i].label,
|
|
||||||
onPressed: () =>
|
|
||||||
controller.onDestinationSelected(i),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
i -= destinations.length;
|
|
||||||
final isSelected = controller.activeFilter ==
|
|
||||||
ActiveFilter.spaces &&
|
|
||||||
rootSpaces[i].id == controller.activeSpaceId;
|
|
||||||
return Container(
|
|
||||||
height: 64,
|
|
||||||
width: 64,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border(
|
|
||||||
left: BorderSide(
|
|
||||||
color: isSelected
|
|
||||||
? Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.secondary
|
|
||||||
: Colors.transparent,
|
|
||||||
width: 4,
|
|
||||||
),
|
|
||||||
right: const BorderSide(
|
|
||||||
color: Colors.transparent,
|
|
||||||
width: 4,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: IconButton(
|
|
||||||
tooltip: rootSpaces[i].displayname,
|
|
||||||
icon: Avatar(
|
|
||||||
mxContent: rootSpaces[i].avatar,
|
|
||||||
name: rootSpaces[i].displayname,
|
|
||||||
size: 32,
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
onPressed: () => controller
|
|
||||||
.setActiveSpace(rootSpaces[i].id),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
Container(
|
|
||||||
color: Theme.of(context).dividerColor,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
Expanded(
|
|
||||||
child: Scaffold(
|
|
||||||
appBar: ChatListHeader(controller: controller),
|
|
||||||
body: ChatListViewBody(controller),
|
|
||||||
bottomNavigationBar: controller.displayNavigationBar
|
|
||||||
? NavigationBar(
|
|
||||||
height: 64,
|
|
||||||
selectedIndex: controller.selectedIndex,
|
|
||||||
onDestinationSelected:
|
|
||||||
controller.onDestinationSelected,
|
|
||||||
destinations:
|
|
||||||
getNavigationDestinations(context),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
floatingActionButton: controller
|
|
||||||
.filteredRooms.isNotEmpty &&
|
|
||||||
selectMode == SelectMode.normal
|
|
||||||
? KeyBoardShortcuts(
|
|
||||||
keysToPress: {
|
|
||||||
LogicalKeyboardKey.controlLeft,
|
|
||||||
LogicalKeyboardKey.keyN
|
|
||||||
},
|
|
||||||
onKeysPressed: () =>
|
|
||||||
VRouter.of(context).to('/newprivatechat'),
|
|
||||||
helpLabel: L10n.of(context)!.newChat,
|
|
||||||
child: StartChatFloatingActionButton(
|
|
||||||
controller: controller),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
);
|
}),
|
||||||
}),
|
Container(
|
||||||
|
color: Theme.of(context).dividerColor,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
Expanded(
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: ChatListHeader(controller: controller),
|
||||||
|
body: ChatListViewBody(controller),
|
||||||
|
bottomNavigationBar: controller.displayNavigationBar
|
||||||
|
? NavigationBar(
|
||||||
|
height: 64,
|
||||||
|
selectedIndex: controller.selectedIndex,
|
||||||
|
onDestinationSelected:
|
||||||
|
controller.onDestinationSelected,
|
||||||
|
destinations: getNavigationDestinations(context),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
floatingActionButton: controller.filteredRooms.isNotEmpty &&
|
||||||
|
selectMode == SelectMode.normal
|
||||||
|
? KeyBoardShortcuts(
|
||||||
|
keysToPress: {
|
||||||
|
LogicalKeyboardKey.controlLeft,
|
||||||
|
LogicalKeyboardKey.keyN
|
||||||
|
},
|
||||||
|
onKeysPressed: () =>
|
||||||
|
VRouter.of(context).to('/newprivatechat'),
|
||||||
|
helpLabel: L10n.of(context)!.newChat,
|
||||||
|
child: StartChatFloatingActionButton(
|
||||||
|
controller: controller),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user