@@ -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' ;
@@ -1483,21 +1484,68 @@ class OutboxMessageWithPossibleSender extends StatelessWidget {
14831484
14841485 final MessageListOutboxMessageItem item;
14851486
1487+ // TODO should we restore the topic as well?
1488+ void _handlePress (BuildContext context) {
1489+ final content = item.message.content.endsWith ('\n ' )
1490+ ? item.message.content : '${item .message .content }\n ' ;
1491+
1492+ final composeBoxController =
1493+ MessageListPage .ancestorOf (context).composeBoxController;
1494+ composeBoxController! .content.insertPadded (content);
1495+ if (! composeBoxController.contentFocusNode.hasFocus) {
1496+ composeBoxController.contentFocusNode.requestFocus ();
1497+ }
1498+
1499+ final store = PerAccountStoreWidget .of (context);
1500+ assert (store.outboxMessages.containsKey (item.message.localMessageId));
1501+ store.removeOutboxMessage (item.message.localMessageId);
1502+ }
1503+
14861504 @override
14871505 Widget build (BuildContext context) {
1506+ final designVariables = DesignVariables .of (context);
1507+ final zulipLocalizations = ZulipLocalizations .of (context);
14881508 final message = item.message;
1489- return Padding (
1490- padding: const EdgeInsets .symmetric (vertical: 4 ),
1491- child: Column (children: [
1492- if (item.showSender) _SenderRow (message: message, showTimestamp: false ),
1493- Padding (
1494- padding: const EdgeInsets .symmetric (horizontal: 16 ),
1495- // This is adapated from [MessageContent].
1496- // TODO(#576): Offer InheritedMessage ancestor once we are ready
1497- // to support local echoing images and lightbox.
1498- child: DefaultTextStyle (
1499- style: ContentTheme .of (context).textStylePlainParagraph,
1500- child: BlockContentList (nodes: item.content.nodes))),
1501- ]));
1509+ final opacity = message.state == OutboxMessageLifecycle .failed ? 0.6 : 1.0 ;
1510+
1511+ final isComposeBoxOffered =
1512+ MessageListPage .ancestorOf (context).composeBoxController != null ;
1513+
1514+ return GestureDetector (
1515+ onTap: isComposeBoxOffered && message.state == OutboxMessageLifecycle .failed
1516+ ? () => _handlePress (context) : null ,
1517+ behavior: HitTestBehavior .opaque,
1518+ child: Padding (
1519+ padding: const EdgeInsets .symmetric (vertical: 4 ),
1520+ child: Column (children: [
1521+ if (item.showSender) Opacity (opacity: opacity,
1522+ child: _SenderRow (message: message, showTimestamp: false )),
1523+ Padding (
1524+ padding: const EdgeInsets .symmetric (horizontal: 16 ),
1525+ child: Column (crossAxisAlignment: CrossAxisAlignment .stretch,
1526+ children: [
1527+ Opacity (opacity: opacity,
1528+ // This is adapated from [MessageContent].
1529+ // TODO(#576): Offer InheritedMessage ancestor once we are ready
1530+ // to support local echoing images and lightbox.
1531+ child: DefaultTextStyle (
1532+ style: ContentTheme .of (context).textStylePlainParagraph,
1533+ child: BlockContentList (nodes: item.content.nodes))),
1534+
1535+ if (message.state == OutboxMessageLifecycle .failed)
1536+ Text (zulipLocalizations.messageIsntSentLabel,
1537+ textAlign: TextAlign .end,
1538+ style: TextStyle (
1539+ color: designVariables.btnLabelAttLowIntDanger,
1540+ fontSize: 12 ,
1541+ height: 12 / 12 ,
1542+ letterSpacing: proportionalLetterSpacing (
1543+ context, 0.006 , baseFontSize: 12 ),
1544+ ).merge (weightVariableTextStyle (context, wght: 400 )))
1545+ else LinearProgressIndicator (minHeight: 2 ,
1546+ color: designVariables.foreground.withFadedAlpha (0.5 ),
1547+ backgroundColor: designVariables.foreground.withFadedAlpha (0.2 )),
1548+ ])),
1549+ ])));
15021550 }
15031551}
0 commit comments