@@ -2,42 +2,71 @@ import 'dart:io';
22
33import 'package:flutter/foundation.dart' ;
44import 'package:flutter/material.dart' ;
5+ import 'package:flutter_it/flutter_it.dart' ;
56import 'package:yaru/yaru.dart' ;
67
8+ import '../../../common/chat_manager.dart' ;
79import '../../../common/view/build_context_x.dart' ;
810import '../../../common/view/ui_constants.dart' ;
11+ import '../../create_or_edit/edit_room_manager.dart' ;
912import '../../titlebar/side_bar_button.dart' ;
1013
11- class ChatNoSelectedRoomPage extends StatelessWidget {
14+ class ChatNoSelectedRoomPage extends StatelessWidget with WatchItMixin {
1215 const ChatNoSelectedRoomPage ({super .key});
1316
1417 @override
15- Widget build (BuildContext context) => Scaffold (
16- appBar: YaruWindowTitleBar (
17- heroTag: '<Right hero tag>' ,
18- border: BorderSide .none,
19- backgroundColor: Colors .transparent,
20- title: const Text ('' ),
21- leading: ! kIsWeb && ! Platform .isMacOS && ! context.showSideBar
22- ? const SideBarButton ()
23- : null ,
24- actions: [
25- if (! context.showSideBar && ! kIsWeb && Platform .isMacOS)
26- const SideBarButton (),
27- ],
28- ),
29- body: Padding (
30- padding: const EdgeInsets .only (bottom: kYaruTitleBarHeight),
31- child: Center (
32- child: Column (
33- mainAxisSize: MainAxisSize .min,
34- spacing: kBigPadding,
35- children: [
36- Image .asset ('assets/nebuchadnezzar.png' , width: 100 , height: 100 ),
37- const Text ('Please select a chatroom from the side panel.' ),
38- ],
18+ Widget build (BuildContext context) {
19+ registerHandler (
20+ select: (EditRoomManager m) => m.knockOrJoinCommand,
21+ handler: (context, room, cancel) {
22+ if (room != null ) {
23+ di <ChatManager >().setSelectedRoom (room);
24+ if (room.isSpace) {
25+ di <ChatManager >().setActiveSpace (room);
26+ }
27+ }
28+ },
29+ );
30+
31+ registerHandler (
32+ select: (EditRoomManager m) => m.joinRoomCommand,
33+ handler: (context, room, cancel) {
34+ if (room != null ) {
35+ di <ChatManager >().setSelectedRoom (room);
36+ if (room.isSpace) {
37+ di <ChatManager >().setActiveSpace (room);
38+ }
39+ }
40+ },
41+ );
42+
43+ return Scaffold (
44+ appBar: YaruWindowTitleBar (
45+ heroTag: '<Right hero tag>' ,
46+ border: BorderSide .none,
47+ backgroundColor: Colors .transparent,
48+ title: const Text ('' ),
49+ leading: ! kIsWeb && ! Platform .isMacOS && ! context.showSideBar
50+ ? const SideBarButton ()
51+ : null ,
52+ actions: [
53+ if (! context.showSideBar && ! kIsWeb && Platform .isMacOS)
54+ const SideBarButton (),
55+ ],
56+ ),
57+ body: Padding (
58+ padding: const EdgeInsets .only (bottom: kYaruTitleBarHeight),
59+ child: Center (
60+ child: Column (
61+ mainAxisSize: MainAxisSize .min,
62+ spacing: kBigPadding,
63+ children: [
64+ Image .asset ('assets/nebuchadnezzar.png' , width: 100 , height: 100 ),
65+ const Text ('Please select a chatroom from the side panel.' ),
66+ ],
67+ ),
3968 ),
4069 ),
41- ),
42- );
70+ );
71+ }
4372}
0 commit comments