@@ -8,6 +8,7 @@ import 'package:intl/intl.dart' hide TextDirection;
8
8
9
9
import '../api/model/model.dart' ;
10
10
import '../generated/l10n/zulip_localizations.dart' ;
11
+ import '../model/message.dart' ;
11
12
import '../model/message_list.dart' ;
12
13
import '../model/narrow.dart' ;
13
14
import '../model/store.dart' ;
@@ -1479,21 +1480,86 @@ class OutboxMessageWithPossibleSender extends StatelessWidget {
1479
1480
1480
1481
final MessageListOutboxMessageItem item;
1481
1482
1483
+ // TODO should we restore the topic as well?
1484
+ void _handlePress (BuildContext context) {
1485
+ final content = item.message.content.endsWith ('\n ' )
1486
+ ? item.message.content : '${item .message .content }\n ' ;
1487
+
1488
+ final composeBoxController =
1489
+ MessageListPage .ancestorOf (context).composeBoxController;
1490
+ composeBoxController! .content.insertPadded (content);
1491
+ if (! composeBoxController.contentFocusNode.hasFocus) {
1492
+ composeBoxController.contentFocusNode.requestFocus ();
1493
+ }
1494
+
1495
+ final store = PerAccountStoreWidget .of (context);
1496
+ assert (store.outboxMessages.containsKey (item.message.localMessageId));
1497
+ store.removeOutboxMessage (item.message.localMessageId);
1498
+ }
1499
+
1482
1500
@override
1483
1501
Widget build (BuildContext context) {
1484
- final message = item.message;
1485
- return Padding (
1486
- padding: const EdgeInsets .symmetric (vertical: 4 ),
1487
- child: Column (children: [
1488
- if (item.showSender) _SenderRow (message: message, showTimestamp: false ),
1489
- Padding (
1490
- padding: const EdgeInsets .symmetric (horizontal: 16 ),
1491
- // This is adapated from [MessageContent].
1492
- // TODO(#576): Offer InheritedMessage ancestor once we are ready
1493
- // to support local echoing images and lightbox.
1494
- child: DefaultTextStyle (
1495
- style: ContentTheme .of (context).textStylePlainParagraph,
1496
- child: BlockContentList (nodes: item.content.nodes))),
1497
- ]));
1502
+ final designVariables = DesignVariables .of (context);
1503
+ final zulipLocalizations = ZulipLocalizations .of (context);
1504
+ final isComposeBoxOffered =
1505
+ MessageListPage .ancestorOf (context).composeBoxController != null ;
1506
+
1507
+ final GestureTapCallback ? handleTap;
1508
+ final double opacity;
1509
+ final Widget bottom;
1510
+ switch (item.message.state) {
1511
+ case OutboxMessageState .hidden:
1512
+ assert (false ,
1513
+ 'Hidden OutboxMessage messages should not appear in message lists' );
1514
+ handleTap = null ;
1515
+ opacity = 1.0 ;
1516
+ bottom = SizedBox .shrink ();
1517
+
1518
+ case OutboxMessageState .waiting:
1519
+ handleTap = null ;
1520
+ opacity = 1.0 ;
1521
+ bottom = LinearProgressIndicator (
1522
+ minHeight: 2 ,
1523
+ color: designVariables.foreground.withFadedAlpha (0.5 ),
1524
+ backgroundColor: designVariables.foreground.withFadedAlpha (0.2 ));
1525
+
1526
+ case OutboxMessageState .failed:
1527
+ case OutboxMessageState .waitPeriodExpired:
1528
+ handleTap = isComposeBoxOffered ? () => _handlePress (context) : null ;
1529
+ opacity = 0.6 ;
1530
+ bottom = Text (
1531
+ zulipLocalizations.messageIsntSentLabel,
1532
+ textAlign: TextAlign .end,
1533
+ style: TextStyle (
1534
+ color: designVariables.btnLabelAttLowIntDanger,
1535
+ fontSize: 12 ,
1536
+ height: 12 / 12 ,
1537
+ letterSpacing: proportionalLetterSpacing (
1538
+ context, 0.006 , baseFontSize: 12 ),
1539
+ ).merge (weightVariableTextStyle (context, wght: 400 )));
1540
+ }
1541
+
1542
+ return GestureDetector (
1543
+ onTap: handleTap,
1544
+ behavior: HitTestBehavior .opaque,
1545
+ child: Opacity (opacity: opacity, child: Padding (
1546
+ padding: const EdgeInsets .symmetric (vertical: 4 ),
1547
+ child: Column (children: [
1548
+ if (item.showSender)
1549
+ _SenderRow (message: item.message, showTimestamp: false ),
1550
+ Padding (
1551
+ padding: const EdgeInsets .symmetric (horizontal: 16 ),
1552
+ child: Column (crossAxisAlignment: CrossAxisAlignment .stretch,
1553
+ children: [
1554
+ // This is adapated from [MessageContent].
1555
+ // TODO(#576): Offer InheritedMessage ancestor once we are ready
1556
+ // to support local echoing images and lightbox.
1557
+ DefaultTextStyle (
1558
+ style: ContentTheme .of (context).textStylePlainParagraph,
1559
+ child: BlockContentList (nodes: item.content.nodes)),
1560
+
1561
+ bottom,
1562
+ ])),
1563
+ ]))));
1498
1564
}
1499
1565
}
0 commit comments