11import 'package:flutter/material.dart' ;
2- import 'package:future_loading_dialog/future_loading_dialog.dart' ;
32import 'package:matrix/matrix.dart' ;
43import 'package:watch_it/watch_it.dart' ;
54import 'package:yaru/yaru.dart' ;
65
76import '../../chat_room/common/view/chat_invitation_dialog.dart' ;
8- import '../../chat_room/create_or_edit/create_or_edit_room_model.dart' ;
97import '../../chat_room/input/draft_model.dart' ;
108import '../../chat_room/titlebar/chat_room_pin_button.dart' ;
119import '../../common/chat_model.dart' ;
@@ -28,82 +26,57 @@ class ChatRoomMasterTile extends StatelessWidget with WatchItMixin {
2826
2927 final selectedRoom = watchPropertyValue ((ChatModel m) => m.selectedRoom);
3028
31- final loadingArchive = watchPropertyValue (
32- (ChatModel m) => m.loadingArchive,
33- );
34-
3529 return ChatMasterTileMenu (
3630 room: room,
37- child: Opacity (
38- opacity: loadingArchive ? 0.3 : 1 ,
39- child: Padding (
40- padding: const EdgeInsets .only (bottom: kSmallPadding),
41- child: Stack (
42- alignment: Alignment .center,
43- children: [
44- YaruMasterTile (
45- key: ValueKey ('${room .id }_master_tile' ),
46- selected:
47- selectedRoom? .id != null && selectedRoom? .id == room.id,
48- leading: ChatRoomMasterTileAvatar (room: room),
49- title: Text (
50- room.membership == Membership .invite
51- ? context.l10n.invite
52- : room.getLocalizedDisplayname (),
53- maxLines: 2 ,
54- ),
55- subtitle: room.membership == Membership .invite
56- ? Text (room.getLocalizedDisplayname ())
57- : ChatRoomMasterTileSubTitle (room: room),
58- onTap: loadingArchive
59- ? null
60- : () async {
61- if (room.isArchived) {
62- chatModel.setSelectedRoom (room);
63- } else {
64- if (room.membership == Membership .invite) {
65- showDialog (
66- context: context,
67- builder: (context) =>
68- ChatInvitationDialog (room: room),
69- );
70- } else {
71- showFutureLoadingDialog (
72- context: context,
73- future: () =>
74- di <CreateOrEditRoomModel >().joinRoom (room),
75- ).then ((result) {
76- if (result.asValue? .value != null ) {
77- chatModel.setSelectedRoom (
78- result.asValue! .value,
79- );
80- }
81- });
82- }
83- }
84- di <DraftModel >().setAttaching (false );
85-
86- masterScaffoldKey.currentState? .hideDrawer ();
87- },
31+ child: Padding (
32+ padding: const EdgeInsets .only (bottom: kSmallPadding),
33+ child: Stack (
34+ alignment: Alignment .center,
35+ children: [
36+ YaruMasterTile (
37+ key: ValueKey ('${room .id }_master_tile' ),
38+ selected: selectedRoom? .id != null && selectedRoom? .id == room.id,
39+ leading: ChatRoomMasterTileAvatar (room: room),
40+ title: Text (
41+ room.membership == Membership .invite
42+ ? context.l10n.invite
43+ : room.getLocalizedDisplayname (),
44+ maxLines: 2 ,
8845 ),
89- if (! room.isArchived) ...[
90- if (room.notificationCount > 0 )
91- Positioned (
92- right: kBigPadding,
93- child: Badge (
94- largeSize: 11 ,
95- smallSize: 11 ,
96- label: Text (room.notificationCount.toString ()),
97- ),
98- )
99- else if (room.isFavourite)
100- Positioned (
101- right: kBigPadding - 3 ,
102- child: ChatRoomPinButton (room: room, small: true ),
46+ subtitle: room.membership == Membership .invite
47+ ? Text (room.getLocalizedDisplayname ())
48+ : ChatRoomMasterTileSubTitle (room: room),
49+ onTap: () async {
50+ di <DraftModel >().setAttaching (false );
51+ masterScaffoldKey.currentState? .hideDrawer ();
52+ return switch (room.membership) {
53+ Membership .join ||
54+ Membership .leave => chatModel.setSelectedRoom (room),
55+ Membership .invite => showDialog (
56+ context: context,
57+ builder: (context) => ChatInvitationDialog (room: room),
58+ ),
59+ _ => Future .value (),
60+ };
61+ },
62+ ),
63+ if (! room.isArchived) ...[
64+ if (room.notificationCount > 0 )
65+ Positioned (
66+ right: kBigPadding,
67+ child: Badge (
68+ largeSize: 11 ,
69+ smallSize: 11 ,
70+ label: Text (room.notificationCount.toString ()),
10371 ),
104- ],
72+ )
73+ else if (room.isFavourite)
74+ Positioned (
75+ right: kBigPadding - 3 ,
76+ child: ChatRoomPinButton (room: room, small: true ),
77+ ),
10578 ],
106- ) ,
79+ ] ,
10780 ),
10881 ),
10982 );
0 commit comments