add JumpToEventController to allow jumping to events from the NotificationsPage when it has been pushed from the NotificationController
This commit is contained in:
parent
c90a1c41b0
commit
1c1f585362
5 changed files with 70 additions and 65 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import "package:flutter_hooks/flutter_hooks.dart";
|
||||
import "package:material_ui/material_ui.dart";
|
||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:nexus/controllers/init_complete.dart";
|
||||
import "package:nexus/controllers/jump_to_event.dart";
|
||||
import "package:nexus/controllers/key.dart";
|
||||
import "package:nexus/widgets/appbar.dart";
|
||||
import "package:nexus/widgets/sidebar.dart";
|
||||
|
|
@ -10,61 +10,51 @@ import "package:nexus/widgets/loading.dart";
|
|||
|
||||
class const ChatPage({super.key}) extends HookConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final initialHighlightedEvent = useState<String?>(null);
|
||||
Widget build(BuildContext context, WidgetRef ref) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final isDesktop = constraints.maxWidth > 650;
|
||||
final showMembersByDefault = constraints.maxWidth > 1000;
|
||||
final initComplete = ref.watch(InitCompleteController.provider);
|
||||
final roomId = ref
|
||||
.watch(KeyController.provider(KeyController.roomKey))
|
||||
.requireValue;
|
||||
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final isDesktop = constraints.maxWidth > 650;
|
||||
final showMembersByDefault = constraints.maxWidth > 1000;
|
||||
final initComplete = ref.watch(InitCompleteController.provider);
|
||||
final roomId = ref
|
||||
.watch(KeyController.provider(KeyController.roomKey))
|
||||
.requireValue;
|
||||
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: initComplete ? null : Appbar(),
|
||||
body: initComplete
|
||||
? Row(
|
||||
children: [
|
||||
if (isDesktop)
|
||||
Sidebar(
|
||||
isDesktop: isDesktop,
|
||||
jumpToEvent: (eventId) =>
|
||||
initialHighlightedEvent.value = eventId,
|
||||
),
|
||||
Expanded(
|
||||
child: RoomChat(
|
||||
key: ValueKey((
|
||||
roomId,
|
||||
initialHighlightedEvent.value,
|
||||
)),
|
||||
roomId: roomId,
|
||||
isDesktop: isDesktop,
|
||||
showMembersByDefault: showMembersByDefault,
|
||||
initialHighlightedEvent:
|
||||
initialHighlightedEvent.value,
|
||||
),
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: initComplete ? null : Appbar(),
|
||||
body: initComplete
|
||||
? Row(
|
||||
children: [
|
||||
if (isDesktop) Sidebar(isDesktop: isDesktop),
|
||||
Expanded(
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final initialHighlight = ref.watch(
|
||||
JumpToEventController.provider,
|
||||
);
|
||||
return RoomChat(
|
||||
key: ValueKey((roomId, initialHighlight)),
|
||||
roomId: roomId,
|
||||
isDesktop: isDesktop,
|
||||
initialHighlightedEvent: initialHighlight,
|
||||
showMembersByDefault: showMembersByDefault,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: Center(
|
||||
child: Column(
|
||||
mainAxisSize: .min,
|
||||
children: [Loading(), Text("Syncing...")],
|
||||
),
|
||||
],
|
||||
)
|
||||
: Center(
|
||||
child: Column(
|
||||
mainAxisSize: .min,
|
||||
children: [Loading(), Text("Syncing...")],
|
||||
),
|
||||
drawer: isDesktop || !initComplete
|
||||
? null
|
||||
: Sidebar(
|
||||
isDesktop: isDesktop,
|
||||
jumpToEvent: (eventId) =>
|
||||
initialHighlightedEvent.value = eventId,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
),
|
||||
drawer: isDesktop || !initComplete
|
||||
? null
|
||||
: Sidebar(isDesktop: isDesktop),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue