mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: dynamic panel
This commit is contained in:
@@ -36,6 +36,7 @@ class Content extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
TextStyle authorStyle =
|
TextStyle authorStyle =
|
||||||
TextStyle(color: Theme.of(context).colorScheme.primary);
|
TextStyle(color: Theme.of(context).colorScheme.primary);
|
||||||
|
InlineSpan? richNodes = richNode(item, context);
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
@@ -51,25 +52,26 @@ class Content extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
IgnorePointer(
|
if (richNodes != null)
|
||||||
// 禁用SelectableRegion的触摸交互功能
|
IgnorePointer(
|
||||||
ignoring: source == 'detail' ? false : true,
|
// 禁用SelectableRegion的触摸交互功能
|
||||||
child: 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(),
|
||||||
/// fix 默认20px高度
|
child: Text.rich(
|
||||||
style: TextStyle(
|
/// fix 默认20px高度
|
||||||
height: 0,
|
style: TextStyle(
|
||||||
fontSize: source == 'detail' ? 16 : 15,
|
height: 0,
|
||||||
|
fontSize: source == 'detail' ? 16 : 15,
|
||||||
|
),
|
||||||
|
richNodes,
|
||||||
|
maxLines: source == 'detail' ? 999 : 6,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
richNode(item, context),
|
|
||||||
maxLines: source == 'detail' ? 999 : 6,
|
|
||||||
overflow: 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)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class ContentGrpc extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
TextStyle authorStyle =
|
TextStyle authorStyle =
|
||||||
TextStyle(color: Theme.of(context).colorScheme.primary);
|
TextStyle(color: Theme.of(context).colorScheme.primary);
|
||||||
|
InlineSpan? richNodes = richNode(item, context);
|
||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 6),
|
padding: const EdgeInsets.fromLTRB(12, 0, 12, 6),
|
||||||
@@ -53,22 +53,23 @@ class ContentGrpc extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
IgnorePointer(
|
if (richNodes != null)
|
||||||
// 禁用SelectableRegion的触摸交互功能
|
IgnorePointer(
|
||||||
ignoring: source == 'detail' ? false : true,
|
// 禁用SelectableRegion的触摸交互功能
|
||||||
child: 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(),
|
||||||
/// fix 默认20px高度
|
child: Text.rich(
|
||||||
style: const TextStyle(height: 0),
|
/// fix 默认20px高度
|
||||||
richNode(item, context),
|
style: const TextStyle(height: 0),
|
||||||
maxLines: source == 'detail' ? 999 : 6,
|
richNodes,
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: source == 'detail' ? 999 : 6,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
if (item.modules.first.moduleDynamic.hasDynDraw())
|
if (item.modules.first.moduleDynamic.hasDynDraw())
|
||||||
Text.rich(
|
Text.rich(
|
||||||
picsNodes(),
|
picsNodes(),
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ Widget forWard(item, context, ctr, source, {floor = 1}) {
|
|||||||
if (hasPics) {
|
if (hasPics) {
|
||||||
pics = item.modules.moduleDynamic.major.opus.pics;
|
pics = item.modules.moduleDynamic.major.opus.pics;
|
||||||
}
|
}
|
||||||
|
InlineSpan? richNodes = richNode(item, context);
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
// 图文
|
// 图文
|
||||||
case 'DYNAMIC_TYPE_DRAW':
|
case 'DYNAMIC_TYPE_DRAW':
|
||||||
@@ -89,12 +90,13 @@ Widget forWard(item, context, ctr, source, {floor = 1}) {
|
|||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ],
|
// ],
|
||||||
Text.rich(
|
if (richNodes != null)
|
||||||
richNode(item, context),
|
Text.rich(
|
||||||
// 被转发状态(floor=2) 隐藏
|
richNodes,
|
||||||
maxLines: source == 'detail' && floor != 2 ? 999 : 4,
|
// 被转发状态(floor=2) 隐藏
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: source == 'detail' && floor != 2 ? 999 : 4,
|
||||||
),
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
if (hasPics) ...[
|
if (hasPics) ...[
|
||||||
Text.rich(
|
Text.rich(
|
||||||
picsNodes(pics),
|
picsNodes(pics),
|
||||||
@@ -180,12 +182,13 @@ Widget forWard(item, context, ctr, source, {floor = 1}) {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text.rich(
|
if (richNodes != null)
|
||||||
richNode(item, context),
|
Text.rich(
|
||||||
// 被转发状态(floor=2) 隐藏
|
richNodes,
|
||||||
maxLines: source == 'detail' && floor != 2 ? 999 : 4,
|
// 被转发状态(floor=2) 隐藏
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: source == 'detail' && floor != 2 ? 999 : 4,
|
||||||
),
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: item.modules.moduleDynamic.additional != null
|
: item.modules.moduleDynamic.additional != null
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ Widget livePanel(item, context, {floor = 1}) {
|
|||||||
dynamic content = item.modules.moduleDynamic.major;
|
dynamic content = item.modules.moduleDynamic.major;
|
||||||
TextStyle authorStyle =
|
TextStyle authorStyle =
|
||||||
TextStyle(color: Theme.of(context).colorScheme.primary);
|
TextStyle(color: Theme.of(context).colorScheme.primary);
|
||||||
|
InlineSpan? richNodes = richNode(item, context);
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -50,7 +51,7 @@ Widget livePanel(item, context, {floor = 1}) {
|
|||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
],
|
],
|
||||||
if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[
|
if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[
|
||||||
Text.rich(richNode(item, context)),
|
if (richNodes != null) Text.rich(richNodes),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
],
|
],
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ Widget liveRcmdPanel(item, context, {floor = 1}) {
|
|||||||
DynamicLiveModel liveRcmd = item.modules.moduleDynamic.major.liveRcmd;
|
DynamicLiveModel liveRcmd = item.modules.moduleDynamic.major.liveRcmd;
|
||||||
int liveStatus = liveRcmd.liveStatus!;
|
int liveStatus = liveRcmd.liveStatus!;
|
||||||
Map watchedShow = liveRcmd.watchedShow!;
|
Map watchedShow = liveRcmd.watchedShow!;
|
||||||
|
InlineSpan? richNodes = richNode(item, context);
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -56,7 +57,7 @@ Widget liveRcmdPanel(item, context, {floor = 1}) {
|
|||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
],
|
],
|
||||||
if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[
|
if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[
|
||||||
Text.rich(richNode(item, context)),
|
if (richNodes != null) Text.rich(richNodes),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
],
|
],
|
||||||
Padding(
|
Padding(
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPalaX/models/dynamics/result.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -6,21 +7,21 @@ import 'package:PiliPalaX/http/search.dart';
|
|||||||
import 'package:PiliPalaX/utils/app_scheme.dart';
|
import 'package:PiliPalaX/utils/app_scheme.dart';
|
||||||
|
|
||||||
// 富文本
|
// 富文本
|
||||||
InlineSpan richNode(item, context) {
|
InlineSpan? richNode(item, context) {
|
||||||
final spacer = _VerticalSpaceSpan(0.0);
|
final spacer = _VerticalSpaceSpan(0.0);
|
||||||
try {
|
try {
|
||||||
TextStyle authorStyle =
|
TextStyle authorStyle =
|
||||||
TextStyle(color: Theme.of(context).colorScheme.primary);
|
TextStyle(color: Theme.of(context).colorScheme.primary);
|
||||||
List<InlineSpan> spanChildren = [];
|
List<InlineSpan> spanChildren = [];
|
||||||
|
|
||||||
dynamic richTextNodes;
|
List<RichTextNodeItem>? richTextNodes;
|
||||||
if (item.modules.moduleDynamic.desc != null) {
|
if (item.modules.moduleDynamic.desc != null) {
|
||||||
richTextNodes = item.modules.moduleDynamic.desc.richTextNodes;
|
richTextNodes = item.modules.moduleDynamic.desc.richTextNodes;
|
||||||
} else if (item.modules.moduleDynamic.major != null) {
|
} else if (item.modules.moduleDynamic.major != null) {
|
||||||
// 动态页面 richTextNodes 层级可能与主页动态层级不同
|
// 动态页面 richTextNodes 层级可能与主页动态层级不同
|
||||||
richTextNodes =
|
richTextNodes =
|
||||||
item.modules.moduleDynamic.major.opus.summary.richTextNodes;
|
item.modules.moduleDynamic.major.opus?.summary?.richTextNodes;
|
||||||
if (item.modules.moduleDynamic.major.opus.title != null) {
|
if (item.modules.moduleDynamic.major.opus?.title != null) {
|
||||||
spanChildren.add(
|
spanChildren.add(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: item.modules.moduleDynamic.major.opus.title + '\n',
|
text: item.modules.moduleDynamic.major.opus.title + '\n',
|
||||||
@@ -33,7 +34,7 @@ InlineSpan richNode(item, context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (richTextNodes == null || richTextNodes.isEmpty) {
|
if (richTextNodes == null || richTextNodes.isEmpty) {
|
||||||
return spacer;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
for (var i in richTextNodes) {
|
for (var i in richTextNodes) {
|
||||||
/// fix 渲染专栏时内容会重复
|
/// fix 渲染专栏时内容会重复
|
||||||
@@ -96,7 +97,11 @@ InlineSpan richNode(item, context) {
|
|||||||
alignment: PlaceholderAlignment.middle,
|
alignment: PlaceholderAlignment.middle,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
String url = i.origText;
|
String? url = i.origText;
|
||||||
|
if (url == null) {
|
||||||
|
SmartDialog.showToast('未获取到链接');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (url.startsWith('//')) {
|
if (url.startsWith('//')) {
|
||||||
url = url.replaceFirst('//', 'https://');
|
url = url.replaceFirst('//', 'https://');
|
||||||
PiliScheme.routePush(Uri.parse(url));
|
PiliScheme.routePush(Uri.parse(url));
|
||||||
@@ -114,7 +119,7 @@ InlineSpan richNode(item, context) {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
i.text,
|
i.text ?? '',
|
||||||
style: authorStyle,
|
style: authorStyle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -150,14 +155,14 @@ InlineSpan richNode(item, context) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
// 表情
|
// 表情
|
||||||
if (i.type == 'RICH_TEXT_NODE_TYPE_EMOJI') {
|
if (i.type == 'RICH_TEXT_NODE_TYPE_EMOJI' && i.emoji != null) {
|
||||||
spanChildren.add(
|
spanChildren.add(
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
child: NetworkImgLayer(
|
child: NetworkImgLayer(
|
||||||
src: i.emoji.iconUrl,
|
src: i.emoji!.iconUrl,
|
||||||
type: 'emote',
|
type: 'emote',
|
||||||
width: i.emoji.size * 20,
|
width: (i.emoji!.size ?? 1) * 20,
|
||||||
height: i.emoji.size * 20,
|
height: (i.emoji!.size ?? 1) * 20,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ Widget videoSeasonWidget(item, context, type, {floor = 1}) {
|
|||||||
'pgc': item.modules.moduleDynamic.major.pgc
|
'pgc': item.modules.moduleDynamic.major.pgc
|
||||||
};
|
};
|
||||||
dynamic content = dynamicProperty[type];
|
dynamic content = dynamicProperty[type];
|
||||||
|
InlineSpan? richNodes = richNode(item, context);
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@@ -73,7 +73,7 @@ Widget videoSeasonWidget(item, context, type, {floor = 1}) {
|
|||||||
// const SizedBox(height: 6),
|
// const SizedBox(height: 6),
|
||||||
// ],
|
// ],
|
||||||
if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[
|
if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[
|
||||||
Text.rich(richNode(item, context)),
|
if (richNodes != null) Text.rich(richNodes),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
],
|
],
|
||||||
Padding(
|
Padding(
|
||||||
|
|||||||
Reference in New Issue
Block a user