|
|
@ -4,11 +4,13 @@ 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';
|
|
|
@ -103,12 +105,21 @@ class ChatListView extends StatelessWidget {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Row(
|
|
|
|
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(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
if (FluffyThemes.isColumnMode(context) &&
|
|
|
|
if (FluffyThemes.isColumnMode(context) &&
|
|
|
|
FluffyThemes.getDisplayNavigationRail(context)) ...[
|
|
|
|
FluffyThemes.getDisplayNavigationRail(context)) ...[
|
|
|
|
Builder(builder: (context) {
|
|
|
|
Builder(builder: (context) {
|
|
|
|
final allSpaces = client.rooms.where((room) => room.isSpace);
|
|
|
|
final allSpaces =
|
|
|
|
|
|
|
|
client.rooms.where((room) => room.isSpace);
|
|
|
|
final rootSpaces = allSpaces
|
|
|
|
final rootSpaces = allSpaces
|
|
|
|
.where(
|
|
|
|
.where(
|
|
|
|
(space) => !allSpaces.any(
|
|
|
|
(space) => !allSpaces.any(
|
|
|
@ -126,7 +137,8 @@ class ChatListView extends StatelessWidget {
|
|
|
|
itemCount: rootSpaces.length + destinations.length,
|
|
|
|
itemCount: rootSpaces.length + destinations.length,
|
|
|
|
itemBuilder: (context, i) {
|
|
|
|
itemBuilder: (context, i) {
|
|
|
|
if (i < destinations.length) {
|
|
|
|
if (i < destinations.length) {
|
|
|
|
final isSelected = i == controller.selectedIndex;
|
|
|
|
final isSelected =
|
|
|
|
|
|
|
|
i == controller.selectedIndex;
|
|
|
|
return Container(
|
|
|
|
return Container(
|
|
|
|
height: 64,
|
|
|
|
height: 64,
|
|
|
|
width: 64,
|
|
|
|
width: 64,
|
|
|
@ -135,12 +147,15 @@ class ChatListView extends StatelessWidget {
|
|
|
|
bottom: i == (destinations.length - 1)
|
|
|
|
bottom: i == (destinations.length - 1)
|
|
|
|
? BorderSide(
|
|
|
|
? BorderSide(
|
|
|
|
width: 1,
|
|
|
|
width: 1,
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
color: Theme.of(context)
|
|
|
|
|
|
|
|
.dividerColor,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
: BorderSide.none,
|
|
|
|
: BorderSide.none,
|
|
|
|
left: BorderSide(
|
|
|
|
left: BorderSide(
|
|
|
|
color: isSelected
|
|
|
|
color: isSelected
|
|
|
|
? Theme.of(context).colorScheme.primary
|
|
|
|
? Theme.of(context)
|
|
|
|
|
|
|
|
.colorScheme
|
|
|
|
|
|
|
|
.primary
|
|
|
|
: Colors.transparent,
|
|
|
|
: Colors.transparent,
|
|
|
|
width: 4,
|
|
|
|
width: 4,
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -153,11 +168,15 @@ class ChatListView extends StatelessWidget {
|
|
|
|
alignment: Alignment.center,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: IconButton(
|
|
|
|
child: IconButton(
|
|
|
|
color: isSelected
|
|
|
|
color: isSelected
|
|
|
|
? Theme.of(context).colorScheme.secondary
|
|
|
|
? Theme.of(context)
|
|
|
|
|
|
|
|
.colorScheme
|
|
|
|
|
|
|
|
.secondary
|
|
|
|
: null,
|
|
|
|
: null,
|
|
|
|
icon: CircleAvatar(
|
|
|
|
icon: CircleAvatar(
|
|
|
|
backgroundColor: isSelected
|
|
|
|
backgroundColor: isSelected
|
|
|
|
? Theme.of(context).colorScheme.secondary
|
|
|
|
? Theme.of(context)
|
|
|
|
|
|
|
|
.colorScheme
|
|
|
|
|
|
|
|
.secondary
|
|
|
|
: Theme.of(context)
|
|
|
|
: Theme.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.colorScheme
|
|
|
|
.background,
|
|
|
|
.background,
|
|
|
@ -179,8 +198,8 @@ class ChatListView extends StatelessWidget {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i -= destinations.length;
|
|
|
|
i -= destinations.length;
|
|
|
|
final isSelected =
|
|
|
|
final isSelected = controller.activeFilter ==
|
|
|
|
controller.activeFilter == ActiveFilter.spaces &&
|
|
|
|
ActiveFilter.spaces &&
|
|
|
|
rootSpaces[i].id == controller.activeSpaceId;
|
|
|
|
rootSpaces[i].id == controller.activeSpaceId;
|
|
|
|
return Container(
|
|
|
|
return Container(
|
|
|
|
height: 64,
|
|
|
|
height: 64,
|
|
|
@ -189,7 +208,9 @@ class ChatListView extends StatelessWidget {
|
|
|
|
border: Border(
|
|
|
|
border: Border(
|
|
|
|
left: BorderSide(
|
|
|
|
left: BorderSide(
|
|
|
|
color: isSelected
|
|
|
|
color: isSelected
|
|
|
|
? Theme.of(context).colorScheme.secondary
|
|
|
|
? Theme.of(context)
|
|
|
|
|
|
|
|
.colorScheme
|
|
|
|
|
|
|
|
.secondary
|
|
|
|
: Colors.transparent,
|
|
|
|
: Colors.transparent,
|
|
|
|
width: 4,
|
|
|
|
width: 4,
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -208,8 +229,8 @@ class ChatListView extends StatelessWidget {
|
|
|
|
size: 32,
|
|
|
|
size: 32,
|
|
|
|
fontSize: 12,
|
|
|
|
fontSize: 12,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () =>
|
|
|
|
onPressed: () => controller
|
|
|
|
controller.setActiveSpace(rootSpaces[i].id),
|
|
|
|
.setActiveSpace(rootSpaces[i].id),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -231,10 +252,12 @@ class ChatListView extends StatelessWidget {
|
|
|
|
selectedIndex: controller.selectedIndex,
|
|
|
|
selectedIndex: controller.selectedIndex,
|
|
|
|
onDestinationSelected:
|
|
|
|
onDestinationSelected:
|
|
|
|
controller.onDestinationSelected,
|
|
|
|
controller.onDestinationSelected,
|
|
|
|
destinations: getNavigationDestinations(context),
|
|
|
|
destinations:
|
|
|
|
|
|
|
|
getNavigationDestinations(context),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
: null,
|
|
|
|
floatingActionButton: controller.filteredRooms.isNotEmpty &&
|
|
|
|
floatingActionButton: controller
|
|
|
|
|
|
|
|
.filteredRooms.isNotEmpty &&
|
|
|
|
selectMode == SelectMode.normal
|
|
|
|
selectMode == SelectMode.normal
|
|
|
|
? KeyBoardShortcuts(
|
|
|
|
? KeyBoardShortcuts(
|
|
|
|
keysToPress: {
|
|
|
|
keysToPress: {
|
|
|
@ -251,7 +274,8 @@ class ChatListView extends StatelessWidget {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|