reorganize and rename widgets
This commit is contained in:
parent
05d25869ef
commit
d5f29dc344
1 changed files with 568 additions and 547 deletions
59
lib/widgets/sidebar/room_list.dart
Normal file
59
lib/widgets/sidebar/room_list.dart
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import "package:nexus/widgets/sidebar/spaces_rail.dart";
|
||||
import "package:nexus/widgets/sidebar/rooms_pane.dart";
|
||||
|
||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:material_ui/material_ui.dart";
|
||||
import "package:nexus/models/nav_page.dart";
|
||||
import "package:nexus/widgets/common/error_dialog.dart";
|
||||
import "package:nexus/controllers/rooms.dart";
|
||||
import "package:nexus/controllers/spaces.dart";
|
||||
|
||||
class const RoomList({super.key}) extends ConsumerWidget implements NavPage {
|
||||
@override
|
||||
String get title => "Rooms";
|
||||
|
||||
@override
|
||||
IconData get icon => Icons.list;
|
||||
|
||||
@override
|
||||
int? badgeCount(WidgetRef ref) {
|
||||
final (notifications, hasUnread) = ref.watch(
|
||||
RoomsController.provider.select(
|
||||
(rooms) => rooms.values.fold(
|
||||
(0, false),
|
||||
(total, room) => (
|
||||
total.$1 + (room.metadata?.unreadNotifications ?? 0),
|
||||
total.$2 || (room.metadata?.unreadMessages ?? 0) > 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return notifications > 0
|
||||
? notifications
|
||||
: hasUnread
|
||||
? 0
|
||||
: null;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final spacesAsync = ref.watch(SpacesController.provider);
|
||||
if (spacesAsync.value == null) {
|
||||
return switch (spacesAsync) {
|
||||
AsyncError(:final error, :final stackTrace) => ErrorDialog(
|
||||
error,
|
||||
stackTrace,
|
||||
),
|
||||
_ => const Center(child: CircularProgressIndicator()),
|
||||
};
|
||||
}
|
||||
|
||||
return const Row(
|
||||
children: [
|
||||
SpacesRail(),
|
||||
Expanded(child: RoomsPane()),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue