@@ -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' ;
@@ -1479,21 +1480,67 @@ class OutboxMessageWithPossibleSender extends StatelessWidget {
14791480
14801481 final MessageListOutboxMessageItem item;
14811482
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+
14821500 @override
14831501 Widget build (BuildContext context) {
1502+ final designVariables = DesignVariables .of (context);
1503+ final zulipLocalizations = ZulipLocalizations .of (context);
14841504 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),
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- ]));
1505+ final opacity = message.state == OutboxMessageLifecycle .failed ? 0.6 : 1.0 ;
1506+
1507+ final isComposeBoxOffered =
1508+ MessageListPage .ancestorOf (context).composeBoxController != null ;
1509+
1510+ return GestureDetector (
1511+ onTap: isComposeBoxOffered && message.state == OutboxMessageLifecycle .failed
1512+ ? () => _handlePress (context) : null ,
1513+ behavior: HitTestBehavior .opaque,
1514+ child: Padding (
1515+ padding: const EdgeInsets .symmetric (vertical: 4 ),
1516+ child: Column (children: [
1517+ if (item.showSender) Opacity (opacity: opacity, child: _SenderRow (message: message)),
1518+ Padding (
1519+ padding: const EdgeInsets .symmetric (horizontal: 16 ),
1520+ child: Column (crossAxisAlignment: CrossAxisAlignment .stretch,
1521+ children: [
1522+ Opacity (opacity: opacity,
1523+ // This is adapated from [MessageContent].
1524+ // TODO(#576): Offer InheritedMessage ancestor once we are ready
1525+ // to support local echoing images and lightbox.
1526+ child: DefaultTextStyle (
1527+ style: ContentTheme .of (context).textStylePlainParagraph,
1528+ child: BlockContentList (nodes: item.content.nodes))),
1529+
1530+ if (message.state == OutboxMessageLifecycle .failed)
1531+ Text (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+ else LinearProgressIndicator (minHeight: 2 ,
1541+ color: designVariables.foreground.withFadedAlpha (0.5 ),
1542+ backgroundColor: designVariables.foreground.withFadedAlpha (0.2 )),
1543+ ])),
1544+ ])));
14981545 }
14991546}
0 commit comments