@@ -7,6 +7,7 @@ import 'package:super_drag_and_drop/super_drag_and_drop.dart';
77import 'package:watch_it/watch_it.dart' ;
88
99import '../../../app/view/error_page.dart' ;
10+ import '../../../app/view/mouse_and_keyboard_command_wrapper.dart' ;
1011import '../../../common/chat_manager.dart' ;
1112import '../../../common/view/build_context_x.dart' ;
1213import '../../../common/view/common_widgets.dart' ;
@@ -98,100 +99,104 @@ class _ChatRoomPageState extends State<ChatRoomPage> {
9899 preserveState: false ,
99100 ).data;
100101
101- return DropRegion (
102- formats: Formats .standardFormats,
103- hitTestBehavior: HitTestBehavior .opaque,
104- onPerformDrop: (e) async {
105- for (var item in e.session.items.take (5 )) {
106- item.dataReader? .getValue (
107- Formats .fileUri,
108- (value) async {
109- if (value == null ) return ;
110- final file = File .fromUri (value);
102+ return MouseAndKeyboardCommandWrapper (
103+ child: DropRegion (
104+ formats: Formats .standardFormats,
105+ hitTestBehavior: HitTestBehavior .opaque,
106+ onPerformDrop: (e) async {
107+ for (var item in e.session.items.take (5 )) {
108+ item.dataReader? .getValue (
109+ Formats .fileUri,
110+ (value) async {
111+ if (value == null ) return ;
112+ final file = File .fromUri (value);
111113
112- await di <DraftManager >().addAttachment (
113- widget.room.id,
114- onFail: (error) => showSnackBar (context, content: Text (error)),
115- existingFiles: [XFile .fromData (file.readAsBytesSync ())],
116- );
117- },
118- onError: (e) => showSnackBar (context, content: Text (e.toString ())),
119- );
120- }
121- },
122- onDropOver: (event) {
123- if (event.session.allowedOperations.contains (DropOperation .copy)) {
124- return DropOperation .copy;
125- } else {
126- return DropOperation .none;
127- }
128- },
129- child: Stack (
130- alignment: Alignment .center,
131- children: [
132- Scaffold (
133- key: chatRoomScaffoldKey,
134- endDrawer: ChatRoomInfoDrawer (room: widget.room),
135- appBar: ChatRoomTitleBar (room: widget.room),
136- bottomNavigationBar:
137- widget.room.isArchived ||
138- unAcceptedDirectChat != false ||
139- widget.room.isSpace
140- ? null
141- : ChatInput (
142- key: ValueKey ('${widget .room .id }input' ),
143- room: widget.room,
144- ),
145- body: unAcceptedDirectChat == null
146- ? const Center (child: Progress ())
147- : unAcceptedDirectChat == true
148- ? const ChatRoomUnacceptedDirectChatBody ()
149- : FutureBuilder <Timeline >(
150- key: ValueKey (widget.room.id),
151- future: _timelineFuture,
152- builder: (context, snapshot) {
153- if (snapshot.hasError) {
154- return ErrorBody (error: snapshot.error.toString ());
155- }
156- if (snapshot.hasData) {
157- return Padding (
158- padding: const EdgeInsets .only (
159- bottom: kMediumPadding,
160- ),
161- child: ChatRoomTimelineList (
162- timeline: snapshot.data! ,
163- listKey: _roomListKey,
164- ),
165- );
166- } else {
167- return const Center (child: Progress ());
168- }
169- },
170- ),
171- ),
172- if (updating &&
173- chatRoomScaffoldKey.currentState? .isEndDrawerOpen != true )
174- Positioned (
175- top: 4 * kBigPadding,
176- child: RepaintBoundary (
177- child: CircleAvatar (
178- backgroundColor: getMonochromeBg (
179- theme: context.theme,
180- factor: 3 ,
181- darkFactor: 4 ,
182- ),
183- maxRadius: 15 ,
184- child: SizedBox .square (
185- dimension: 18 ,
186- child: Progress (
187- strokeWidth: 2 ,
188- color: colorScheme.onSurface,
114+ await di <DraftManager >().addAttachment (
115+ widget.room.id,
116+ onFail: (error) =>
117+ showSnackBar (context, content: Text (error)),
118+ existingFiles: [XFile .fromData (file.readAsBytesSync ())],
119+ );
120+ },
121+ onError: (e) =>
122+ showSnackBar (context, content: Text (e.toString ())),
123+ );
124+ }
125+ },
126+ onDropOver: (event) {
127+ if (event.session.allowedOperations.contains (DropOperation .copy)) {
128+ return DropOperation .copy;
129+ } else {
130+ return DropOperation .none;
131+ }
132+ },
133+ child: Stack (
134+ alignment: Alignment .center,
135+ children: [
136+ Scaffold (
137+ key: chatRoomScaffoldKey,
138+ endDrawer: ChatRoomInfoDrawer (room: widget.room),
139+ appBar: ChatRoomTitleBar (room: widget.room),
140+ bottomNavigationBar:
141+ widget.room.isArchived ||
142+ unAcceptedDirectChat != false ||
143+ widget.room.isSpace
144+ ? null
145+ : ChatInput (
146+ key: ValueKey ('${widget .room .id }input' ),
147+ room: widget.room,
148+ ),
149+ body: unAcceptedDirectChat == null
150+ ? const Center (child: Progress ())
151+ : unAcceptedDirectChat == true
152+ ? const ChatRoomUnacceptedDirectChatBody ()
153+ : FutureBuilder <Timeline >(
154+ key: ValueKey (widget.room.id),
155+ future: _timelineFuture,
156+ builder: (context, snapshot) {
157+ if (snapshot.hasError) {
158+ return ErrorBody (error: snapshot.error.toString ());
159+ }
160+ if (snapshot.hasData) {
161+ return Padding (
162+ padding: const EdgeInsets .only (
163+ bottom: kMediumPadding,
164+ ),
165+ child: ChatRoomTimelineList (
166+ timeline: snapshot.data! ,
167+ listKey: _roomListKey,
168+ ),
169+ );
170+ } else {
171+ return const Center (child: Progress ());
172+ }
173+ },
174+ ),
175+ ),
176+ if (updating &&
177+ chatRoomScaffoldKey.currentState? .isEndDrawerOpen != true )
178+ Positioned (
179+ top: 4 * kBigPadding,
180+ child: RepaintBoundary (
181+ child: CircleAvatar (
182+ backgroundColor: getMonochromeBg (
183+ theme: context.theme,
184+ factor: 3 ,
185+ darkFactor: 4 ,
186+ ),
187+ maxRadius: 15 ,
188+ child: SizedBox .square (
189+ dimension: 18 ,
190+ child: Progress (
191+ strokeWidth: 2 ,
192+ color: colorScheme.onSurface,
193+ ),
189194 ),
190195 ),
191196 ),
192197 ),
193- ) ,
194- ] ,
198+ ] ,
199+ ) ,
195200 ),
196201 );
197202 }
0 commit comments