mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt repost dyn
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -116,6 +116,7 @@ class MsgHttp {
|
||||
int? publishTime,
|
||||
ReplyOptionType? replyOption,
|
||||
int? privatePub,
|
||||
List<Map<String, dynamic>>? 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)
|
||||
|
||||
@@ -15,27 +15,6 @@ Widget content(
|
||||
Function(List<String>, 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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -339,6 +339,45 @@ class _RepostPanelState extends CommonPublishPageState<RepostPanel> {
|
||||
@override
|
||||
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
|
||||
Future<void> onCustomPublish(
|
||||
{required String message, List? pictures}) async {
|
||||
@@ -348,6 +387,8 @@ class _RepostPanelState extends CommonPublishPageState<RepostPanel> {
|
||||
rid: widget.rid,
|
||||
dynType: widget.dynType,
|
||||
rawText: editController.text,
|
||||
extraContent:
|
||||
widget.item?.orig != null ? extraContent(widget.item!) : null,
|
||||
);
|
||||
if (result['status']) {
|
||||
Get.back();
|
||||
|
||||
Reference in New Issue
Block a user