opt repost dyn

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-24 14:11:42 +08:00
parent b6b67884f4
commit 8e1b2be073
4 changed files with 71 additions and 37 deletions

View File

@@ -116,6 +116,7 @@ class MsgHttp {
int? publishTime, int? publishTime,
ReplyOptionType? replyOption, ReplyOptionType? replyOption,
int? privatePub, int? privatePub,
List<Map<String, dynamic>>? extraContent,
}) async { }) async {
var res = await Request().post( var res = await Request().post(
Api.createDynamic, Api.createDynamic,
@@ -133,7 +134,8 @@ class MsgHttp {
"raw_text": rawText, "raw_text": rawText,
"type": 1, "type": 1,
"biz_id": "", "biz_id": "",
} },
if (extraContent != null) ...extraContent,
] ]
}, },
if (privatePub != null || replyOption != null || publishTime != null) if (privatePub != null || replyOption != null || publishTime != null)

View File

@@ -15,27 +15,6 @@ Widget content(
Function(List<String>, int)? callback, { Function(List<String>, int)? callback, {
floor = 1, 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); TextSpan? richNodes = richNode(theme, item, context);
return Padding( return Padding(
@@ -98,7 +77,26 @@ Widget content(
overflow: isSave ? null : TextOverflow.ellipsis, overflow: isSave ? null : TextOverflow.ellipsis,
), ),
if (item.modules.moduleDynamic?.major?.opus?.pics?.isNotEmpty == true) 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,
),
),
),
),
], ],
), ),
); );

View File

@@ -94,17 +94,13 @@ TextSpan? richNode(
) )
..add( ..add(
TextSpan( TextSpan(
text: i.text ?? '', text: i.text,
style: style, style: style,
recognizer: TapGestureRecognizer() recognizer: i.origText == null
..onTap = () { ? null
String? url = i.origText; : (TapGestureRecognizer()
if (url == null) { ..onTap =
SmartDialog.showToast('未获取到链接'); () => PiliScheme.routePushFromUrl(i.origText!)),
return;
}
PiliScheme.routePushFromUrl(url);
},
), ),
); );
break; break;
@@ -261,10 +257,7 @@ TextSpan? richNode(
break; break;
default: default:
spanChildren.add( spanChildren.add(
TextSpan( TextSpan(text: i.text, style: style),
text: '${i.text}',
style: style,
),
); );
break; break;
} }

View File

@@ -339,6 +339,45 @@ class _RepostPanelState extends CommonPublishPageState<RepostPanel> {
@override @override
Widget? get customPanel => EmotePanel(onChoose: onChooseEmote); Widget? get customPanel => EmotePanel(onChoose: onChooseEmote);
List<Map<String, dynamic>>? 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 @override
Future<void> onCustomPublish( Future<void> onCustomPublish(
{required String message, List? pictures}) async { {required String message, List? pictures}) async {
@@ -348,6 +387,8 @@ class _RepostPanelState extends CommonPublishPageState<RepostPanel> {
rid: widget.rid, rid: widget.rid,
dynType: widget.dynType, dynType: widget.dynType,
rawText: editController.text, rawText: editController.text,
extraContent:
widget.item?.orig != null ? extraContent(widget.item!) : null,
); );
if (result['status']) { if (result['status']) {
Get.back(); Get.back();