diff --git a/lib/http/msg.dart b/lib/http/msg.dart index b3b94a6c..d66b774a 100644 --- a/lib/http/msg.dart +++ b/lib/http/msg.dart @@ -116,6 +116,7 @@ class MsgHttp { int? publishTime, ReplyOptionType? replyOption, int? privatePub, + List>? extraContent, }) async { var res = await Request().post( Api.createDynamic, @@ -133,7 +134,8 @@ class MsgHttp { "raw_text": rawText, "type": 1, "biz_id": "", - } + }, + if (extraContent != null) ...extraContent, ] }, if (privatePub != null || replyOption != null || publishTime != null) diff --git a/lib/pages/dynamics/widgets/content_panel.dart b/lib/pages/dynamics/widgets/content_panel.dart index a6a3d002..76ac66f1 100644 --- a/lib/pages/dynamics/widgets/content_panel.dart +++ b/lib/pages/dynamics/widgets/content_panel.dart @@ -15,27 +15,6 @@ Widget content( Function(List, int)? callback, { floor = 1, }) { - InlineSpan picsNodes() { - return WidgetSpan( - child: LayoutBuilder( - builder: (context, constraints) => imageView( - constraints.maxWidth, - (item.modules.moduleDynamic!.major!.opus!.pics as List) - .map( - (item) => ImageModel( - width: item.width, - height: item.height, - url: item.url ?? '', - liveUrl: item.liveUrl, - ), - ) - .toList(), - callback: callback, - ), - ), - ); - } - TextSpan? richNodes = richNode(theme, item, context); return Padding( @@ -98,7 +77,26 @@ Widget content( overflow: isSave ? null : TextOverflow.ellipsis, ), if (item.modules.moduleDynamic?.major?.opus?.pics?.isNotEmpty == true) - Text.rich(picsNodes()), + Text.rich( + WidgetSpan( + child: LayoutBuilder( + builder: (context, constraints) => imageView( + constraints.maxWidth, + (item.modules.moduleDynamic!.major!.opus!.pics as List) + .map( + (item) => ImageModel( + width: item.width, + height: item.height, + url: item.url ?? '', + liveUrl: item.liveUrl, + ), + ) + .toList(), + callback: callback, + ), + ), + ), + ), ], ), ); diff --git a/lib/pages/dynamics/widgets/rich_node_panel.dart b/lib/pages/dynamics/widgets/rich_node_panel.dart index 682adc46..89fd0dc9 100644 --- a/lib/pages/dynamics/widgets/rich_node_panel.dart +++ b/lib/pages/dynamics/widgets/rich_node_panel.dart @@ -94,17 +94,13 @@ TextSpan? richNode( ) ..add( TextSpan( - text: i.text ?? '', + text: i.text, style: style, - recognizer: TapGestureRecognizer() - ..onTap = () { - String? url = i.origText; - if (url == null) { - SmartDialog.showToast('未获取到链接'); - return; - } - PiliScheme.routePushFromUrl(url); - }, + recognizer: i.origText == null + ? null + : (TapGestureRecognizer() + ..onTap = + () => PiliScheme.routePushFromUrl(i.origText!)), ), ); break; @@ -261,10 +257,7 @@ TextSpan? richNode( break; default: spanChildren.add( - TextSpan( - text: '${i.text}', - style: style, - ), + TextSpan(text: i.text, style: style), ); break; } diff --git a/lib/pages/dynamics_repost/view.dart b/lib/pages/dynamics_repost/view.dart index 4b41192b..72e1f42d 100644 --- a/lib/pages/dynamics_repost/view.dart +++ b/lib/pages/dynamics_repost/view.dart @@ -339,6 +339,45 @@ class _RepostPanelState extends CommonPublishPageState { @override Widget? get customPanel => EmotePanel(onChoose: onChooseEmote); + List>? extraContent(DynamicItemModel item) { + try { + return [ + {"raw_text": "//", "type": 1, "biz_id": ""}, + { + "raw_text": "@${item.modules.moduleAuthor!.name}", + "type": 2, + "biz_id": item.modules.moduleAuthor!.mid.toString(), + }, + {"raw_text": ":", "type": 1, "biz_id": ""}, + ...item.modules.moduleDynamic!.desc!.richTextNodes!.map( + (e) { + int? type; + String? bizId; + switch (e.type) { + case 'RICH_TEXT_NODE_TYPE_EMOJI': + type = 9; + bizId = ''; + case 'RICH_TEXT_NODE_TYPE_AT': + type = 2; + bizId = e.rid; + case 'RICH_TEXT_NODE_TYPE_TEXT': + default: + type = 1; + bizId = ''; + } + return { + "raw_text": e.origText, + "type": type, + "biz_id": bizId, + }; + }, + ), + ]; + } catch (_) { + return null; + } + } + @override Future onCustomPublish( {required String message, List? pictures}) async { @@ -348,6 +387,8 @@ class _RepostPanelState extends CommonPublishPageState { rid: widget.rid, dynType: widget.dynType, rawText: editController.text, + extraContent: + widget.item?.orig != null ? extraContent(widget.item!) : null, ); if (result['status']) { Get.back();