shows room but not really

This commit is contained in:
Henry Hiles 2026-01-27 19:09:43 +00:00
commit a28bced44d
No known key found for this signature in database
23 changed files with 885 additions and 805 deletions

View file

@ -2,27 +2,20 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:flutter/material.dart";
import "package:flutter/services.dart";
import "package:flutter_hooks/flutter_hooks.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/controllers/client_controller.dart";
import "package:nexus/models/room.dart";
import "package:nexus/widgets/form_text_input.dart";
class RoomMenu extends StatelessWidget {
class RoomMenu extends ConsumerWidget {
final Room room;
final IList<Room> children;
const RoomMenu(this.room, {this.children = const IList.empty(), super.key});
@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
final danger = Theme.of(context).colorScheme.error;
void markRead(String roomId) async {
// TODO: Set parent read
for (final child in children) {
// await child.setReadMarker( TODO: Set children read
// child.roomData.lastEvent?.eventId,
// mRead: child.roomData.lastEvent?.eventId,
// );
}
}
final client = ref.watch(ClientController.provider.notifier);
return PopupMenuButton(
itemBuilder: (_) => [
@ -33,45 +26,51 @@ class RoomMenu extends StatelessWidget {
// },
// child: ListTile(leading: Icon(Icons.link), title: Text("Copy Link")),
// ),
// PopupMenuItem(
// onTap: () => markRead(room.id),
// child: ListTile(
// leading: Icon(Icons.check),
// title: Text("Mark as Read"),
// ),
// ),
// PopupMenuItem(
// onTap: () => showDialog(
// context: context,
// builder: (context) => AlertDialog(
// title: Text("Leave Room"),
// content: Text(
// "Are you sure you want to leave \"${room.getLocalizedDisplayname()}\"?",
// ),
// actions: [
// TextButton(
// onPressed: Navigator.of(context).pop,
// child: Text("Cancel"),
// ),
// TextButton(
// onPressed: () async {
// Navigator.of(context).pop();
// final snackbar = ScaffoldMessenger.of(
// context,
// ).showSnackBar(SnackBar(content: Text("Leaving room...")));
// await room.leave();
// snackbar.close();
// },
// child: Text("Leave"),
// ),
// ],
// ),
// ),
// child: ListTile(
// leading: Icon(Icons.logout, color: danger),
// title: Text("Leave", style: TextStyle(color: danger)),
// ),
// ),
PopupMenuItem(
onTap: () async {
await client.markRead(room);
await Future.wait(children.map((child) => client.markRead(child)));
},
child: ListTile(
leading: Icon(Icons.check),
title: Text("Mark as Read"),
),
),
PopupMenuItem(
onTap: () => showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text("Leave Room"),
content: Text(
"Are you sure you want to leave \"${room.metadata?.name ?? "Unnamed Room"}\"?",
),
actions: [
TextButton(
onPressed: Navigator.of(context).pop,
child: Text("Cancel"),
),
TextButton(
onPressed: () async {
Navigator.of(context).pop();
final snackbar = ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("Leaving room..."),
duration: Duration(days: 1),
),
);
await client.leaveRoom(room);
snackbar.close();
},
child: Text("Leave"),
),
],
),
),
child: ListTile(
leading: Icon(Icons.logout, color: danger),
title: Text("Leave", style: TextStyle(color: danger)),
),
),
// PopupMenuItem(
// onTap: () => showDialog(
// context: context,