mod: 页面样式调整&组件拆分

This commit is contained in:
guozhigq
2023-06-26 12:25:19 +08:00
parent 1ce12f9f28
commit 532ad52c17
14 changed files with 590 additions and 560 deletions

View File

@ -120,10 +120,9 @@ class VideoContent extends StatelessWidget {
videoItem.title, videoItem.title,
textAlign: TextAlign.start, textAlign: TextAlign.start,
style: const TextStyle( style: const TextStyle(
// fontSize: // fontSize: Theme.of(context).textTheme.titleSmall!.fontSize,
// Theme.of(context).textTheme.titleSmall!.fontSize,
fontSize: 13, fontSize: 13,
fontWeight: FontWeight.w500), ),
maxLines: Get.find<HomeController>().crossAxisCount, maxLines: Get.find<HomeController>().crossAxisCount,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),

View File

@ -256,7 +256,7 @@ class Ugc {
String? headText; String? headText;
String? idStr; String? idStr;
String? jumpUrl; String? jumpUrl;
String? multiLine; bool? multiLine;
String? title; String? title;
Ugc.fromJson(Map<String, dynamic> json) { Ugc.fromJson(Map<String, dynamic> json) {

View File

@ -0,0 +1,37 @@
// 操作栏
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:pilipala/models/dynamics/result.dart';
Widget action(item, context) {
ModuleStatModel stat = item.modules.moduleStat;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
TextButton.icon(
onPressed: () {},
icon: const Icon(
FontAwesomeIcons.shareFromSquare,
size: 16,
),
label: Text(stat.forward!.count ?? '转发'),
),
TextButton.icon(
onPressed: () {},
icon: const Icon(
FontAwesomeIcons.comment,
size: 16,
),
label: Text(stat.comment!.count ?? '评论'),
),
TextButton.icon(
onPressed: () {},
icon: const Icon(
FontAwesomeIcons.thumbsUp,
size: 16,
),
label: Text(stat.like!.count ?? '点赞'),
)
],
);
}

View File

@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:pilipala/utils/utils.dart';
import 'pic_panel.dart';
Widget articlePanel(item, context, {floor = 1}) {
TextStyle authorStyle =
TextStyle(color: Theme.of(context).colorScheme.primary);
return Padding(
padding: floor == 2
? EdgeInsets.zero
: const EdgeInsets.only(left: 12, right: 12),
child: 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: 8),
],
Text(
item.modules.moduleDynamic.major.opus.title,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontWeight: FontWeight.bold),
),
const SizedBox(height: 2),
if (item.modules.moduleDynamic.major.opus.summary.text != 'undefined')
Text(
item.modules.moduleDynamic.major.opus.summary.richTextNodes.first
.text,
maxLines: 4,
overflow: TextOverflow.ellipsis,
),
picWidget(item, context)
],
),
);
}

View File

@ -0,0 +1,30 @@
// 内容
import 'package:flutter/material.dart';
import 'rich_node_panel.dart';
Widget content(item, context) {
TextStyle authorStyle =
TextStyle(color: Theme.of(context).colorScheme.primary);
return Container(
width: double.infinity,
padding: const EdgeInsets.fromLTRB(12, 0, 12, 6),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (item.modules.moduleDynamic.topic != null) ...[
GestureDetector(
child: Text(
'#${item.modules.moduleDynamic.topic.name}',
style: authorStyle,
),
),
],
Text.rich(
richNode(item, context),
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
],
));
}

View File

@ -6,6 +6,13 @@ import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/models/dynamics/result.dart'; import 'package:pilipala/models/dynamics/result.dart';
import 'package:pilipala/utils/utils.dart'; import 'package:pilipala/utils/utils.dart';
import 'action_panel.dart';
import 'article_panel.dart';
import 'content_panel.dart';
import 'live_rcmd_panel.dart';
import 'pic_panel.dart';
import 'rich_node_panel.dart';
class DynamicPanel extends StatelessWidget { class DynamicPanel extends StatelessWidget {
DynamicItemModel? item; DynamicItemModel? item;
DynamicPanel({this.item, Key? key}); DynamicPanel({this.item, Key? key});
@ -50,7 +57,7 @@ class DynamicPanel extends StatelessWidget {
Widget author(item, context) { Widget author(item, context) {
return Container( return Container(
padding: const EdgeInsets.fromLTRB(12, 10, 12, 10), padding: const EdgeInsets.fromLTRB(12, 12, 12, 8),
child: Row( child: Row(
children: [ children: [
NetworkImgLayer( NetworkImgLayer(
@ -64,15 +71,20 @@ class DynamicPanel extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(item.modules.moduleAuthor.name), Text(item.modules.moduleAuthor.name),
Text( DefaultTextStyle.merge(
item.modules.moduleAuthor.pubTime +
(item.modules.moduleAuthor.pubAction != ''
? ' ${item.modules.moduleAuthor.pubAction}'
: ''),
style: TextStyle( style: TextStyle(
color: Theme.of(context).colorScheme.outline, color: Theme.of(context).colorScheme.outline,
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize, fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
), ),
child: Row(
children: [
Text(item.modules.moduleAuthor.pubTime),
if (item.modules.moduleAuthor.pubTime != '' &&
item.modules.moduleAuthor.pubAction != '')
const Text(' '),
Text(item.modules.moduleAuthor.pubAction),
],
),
) )
], ],
), ),
@ -81,33 +93,6 @@ class DynamicPanel extends StatelessWidget {
); );
} }
// 内容
Widget content(item, context) {
TextStyle authorStyle =
TextStyle(color: Theme.of(context).colorScheme.primary);
return Container(
width: double.infinity,
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (item.modules.moduleDynamic.topic != null) ...[
GestureDetector(
child: Text(
'#${item.modules.moduleDynamic.topic.name}',
style: authorStyle,
),
),
],
Text.rich(
richNode(item, context),
maxLines: 4,
overflow: TextOverflow.ellipsis,
),
],
));
}
// 转发 // 转发
Widget forWard(item, context, {floor = 1}) { Widget forWard(item, context, {floor = 1}) {
TextStyle authorStyle = TextStyle authorStyle =
@ -157,7 +142,6 @@ class DynamicPanel extends StatelessWidget {
maxLines: 4, maxLines: 4,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
// Text(item.modules.moduleDynamic.desc.text),
const SizedBox(height: 4), const SizedBox(height: 4),
], ],
Padding( Padding(
@ -173,240 +157,18 @@ class DynamicPanel extends StatelessWidget {
return videoSeasonWidget(item, context, 'archive', floor: floor); return videoSeasonWidget(item, context, 'archive', floor: floor);
// 文章 // 文章
case 'DYNAMIC_TYPE_ARTICLE': case 'DYNAMIC_TYPE_ARTICLE':
return Padding( return articlePanel(item, context, floor: floor);
padding: floor == 2
? EdgeInsets.zero
: const EdgeInsets.only(left: 12, right: 12),
child: 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: 8),
],
Text(
item.modules.moduleDynamic.major.opus.title,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontWeight: FontWeight.bold),
),
const SizedBox(height: 2),
if (item.modules.moduleDynamic.major.opus.summary.text !=
'undefined')
Text(
item.modules.moduleDynamic.major.opus.summary.richTextNodes
.first.text,
maxLines: 4,
overflow: TextOverflow.ellipsis,
),
picWidget(item, context)
],
),
);
// 转发 // 转发
case 'DYNAMIC_TYPE_FORWARD': case 'DYNAMIC_TYPE_FORWARD':
return Container( return Container(
padding: padding:
const EdgeInsets.only(left: 15, top: 10, right: 15, bottom: 10), const EdgeInsets.only(left: 15, top: 10, right: 15, bottom: 8),
color: Theme.of(context).dividerColor.withOpacity(0.08), color: Theme.of(context).dividerColor.withOpacity(0.08),
child: forWard(item.orig, context, floor: 2), child: forWard(item.orig, context, floor: 2),
); );
// switch (item.orig.type) {
// // 递归
// case 'DYNAMIC_TYPE_AV':
// return Container(
// padding: const EdgeInsets.only(
// left: 15, top: 10, right: 15, bottom: 10),
// color: Theme.of(context).dividerColor.withOpacity(0.08),
// child: forWard(item.orig, context, floor: 2),
// );
// case 'DYNAMIC_TYPE_DRAW':
// return Container(
// padding: const EdgeInsets.only(
// left: 15, top: 10, right: 15, bottom: 10),
// color: Theme.of(context).dividerColor.withOpacity(0.08),
// child: forWard(item.orig, context, floor: 2),
// );
// case 'DYNAMIC_TYPE_WORD':
// return Container(
// width: double.infinity,
// padding: const EdgeInsets.only(
// left: 15, top: 10, right: 15, bottom: 10),
// color: Theme.of(context).dividerColor.withOpacity(0.08),
// child: forWard(item.orig, context, floor: 2),
// );
// case 'DYNAMIC_TYPE_NONE':
// return Container(
// width: double.infinity,
// padding: const EdgeInsets.only(
// left: 15, top: 10, right: 15, bottom: 10),
// color: Theme.of(context).dividerColor.withOpacity(0.08),
// child: forWard(item.orig, context, floor: 2),
// );
// case 'DYNAMIC_TYPE_ARTICLE':
// return Container(
// width: double.infinity,
// padding: const EdgeInsets.only(
// left: 15, top: 10, right: 15, bottom: 10),
// color: Theme.of(context).dividerColor.withOpacity(0.08),
// child: forWard(item.orig, context, floor: 2),
// );
// case 'DYNAMIC_TYPE_PGC':
// return Container(
// width: double.infinity,
// padding: const EdgeInsets.only(
// left: 15, top: 10, right: 15, bottom: 10),
// color: Theme.of(context).dividerColor.withOpacity(0.08),
// child: forWard(item.orig, context, floor: 2),
// );
// case 'DYNAMIC_TYPE_LIVE_RCMD':
// return Container(
// width: double.infinity,
// padding: const EdgeInsets.only(
// left: 15, top: 10, right: 15, bottom: 10),
// color: Theme.of(context).dividerColor.withOpacity(0.08),
// child: forWard(item.orig, context, floor: 2),
// );
// default:
// return const Text('渲染出错了1');
// }
// 直播 // 直播
case 'DYNAMIC_TYPE_LIVE_RCMD': case 'DYNAMIC_TYPE_LIVE_RCMD':
return Column( return liveRcmdPanel(item, context, floor: floor);
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: 4),
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,
),
),
),
const SizedBox(height: 6),
],
if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[
Text.rich(richNode(item, context)),
const SizedBox(height: 6),
],
GestureDetector(
onTap: () {},
child: LayoutBuilder(builder: (context, box) {
double width = box.maxWidth;
return Stack(
children: [
NetworkImgLayer(
type: floor == 1 ? 'emote' : null,
width: width,
height: width / StyleString.aspectRatio,
src: item.modules.moduleDynamic.major.liveRcmd.cover,
),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: Container(
height: 80,
padding: const EdgeInsets.fromLTRB(12, 0, 10, 10),
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
gradient: const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: <Color>[
Colors.transparent,
Colors.black87,
],
),
borderRadius: floor == 1
? null
: const BorderRadius.all(Radius.circular(6))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
DefaultTextStyle.merge(
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize,
color: Colors.white),
child: Row(
children: [
Text(item.modules.moduleDynamic.major
.liveRcmd.areaName ??
''),
],
),
),
],
),
)),
],
);
}),
),
const SizedBox(height: 6),
Padding(
padding: floor == 1
? const EdgeInsets.only(left: 12, right: 12)
: EdgeInsets.zero,
child: Text(
item.modules.moduleDynamic.major.liveRcmd.title,
maxLines: 1,
style: const TextStyle(fontWeight: FontWeight.bold),
overflow: TextOverflow.ellipsis,
),
),
const SizedBox(height: 2),
],
);
// 合集 // 合集
case 'DYNAMIC_TYPE_UGC_SEASON': case 'DYNAMIC_TYPE_UGC_SEASON':
return videoSeasonWidget(item, context, 'ugcSeason'); return videoSeasonWidget(item, context, 'ugcSeason');
@ -459,100 +221,6 @@ class DynamicPanel extends StatelessWidget {
} }
} }
// 操作栏
Widget action(item, context) {
ModuleStatModel stat = item.modules.moduleStat;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
TextButton.icon(
onPressed: () {},
icon: const Icon(
FontAwesomeIcons.shareFromSquare,
size: 16,
),
label: Text(stat.forward!.count ?? '转发'),
),
TextButton.icon(
onPressed: () {},
icon: const Icon(
FontAwesomeIcons.comment,
size: 16,
),
label: Text(stat.comment!.count ?? '评论'),
),
TextButton.icon(
onPressed: () {},
icon: const Icon(
FontAwesomeIcons.thumbsUp,
size: 16,
),
label: Text(stat.like!.count ?? '点赞'),
)
],
);
}
Widget picWidget(item, context) {
String type = item.modules.moduleDynamic.major.type;
List pictures = [];
if (type == 'MAJOR_TYPE_OPUS') {
pictures = item.modules.moduleDynamic.major.opus.pics;
}
if (type == 'MAJOR_TYPE_DRAW') {
pictures = item.modules.moduleDynamic.major.draw.items;
}
int len = pictures.length;
List picList = [];
List<Widget> list = [];
for (var i = 0; i < len; i++) {
picList.add(pictures[i].src ?? pictures[i].url);
list.add(
LayoutBuilder(
builder: (context, BoxConstraints box) {
return GestureDetector(
onTap: () {
Get.toNamed('/preview',
arguments: {'initialPage': i, 'imgList': picList});
},
child: NetworkImgLayer(
src: pictures[i].src ?? pictures[i].url,
width: box.maxWidth,
height: box.maxWidth,
),
);
},
),
);
}
return LayoutBuilder(
builder: (context, BoxConstraints box) {
double maxWidth = box.maxWidth;
double crossCount = len < 3 ? 2 : 3;
double height = maxWidth /
crossCount *
(len % crossCount == 0
? len ~/ crossCount
: len ~/ crossCount + 1) +
6;
return Container(
padding: const EdgeInsets.only(top: 4),
height: height,
child: GridView.count(
padding: EdgeInsets.zero,
physics: const NeverScrollableScrollPhysics(),
crossAxisCount: crossCount.toInt(),
mainAxisSpacing: 4.0,
crossAxisSpacing: 4.0,
childAspectRatio: 1,
children: list,
),
);
},
);
}
// 视频or合集 // 视频or合集
Widget videoSeasonWidget(item, context, type, {floor = 1}) { Widget videoSeasonWidget(item, context, type, {floor = 1}) {
TextStyle authorStyle = TextStyle authorStyle =
@ -573,6 +241,7 @@ class DynamicPanel extends StatelessWidget {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
if (floor == 2) ...[ if (floor == 2) ...[
Row( Row(
@ -593,8 +262,9 @@ class DynamicPanel extends StatelessWidget {
), ),
], ],
), ),
const SizedBox(height: 6),
], ],
const SizedBox(height: 4), // const SizedBox(height: 4),
if (item.modules.moduleDynamic.topic != null) ...[ if (item.modules.moduleDynamic.topic != null) ...[
Padding( Padding(
padding: floor == 2 padding: floor == 2
@ -639,7 +309,7 @@ class DynamicPanel extends StatelessWidget {
end: Alignment.bottomCenter, end: Alignment.bottomCenter,
colors: <Color>[ colors: <Color>[
Colors.transparent, Colors.transparent,
Colors.black87, Colors.black54,
], ],
), ),
borderRadius: floor == 1 borderRadius: floor == 1
@ -669,12 +339,13 @@ class DynamicPanel extends StatelessWidget {
), ),
Image.asset( Image.asset(
'assets/images/play.png', 'assets/images/play.png',
width: 70, width: 60,
height: 70, height: 60,
), ),
], ],
), ),
)), ),
),
], ],
); );
}), }),
@ -691,126 +362,7 @@ class DynamicPanel extends StatelessWidget {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
), ),
const SizedBox(height: 2),
], ],
); );
} }
InlineSpan richNode(item, context) {
TextStyle authorStyle =
TextStyle(color: Theme.of(context).colorScheme.primary);
List<InlineSpan> spanChilds = [];
for (var i in item.modules.moduleDynamic.desc.richTextNodes) {
if (i.type == 'RICH_TEXT_NODE_TYPE_TEXT') {
spanChilds.add(TextSpan(text: i.origText));
}
// @用户
if (i.type == 'RICH_TEXT_NODE_TYPE_AT') {
spanChilds.add(
WidgetSpan(
baseline: TextBaseline.ideographic,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
GestureDetector(
onTap: () {},
child: Text(
'${i.text}',
style: authorStyle,
),
),
],
),
),
);
}
// 话题
if (i.type == 'RICH_TEXT_NODE_TYPE_TOPIC') {
spanChilds.add(
WidgetSpan(
child: GestureDetector(
onTap: () {},
child: Text(
' ${i.origText} ',
style: authorStyle,
),
),
),
);
}
// 网页链接
if (i.type == 'RICH_TEXT_NODE_TYPE_WEB') {
spanChilds.add(
WidgetSpan(
child: GestureDetector(
onTap: () {},
child: Text(
i.text,
style: authorStyle,
),
),
),
);
}
// 投票
if (i.type == 'RICH_TEXT_NODE_TYPE_VOTE') {
spanChilds.add(
WidgetSpan(
child: GestureDetector(
onTap: () {},
child: Text(
i.text,
style: authorStyle,
),
),
),
);
}
// 表情
if (i.type == 'RICH_TEXT_NODE_TYPE_EMOJI') {
spanChilds.add(
WidgetSpan(
child: NetworkImgLayer(
src: i.emoji.iconUrl,
type: 'emote',
width: i.emoji.size * 20,
height: i.emoji.size * 20,
),
),
);
}
// 抽奖
if (i.type == 'RICH_TEXT_NODE_TYPE_LOTTERY') {
spanChilds.add(
WidgetSpan(
child: GestureDetector(
onTap: () {},
child: Text(
' ${i.origText} ',
style: authorStyle,
),
),
),
);
}
/// TODO 商品
if (i.type == 'RICH_TEXT_NODE_TYPE_GOODS') {
spanChilds.add(
WidgetSpan(
child: GestureDetector(
onTap: () {},
child: Text(
' ${i.text} ',
style: authorStyle,
),
),
),
);
}
}
return TextSpan(
children: spanChilds,
);
}
} }

View File

@ -0,0 +1,126 @@
import 'package:flutter/material.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/utils/utils.dart';
import 'rich_node_panel.dart';
Widget liveRcmdPanel(item, context, {floor = 1}) {
TextStyle authorStyle =
TextStyle(color: Theme.of(context).colorScheme.primary);
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: 4),
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,
),
),
),
const SizedBox(height: 6),
],
if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[
Text.rich(richNode(item, context)),
const SizedBox(height: 6),
],
GestureDetector(
onTap: () {},
child: LayoutBuilder(builder: (context, box) {
double width = box.maxWidth;
return Stack(
children: [
NetworkImgLayer(
type: floor == 1 ? 'emote' : null,
width: width,
height: width / StyleString.aspectRatio,
src: item.modules.moduleDynamic.major.liveRcmd.cover,
),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: Container(
height: 80,
padding: const EdgeInsets.fromLTRB(12, 0, 10, 10),
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
gradient: const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: <Color>[
Colors.transparent,
Colors.black45,
],
),
borderRadius: floor == 1
? null
: const BorderRadius.all(Radius.circular(6))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
DefaultTextStyle.merge(
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize,
color: Colors.white),
child: Row(
children: [
Text(item.modules.moduleDynamic.major.liveRcmd
.areaName ??
''),
],
),
),
],
),
)),
],
);
}),
),
const SizedBox(height: 6),
Padding(
padding: floor == 1
? const EdgeInsets.only(left: 12, right: 12)
: EdgeInsets.zero,
child: Text(
item.modules.moduleDynamic.major.liveRcmd.title,
maxLines: 1,
style: const TextStyle(fontWeight: FontWeight.bold),
overflow: TextOverflow.ellipsis,
),
),
const SizedBox(height: 2),
],
);
}

View File

@ -0,0 +1,85 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
Widget picWidget(item, context) {
String type = item.modules.moduleDynamic.major.type;
List pictures = [];
if (type == 'MAJOR_TYPE_OPUS') {
pictures = item.modules.moduleDynamic.major.opus.pics;
}
if (type == 'MAJOR_TYPE_DRAW') {
pictures = item.modules.moduleDynamic.major.draw.items;
}
int len = pictures.length;
List picList = [];
List<Widget> list = [];
for (var i = 0; i < len; i++) {
picList.add(pictures[i].src ?? pictures[i].url);
list.add(
LayoutBuilder(
builder: (context, BoxConstraints box) {
return GestureDetector(
onTap: () {
Get.toNamed('/preview',
arguments: {'initialPage': i, 'imgList': picList});
},
child: Hero(
tag: pictures[i].src,
child: NetworkImgLayer(
src: pictures[i].src ?? pictures[i].url,
width: box.maxWidth,
height: box.maxWidth,
),
),
);
},
),
);
}
return LayoutBuilder(
builder: (context, BoxConstraints box) {
double maxWidth = box.maxWidth;
double aspectRatio = 1.1;
double crossCount = len == 1
? 1
: len < 3
? 2
: 3;
double height = 0.0;
if (len == 1) {
aspectRatio = pictures.first.width / pictures.first.height;
height = pictures.first.height * maxWidth / pictures.first.width;
} else {
aspectRatio = 1;
height = maxWidth /
crossCount *
(len % crossCount == 0
? len ~/ crossCount
: len ~/ crossCount + 1) +
6;
}
return Container(
padding: const EdgeInsets.only(top: 4),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(StyleString.imgRadius.x),
),
clipBehavior: Clip.hardEdge,
height: height,
child: GridView.count(
padding: EdgeInsets.zero,
physics: const NeverScrollableScrollPhysics(),
crossAxisCount: crossCount.toInt(),
mainAxisSpacing: 4.0,
crossAxisSpacing: 4.0,
childAspectRatio: aspectRatio,
children: list,
),
);
},
);
}

View File

@ -0,0 +1,136 @@
import 'package:flutter/material.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
// 富文本
InlineSpan richNode(item, context) {
TextStyle authorStyle =
TextStyle(color: Theme.of(context).colorScheme.primary);
List<InlineSpan> spanChilds = [];
for (var i in item.modules.moduleDynamic.desc.richTextNodes) {
if (i.type == 'RICH_TEXT_NODE_TYPE_TEXT') {
spanChilds.add(TextSpan(text: i.origText));
}
// @用户
if (i.type == 'RICH_TEXT_NODE_TYPE_AT') {
spanChilds.add(
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
GestureDetector(
onTap: () {},
child: Text(
'${i.text}',
style: authorStyle,
),
),
],
),
),
);
}
// 话题
if (i.type == 'RICH_TEXT_NODE_TYPE_TOPIC') {
spanChilds.add(
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
onTap: () {},
child: Text(
'${i.origText}',
style: authorStyle,
),
),
),
);
}
// 网页链接
if (i.type == 'RICH_TEXT_NODE_TYPE_WEB') {
spanChilds.add(
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Icon(
Icons.link,
size: 20,
color: Theme.of(context).colorScheme.primary,
),
),
);
spanChilds.add(
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
onTap: () {},
child: Text(
i.text,
style: authorStyle,
),
),
),
);
}
// 投票
if (i.type == 'RICH_TEXT_NODE_TYPE_VOTE') {
spanChilds.add(
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
onTap: () {},
child: Text(
'投票:${i.text}',
style: authorStyle,
),
),
),
);
}
// 表情
if (i.type == 'RICH_TEXT_NODE_TYPE_EMOJI') {
spanChilds.add(
WidgetSpan(
child: NetworkImgLayer(
src: i.emoji.iconUrl,
type: 'emote',
width: i.emoji.size * 20,
height: i.emoji.size * 20,
),
),
);
}
// 抽奖
if (i.type == 'RICH_TEXT_NODE_TYPE_LOTTERY') {
spanChilds.add(
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
onTap: () {},
child: Text(
'${i.origText} ',
style: authorStyle,
),
),
),
);
}
/// TODO 商品
if (i.type == 'RICH_TEXT_NODE_TYPE_GOODS') {
spanChilds.add(
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
onTap: () {},
child: Text(
'${i.text} ',
style: authorStyle,
),
),
),
);
}
}
return TextSpan(
children: spanChilds,
);
}

View File

@ -54,6 +54,8 @@ class HomeAppBar extends StatelessWidget {
// onPressed: () {}, // onPressed: () {},
// icon: const Icon(CupertinoIcons.bell, size: 22), // icon: const Icon(CupertinoIcons.bell, size: 22),
// ), // ),
const SizedBox(width: 6),
/// TODO /// TODO
if (userInfoCache.get('userInfoCache') != null) ...[ if (userInfoCache.get('userInfoCache') != null) ...[
GestureDetector( GestureDetector(

View File

@ -115,7 +115,7 @@ Widget searchMbangumiPanel(BuildContext context, ctr, list) {
}, },
child: const Text('观看'), child: const Text('观看'),
), ),
) ),
], ],
), ),
), ),

View File

@ -55,7 +55,11 @@ class _SearchResultPageState extends State<SearchResultPage>
body: Column( body: Column(
children: [ children: [
const SizedBox(height: 4), const SizedBox(height: 4),
Theme( Container(
width: double.infinity,
padding: const EdgeInsets.only(left: 8),
color: Theme.of(context).colorScheme.surface,
child: Theme(
data: ThemeData( data: ThemeData(
splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明
highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明
@ -88,6 +92,7 @@ class _SearchResultPageState extends State<SearchResultPage>
}, },
), ),
), ),
),
Expanded( Expanded(
child: TabBarView( child: TabBarView(
controller: _tabController, controller: _tabController,

View File

@ -231,10 +231,10 @@ class ReplyItem extends StatelessWidget {
), ),
Text( Text(
Utils.dateFormat(replyItem!.ctime), Utils.dateFormat(replyItem!.ctime),
style: Theme.of(context) style: TextStyle(
.textTheme fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
.labelMedium! color: Theme.of(context).colorScheme.outline,
.copyWith(color: Theme.of(context).colorScheme.outline), ),
), ),
if (replyItem!.replyControl != null && if (replyItem!.replyControl != null &&
replyItem!.replyControl!.location != '') replyItem!.replyControl!.location != '')

View File

@ -248,8 +248,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
body: Column( body: Column(
children: [ children: [
Container( Container(
width: double.infinity,
height: 45, height: 45,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
border: Border( border: Border(
bottom: BorderSide( bottom: BorderSide(
color: color: