@@ -8,6 +8,7 @@ import 'package:intl/intl.dart' hide TextDirection;
88
99import '../api/model/model.dart' ;
1010import '../generated/l10n/zulip_localizations.dart' ;
11+ import '../model/message.dart' ;
1112import '../model/message_list.dart' ;
1213import '../model/narrow.dart' ;
1314import '../model/store.dart' ;
@@ -1481,21 +1482,67 @@ class OutboxMessageWithPossibleSender extends StatelessWidget {
14811482
14821483 final MessageListOutboxMessageItem item;
14831484
1485+ // TODO should we restore the topic as well?
1486+ void _handlePress (BuildContext context) {
1487+ final content = item.message.content.endsWith ('\n ' )
1488+ ? item.message.content : '${item .message .content }\n ' ;
1489+
1490+ final composeBoxController =
1491+ MessageListPage .ancestorOf (context).composeBoxController;
1492+ composeBoxController! .content.insertPadded (content);
1493+ if (! composeBoxController.contentFocusNode.hasFocus) {
1494+ composeBoxController.contentFocusNode.requestFocus ();
1495+ }
1496+
1497+ final store = PerAccountStoreWidget .of (context);
1498+ assert (store.outboxMessages.containsKey (item.message.localMessageId));
1499+ store.removeOutboxMessage (item.message.localMessageId);
1500+ }
1501+
14841502 @override
14851503 Widget build (BuildContext context) {
1504+ final designVariables = DesignVariables .of (context);
1505+ final zulipLocalizations = ZulipLocalizations .of (context);
14861506 final message = item.message;
1487- return Padding (
1488- padding: const EdgeInsets .symmetric (vertical: 4 ),
1489- child: Column (children: [
1490- if (item.showSender) _SenderRow (message: message),
1491- Padding (
1492- padding: const EdgeInsets .symmetric (horizontal: 16 ),
1493- // This is adapated from [MessageContent].
1494- // TODO(#576): Offer InheritedMessage ancestor once we are ready
1495- // to support local echoing images and lightbox.
1496- child: DefaultTextStyle (
1497- style: ContentTheme .of (context).textStylePlainParagraph,
1498- child: BlockContentList (nodes: item.content.nodes))),
1499- ]));
1507+ final opacity = message.state == OutboxMessageLifecycle .failed ? 0.6 : 1.0 ;
1508+
1509+ final isComposeBoxOffered =
1510+ MessageListPage .ancestorOf (context).composeBoxController != null ;
1511+
1512+ return GestureDetector (
1513+ onTap: isComposeBoxOffered && message.state == OutboxMessageLifecycle .failed
1514+ ? () => _handlePress (context) : null ,
1515+ behavior: HitTestBehavior .opaque,
1516+ child: Padding (
1517+ padding: const EdgeInsets .symmetric (vertical: 4 ),
1518+ child: Column (children: [
1519+ if (item.showSender) Opacity (opacity: opacity, child: _SenderRow (message: message)),
1520+ Padding (
1521+ padding: const EdgeInsets .symmetric (horizontal: 16 ),
1522+ child: Column (crossAxisAlignment: CrossAxisAlignment .stretch,
1523+ children: [
1524+ Opacity (opacity: opacity,
1525+ // This is adapated from [MessageContent].
1526+ // TODO(#576): Offer InheritedMessage ancestor once we are ready
1527+ // to support local echoing images and lightbox.
1528+ child: DefaultTextStyle (
1529+ style: ContentTheme .of (context).textStylePlainParagraph,
1530+ child: BlockContentList (nodes: item.content.nodes))),
1531+
1532+ if (message.state == OutboxMessageLifecycle .failed)
1533+ Text (zulipLocalizations.messageIsntSentLabel,
1534+ textAlign: TextAlign .end,
1535+ style: TextStyle (
1536+ color: designVariables.btnLabelAttLowIntDanger,
1537+ fontSize: 12 ,
1538+ height: 12 / 12 ,
1539+ letterSpacing: proportionalLetterSpacing (
1540+ context, 0.006 , baseFontSize: 12 ),
1541+ ).merge (weightVariableTextStyle (context, wght: 400 )))
1542+ else LinearProgressIndicator (minHeight: 2 ,
1543+ color: designVariables.foreground.withFadedAlpha (0.5 ),
1544+ backgroundColor: designVariables.foreground.withFadedAlpha (0.2 )),
1545+ ])),
1546+ ])));
15001547 }
15011548}
0 commit comments