@@ -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' ;
@@ -1300,22 +1301,45 @@ String formatHeaderDate(
1300
1301
// Design referenced from:
1301
1302
// - https://github.com/zulip/zulip-mobile/issues/5511
1302
1303
// - https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=538%3A20849&mode=dev
1303
- class MessageWithPossibleSender extends StatelessWidget {
1304
+ class MessageWithPossibleSender extends StatefulWidget {
1304
1305
const MessageWithPossibleSender ({super .key, required this .item});
1305
1306
1306
1307
final MessageListMessageItem item;
1307
1308
1309
+ @override
1310
+ State <MessageWithPossibleSender > createState () => _MessageWithPossibleSenderState ();
1311
+ }
1312
+
1313
+ class _MessageWithPossibleSenderState extends State <MessageWithPossibleSender > {
1314
+ final WidgetStatesController statesController = WidgetStatesController ();
1315
+
1316
+ @override
1317
+ void initState () {
1318
+ super .initState ();
1319
+ statesController.addListener (() {
1320
+ setState (() {
1321
+ // Force a rebuild to resolve background color
1322
+ });
1323
+ });
1324
+ }
1325
+
1326
+ @override
1327
+ void dispose () {
1328
+ statesController.dispose ();
1329
+ super .dispose ();
1330
+ }
1331
+
1308
1332
@override
1309
1333
Widget build (BuildContext context) {
1310
1334
final store = PerAccountStoreWidget .of (context);
1311
1335
final messageListTheme = MessageListTheme .of (context);
1312
1336
final designVariables = DesignVariables .of (context);
1313
1337
1314
- final message = item.message;
1338
+ final message = widget. item.message;
1315
1339
final sender = store.users[message.senderId];
1316
1340
1317
1341
Widget ? senderRow;
1318
- if (item.showSender) {
1342
+ if (widget. item.showSender) {
1319
1343
final time = _kMessageTimestampFormat
1320
1344
.format (DateTime .fromMillisecondsSinceEpoch (1000 * message.timestamp));
1321
1345
senderRow = Row (
@@ -1373,40 +1397,57 @@ class MessageWithPossibleSender extends StatelessWidget {
1373
1397
1374
1398
return GestureDetector (
1375
1399
behavior: HitTestBehavior .translucent,
1376
- onLongPress: () => showMessageActionSheet (context: context, message: message),
1377
- child: Padding (
1378
- padding: const EdgeInsets .symmetric (vertical: 4 ),
1379
- child: Column (children: [
1380
- if (senderRow != null )
1381
- Padding (padding: const EdgeInsets .fromLTRB (16 , 2 , 16 , 0 ),
1382
- child: senderRow),
1383
- Row (
1384
- crossAxisAlignment: CrossAxisAlignment .baseline,
1385
- textBaseline: localizedTextBaseline (context),
1386
- children: [
1387
- const SizedBox (width: 16 ),
1388
- Expanded (child: Column (
1389
- crossAxisAlignment: CrossAxisAlignment .stretch,
1390
- children: [
1391
- MessageContent (message: message, content: item.content),
1392
- if ((message.reactions? .total ?? 0 ) > 0 )
1393
- ReactionChipsList (messageId: message.id, reactions: message.reactions! ),
1394
- if (editStateText != null )
1395
- Text (editStateText,
1396
- textAlign: TextAlign .end,
1397
- style: TextStyle (
1398
- color: designVariables.labelEdited,
1399
- fontSize: 12 ,
1400
- height: (12 / 12 ),
1401
- letterSpacing: proportionalLetterSpacing (
1402
- context, 0.05 , baseFontSize: 12 ))),
1403
- ])),
1404
- SizedBox (width: 16 ,
1405
- child: message.flags.contains (MessageFlag .starred)
1406
- ? Icon (ZulipIcons .star_filled, size: 16 , color: designVariables.star)
1407
- : null ),
1408
- ]),
1409
- ])));
1400
+ onLongPress: () async {
1401
+ statesController.update (WidgetState .selected, true );
1402
+ ModalStatus status = showMessageActionSheet (context: context,
1403
+ message: message);
1404
+ await status.closed;
1405
+ statesController.update (WidgetState .selected, false );
1406
+ },
1407
+ onLongPressDown: (_) => statesController.update (WidgetState .pressed, true ),
1408
+ onLongPressCancel: () => statesController.update (WidgetState .pressed, false ),
1409
+ onLongPressUp: () => statesController.update (WidgetState .pressed, false ),
1410
+ child: DecoratedBox (
1411
+ decoration: BoxDecoration (
1412
+ color: WidgetStateColor .fromMap ({
1413
+ WidgetState .pressed: designVariables.pressedTint,
1414
+ WidgetState .selected: designVariables.pressedTint,
1415
+ WidgetState .any: Colors .transparent,
1416
+ }).resolve (statesController.value)
1417
+ ),
1418
+ child: Padding (
1419
+ padding: const EdgeInsets .symmetric (vertical: 4 ),
1420
+ child: Column (children: [
1421
+ if (senderRow != null )
1422
+ Padding (padding: const EdgeInsets .fromLTRB (16 , 2 , 16 , 0 ),
1423
+ child: senderRow),
1424
+ Row (
1425
+ crossAxisAlignment: CrossAxisAlignment .baseline,
1426
+ textBaseline: localizedTextBaseline (context),
1427
+ children: [
1428
+ const SizedBox (width: 16 ),
1429
+ Expanded (child: Column (
1430
+ crossAxisAlignment: CrossAxisAlignment .stretch,
1431
+ children: [
1432
+ MessageContent (message: message, content: widget.item.content),
1433
+ if ((message.reactions? .total ?? 0 ) > 0 )
1434
+ ReactionChipsList (messageId: message.id, reactions: message.reactions! ),
1435
+ if (editStateText != null )
1436
+ Text (editStateText,
1437
+ textAlign: TextAlign .end,
1438
+ style: TextStyle (
1439
+ color: designVariables.labelEdited,
1440
+ fontSize: 12 ,
1441
+ height: (12 / 12 ),
1442
+ letterSpacing: proportionalLetterSpacing (
1443
+ context, 0.05 , baseFontSize: 12 ))),
1444
+ ])),
1445
+ SizedBox (width: 16 ,
1446
+ child: message.flags.contains (MessageFlag .starred)
1447
+ ? Icon (ZulipIcons .star_filled, size: 16 , color: designVariables.star)
1448
+ : null ),
1449
+ ]),
1450
+ ]))));
1410
1451
}
1411
1452
}
1412
1453
0 commit comments