feat: 图文动态详情页&评论渲染
This commit is contained in:
139
lib/pages/dynamics/widgets/forward_panel.dart
Normal file
139
lib/pages/dynamics/widgets/forward_panel.dart
Normal file
@ -0,0 +1,139 @@
|
||||
// 转发
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
import 'article_panel.dart';
|
||||
import 'live_rcmd_panel.dart';
|
||||
import 'pic_panel.dart';
|
||||
import 'rich_node_panel.dart';
|
||||
import 'video_panel.dart';
|
||||
|
||||
Widget forWard(item, context, ctr, source, {floor = 1}) {
|
||||
TextStyle authorStyle =
|
||||
TextStyle(color: Theme.of(context).colorScheme.primary);
|
||||
switch (item.type) {
|
||||
// 图文
|
||||
case 'DYNAMIC_TYPE_DRAW':
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (floor == 2) ...[
|
||||
Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Text(
|
||||
'@${item.modules.moduleAuthor.name}',
|
||||
style: authorStyle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
Utils.dateFormat(item.modules.moduleAuthor.pubTs),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize:
|
||||
Theme.of(context).textTheme.labelSmall!.fontSize),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
if (item.modules.moduleDynamic.topic != null) ...[
|
||||
Padding(
|
||||
padding: floor == 2
|
||||
? EdgeInsets.zero
|
||||
: const EdgeInsets.only(left: 12, right: 12),
|
||||
child: GestureDetector(
|
||||
child: Text(
|
||||
'#${item.modules.moduleDynamic.topic.name}',
|
||||
style: authorStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
Text.rich(
|
||||
richNode(item, context),
|
||||
// 被转发状态(floor=2) 隐藏
|
||||
maxLines: source == 'detail' && floor != 2 ? 999 : 4,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
],
|
||||
Padding(
|
||||
padding: floor == 2
|
||||
? EdgeInsets.zero
|
||||
: const EdgeInsets.only(left: 12, right: 12),
|
||||
child: picWidget(item, context),
|
||||
),
|
||||
],
|
||||
);
|
||||
// 视频
|
||||
case 'DYNAMIC_TYPE_AV':
|
||||
return videoSeasonWidget(item, context, 'archive', floor: floor);
|
||||
// 文章
|
||||
case 'DYNAMIC_TYPE_ARTICLE':
|
||||
return articlePanel(item, context, floor: floor);
|
||||
// 转发
|
||||
case 'DYNAMIC_TYPE_FORWARD':
|
||||
return InkWell(
|
||||
onTap: () => ctr.pushDetail(item.orig, floor + 1),
|
||||
child: Container(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 15, top: 10, right: 15, bottom: 8),
|
||||
color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||
child: forWard(item.orig, context, ctr, source, floor: floor + 1),
|
||||
),
|
||||
);
|
||||
// 直播
|
||||
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
||||
return liveRcmdPanel(item, context, floor: floor);
|
||||
// 合集
|
||||
case 'DYNAMIC_TYPE_UGC_SEASON':
|
||||
return videoSeasonWidget(item, context, 'ugcSeason');
|
||||
case 'DYNAMIC_TYPE_WORD':
|
||||
return floor == 2
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Text(
|
||||
'@${item.modules.moduleAuthor.name}',
|
||||
style: authorStyle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
Utils.dateFormat(item.modules.moduleAuthor.pubTs),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize:
|
||||
Theme.of(context).textTheme.labelSmall!.fontSize),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(item.modules.moduleDynamic.desc.text)
|
||||
],
|
||||
)
|
||||
: const SizedBox(height: 0);
|
||||
case 'DYNAMIC_TYPE_PGC':
|
||||
return videoSeasonWidget(item, context, 'pgc', floor: floor);
|
||||
case 'DYNAMIC_TYPE_NONE':
|
||||
return Row(
|
||||
children: [
|
||||
const Icon(
|
||||
FontAwesomeIcons.ghost,
|
||||
size: 14,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(item.modules.moduleDynamic.major.none.tips)
|
||||
],
|
||||
);
|
||||
default:
|
||||
return const SizedBox(height: 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user