mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: show RICH_TEXT_NODE_TYPE_VIEW_PICTURE
Closes #691 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -145,8 +145,9 @@ class MsgHttp {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
if (replyOption != null || publishTime != null)
|
if (privatePub != null || replyOption != null || publishTime != null)
|
||||||
"option": {
|
"option": {
|
||||||
|
if (privatePub != null) 'private_pub': privatePub,
|
||||||
if (publishTime != null) "timer_pub_time": publishTime,
|
if (publishTime != null) "timer_pub_time": publishTime,
|
||||||
if (replyOption == ReplyOption.close)
|
if (replyOption == ReplyOption.close)
|
||||||
"close_comment": 1
|
"close_comment": 1
|
||||||
@@ -160,10 +161,6 @@ class MsgHttp {
|
|||||||
: pics != null
|
: pics != null
|
||||||
? 2
|
? 2
|
||||||
: 1,
|
: 1,
|
||||||
if (privatePub != null)
|
|
||||||
'create_option': {
|
|
||||||
'private_pub': privatePub,
|
|
||||||
},
|
|
||||||
if (pics != null) 'pics': pics,
|
if (pics != null) 'pics': pics,
|
||||||
"attach_card": null,
|
"attach_card": null,
|
||||||
"upload_id":
|
"upload_id":
|
||||||
|
|||||||
@@ -598,6 +598,7 @@ class RichTextNodeItem {
|
|||||||
String? text;
|
String? text;
|
||||||
String? type;
|
String? type;
|
||||||
String? rid;
|
String? rid;
|
||||||
|
List<OpusPicsModel>? pics;
|
||||||
|
|
||||||
RichTextNodeItem.fromJson(Map<String, dynamic> json) {
|
RichTextNodeItem.fromJson(Map<String, dynamic> json) {
|
||||||
emoji = json['emoji'] != null ? Emoji.fromJson(json['emoji']) : null;
|
emoji = json['emoji'] != null ? Emoji.fromJson(json['emoji']) : null;
|
||||||
@@ -605,6 +606,11 @@ class RichTextNodeItem {
|
|||||||
text = json['text'];
|
text = json['text'];
|
||||||
type = json['type'];
|
type = json['type'];
|
||||||
rid = json['rid'];
|
rid = json['rid'];
|
||||||
|
pics = json['pics'] == null
|
||||||
|
? null
|
||||||
|
: (json['pics'] as List?)
|
||||||
|
?.map((e) => OpusPicsModel.fromJson(e))
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,24 +45,22 @@ Widget content(bool isSave, BuildContext context, item, source, callback) {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
if (richNodes != null)
|
if (richNodes != null)
|
||||||
IgnorePointer(
|
source == 'detail'
|
||||||
// 禁用SelectableRegion的触摸交互功能
|
? SelectableRegion(
|
||||||
ignoring: source == 'detail' ? false : true,
|
magnifierConfiguration: const TextMagnifierConfiguration(),
|
||||||
child: SelectableRegion(
|
focusNode: FocusNode(),
|
||||||
magnifierConfiguration: const TextMagnifierConfiguration(),
|
selectionControls: MaterialTextSelectionControls(),
|
||||||
focusNode: FocusNode(),
|
child: Text.rich(
|
||||||
selectionControls: MaterialTextSelectionControls(),
|
style: TextStyle(fontSize: !isSave ? 16 : 15),
|
||||||
child: Text.rich(
|
richNodes,
|
||||||
/// fix 默认20px高度
|
),
|
||||||
style: TextStyle(
|
)
|
||||||
fontSize: source == 'detail' && !isSave ? 16 : 15,
|
: Text.rich(
|
||||||
|
style: const TextStyle(fontSize: 15),
|
||||||
|
richNodes,
|
||||||
|
maxLines: 6,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
richNodes,
|
|
||||||
maxLines: source == 'detail' ? null : 6,
|
|
||||||
overflow: source == 'detail' ? null : TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (item.modules.moduleDynamic.major != null &&
|
if (item.modules.moduleDynamic.major != null &&
|
||||||
item.modules.moduleDynamic.major.opus != null &&
|
item.modules.moduleDynamic.major.opus != null &&
|
||||||
item.modules.moduleDynamic.major.opus.pics.isNotEmpty)
|
item.modules.moduleDynamic.major.opus.pics.isNotEmpty)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPlus/common/widgets/image_view.dart';
|
||||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -8,7 +9,7 @@ import 'package:PiliPlus/http/search.dart';
|
|||||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||||
|
|
||||||
// 富文本
|
// 富文本
|
||||||
InlineSpan? richNode(item, context) {
|
InlineSpan? richNode(item, BuildContext context) {
|
||||||
final spacer = _VerticalSpaceSpan(0.0);
|
final spacer = _VerticalSpaceSpan(0.0);
|
||||||
try {
|
try {
|
||||||
TextStyle authorStyle =
|
TextStyle authorStyle =
|
||||||
@@ -256,8 +257,37 @@ InlineSpan? richNode(item, context) {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else if (i.type == 'RICH_TEXT_NODE_TYPE_VIEW_PICTURE') {
|
||||||
|
if (i.pics?.isNotEmpty == true) {
|
||||||
|
spanChildren.add(
|
||||||
|
WidgetSpan(
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
return imageView(
|
||||||
|
constraints.maxWidth,
|
||||||
|
i.pics!
|
||||||
|
.map((item) => ImageModel(
|
||||||
|
url: item.src ?? '',
|
||||||
|
width: item.width,
|
||||||
|
height: item.height,
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
spanChildren.add(
|
||||||
|
TextSpan(
|
||||||
|
text: '${i.text}',
|
||||||
|
style: authorStyle,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (contentType == 'major' &&
|
// if (contentType == 'major' &&
|
||||||
// item.modules.moduleDynamic.major.opus.pics.isNotEmpty) {
|
// item.modules.moduleDynamic.major.opus.pics.isNotEmpty) {
|
||||||
// // 图片可能跟其他widget重复渲染
|
// // 图片可能跟其他widget重复渲染
|
||||||
|
|||||||
Reference in New Issue
Block a user