@@ -16,6 +16,7 @@ import 'actions.dart';
16
16
import 'app_bar.dart' ;
17
17
import 'compose_box.dart' ;
18
18
import 'content.dart' ;
19
+ import 'dialog.dart' ;
19
20
import 'emoji_reaction.dart' ;
20
21
import 'icons.dart' ;
21
22
import 'page.dart' ;
@@ -1274,22 +1275,45 @@ String formatHeaderDate(
1274
1275
// Design referenced from:
1275
1276
// - https://github.com/zulip/zulip-mobile/issues/5511
1276
1277
// - https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=538%3A20849&mode=dev
1277
- class MessageWithPossibleSender extends StatelessWidget {
1278
+ class MessageWithPossibleSender extends StatefulWidget {
1278
1279
const MessageWithPossibleSender ({super .key, required this .item});
1279
1280
1280
1281
final MessageListMessageItem item;
1281
1282
1283
+ @override
1284
+ State <MessageWithPossibleSender > createState () => _MessageWithPossibleSenderState ();
1285
+ }
1286
+
1287
+ class _MessageWithPossibleSenderState extends State <MessageWithPossibleSender > {
1288
+ final WidgetStatesController statesController = WidgetStatesController ();
1289
+
1290
+ @override
1291
+ void initState () {
1292
+ super .initState ();
1293
+ statesController.addListener (() {
1294
+ setState (() {
1295
+ // Force a rebuild to resolve background color
1296
+ });
1297
+ });
1298
+ }
1299
+
1300
+ @override
1301
+ void dispose () {
1302
+ statesController.dispose ();
1303
+ super .dispose ();
1304
+ }
1305
+
1282
1306
@override
1283
1307
Widget build (BuildContext context) {
1284
1308
final store = PerAccountStoreWidget .of (context);
1285
1309
final messageListTheme = MessageListTheme .of (context);
1286
1310
final designVariables = DesignVariables .of (context);
1287
1311
1288
- final message = item.message;
1312
+ final message = widget. item.message;
1289
1313
final sender = store.users[message.senderId];
1290
1314
1291
1315
Widget ? senderRow;
1292
- if (item.showSender) {
1316
+ if (widget. item.showSender) {
1293
1317
final time = _kMessageTimestampFormat
1294
1318
.format (DateTime .fromMillisecondsSinceEpoch (1000 * message.timestamp));
1295
1319
senderRow = Row (
@@ -1347,40 +1371,57 @@ class MessageWithPossibleSender extends StatelessWidget {
1347
1371
1348
1372
return GestureDetector (
1349
1373
behavior: HitTestBehavior .translucent,
1350
- onLongPress: () => showMessageActionSheet (context: context, message: message),
1351
- child: Padding (
1352
- padding: const EdgeInsets .symmetric (vertical: 4 ),
1353
- child: Column (children: [
1354
- if (senderRow != null )
1355
- Padding (padding: const EdgeInsets .fromLTRB (16 , 2 , 16 , 0 ),
1356
- child: senderRow),
1357
- Row (
1358
- crossAxisAlignment: CrossAxisAlignment .baseline,
1359
- textBaseline: localizedTextBaseline (context),
1360
- children: [
1361
- const SizedBox (width: 16 ),
1362
- Expanded (child: Column (
1363
- crossAxisAlignment: CrossAxisAlignment .stretch,
1364
- children: [
1365
- MessageContent (message: message, content: item.content),
1366
- if ((message.reactions? .total ?? 0 ) > 0 )
1367
- ReactionChipsList (messageId: message.id, reactions: message.reactions! ),
1368
- if (editStateText != null )
1369
- Text (editStateText,
1370
- textAlign: TextAlign .end,
1371
- style: TextStyle (
1372
- color: designVariables.labelEdited,
1373
- fontSize: 12 ,
1374
- height: (12 / 12 ),
1375
- letterSpacing: proportionalLetterSpacing (
1376
- context, 0.05 , baseFontSize: 12 ))),
1377
- ])),
1378
- SizedBox (width: 16 ,
1379
- child: message.flags.contains (MessageFlag .starred)
1380
- ? Icon (ZulipIcons .star_filled, size: 16 , color: designVariables.star)
1381
- : null ),
1382
- ]),
1383
- ])));
1374
+ onLongPress: () async {
1375
+ statesController.update (WidgetState .selected, true );
1376
+ ModalStatus status = showMessageActionSheet (context: context,
1377
+ message: message);
1378
+ await status.closed;
1379
+ statesController.update (WidgetState .selected, false );
1380
+ },
1381
+ onLongPressDown: (_) => statesController.update (WidgetState .pressed, true ),
1382
+ onLongPressCancel: () => statesController.update (WidgetState .pressed, false ),
1383
+ onLongPressUp: () => statesController.update (WidgetState .pressed, false ),
1384
+ child: DecoratedBox (
1385
+ decoration: BoxDecoration (
1386
+ color: WidgetStateColor .fromMap ({
1387
+ WidgetState .pressed: designVariables.pressedTint,
1388
+ WidgetState .selected: designVariables.pressedTint,
1389
+ WidgetState .any: Colors .transparent,
1390
+ }).resolve (statesController.value)
1391
+ ),
1392
+ child: Padding (
1393
+ padding: const EdgeInsets .symmetric (vertical: 4 ),
1394
+ child: Column (children: [
1395
+ if (senderRow != null )
1396
+ Padding (padding: const EdgeInsets .fromLTRB (16 , 2 , 16 , 0 ),
1397
+ child: senderRow),
1398
+ Row (
1399
+ crossAxisAlignment: CrossAxisAlignment .baseline,
1400
+ textBaseline: localizedTextBaseline (context),
1401
+ children: [
1402
+ const SizedBox (width: 16 ),
1403
+ Expanded (child: Column (
1404
+ crossAxisAlignment: CrossAxisAlignment .stretch,
1405
+ children: [
1406
+ MessageContent (message: message, content: widget.item.content),
1407
+ if ((message.reactions? .total ?? 0 ) > 0 )
1408
+ ReactionChipsList (messageId: message.id, reactions: message.reactions! ),
1409
+ if (editStateText != null )
1410
+ Text (editStateText,
1411
+ textAlign: TextAlign .end,
1412
+ style: TextStyle (
1413
+ color: designVariables.labelEdited,
1414
+ fontSize: 12 ,
1415
+ height: (12 / 12 ),
1416
+ letterSpacing: proportionalLetterSpacing (
1417
+ context, 0.05 , baseFontSize: 12 ))),
1418
+ ])),
1419
+ SizedBox (width: 16 ,
1420
+ child: message.flags.contains (MessageFlag .starred)
1421
+ ? Icon (ZulipIcons .star_filled, size: 16 , color: designVariables.star)
1422
+ : null ),
1423
+ ]),
1424
+ ]))));
1384
1425
}
1385
1426
}
1386
1427
0 commit comments