This commit is contained in:
guozhigq
2023-07-26 22:04:56 +08:00
parent 5b46123f3f
commit ca12be5373
19 changed files with 311 additions and 215 deletions

View File

@ -16,6 +16,7 @@ import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/utils.dart';
import 'widgets/action_item.dart';
import 'widgets/action_row_item.dart';
import 'widgets/fav_panel.dart';
import 'widgets/intro_detail.dart';
@ -157,11 +158,10 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
? widget.videoDetail!.title
: videoItem['title'],
style: const TextStyle(
fontSize: 18,
letterSpacing: 0.3,
fontSize: 16,
fontWeight: FontWeight.w500,
),
maxLines: 2,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
@ -228,8 +228,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
],
),
),
const SizedBox(height: 6),
// 点赞收藏转发
const SizedBox(height: 7),
// 点赞收藏转发 布局样式1
SingleChildScrollView(
padding: const EdgeInsets.only(top: 7, bottom: 7),
scrollDirection: Axis.horizontal,
@ -239,6 +239,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
videoDetailCtr,
),
),
// 点赞收藏转发 布局样式2
// actionGrid(context, videoIntroController),
// 合集
if (!widget.loadingStatus &&
widget.videoDetail!.ugcSeason != null) ...[
@ -246,105 +248,103 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
widget.videoDetail!.pages!.first.cid, sheetHeight)
],
GestureDetector(
onTap: () {
feedBack();
int mid = !widget.loadingStatus
? widget.videoDetail!.owner!.mid
: videoItem['owner'].mid;
String face = !widget.loadingStatus
? widget.videoDetail!.owner!.face
: videoItem['owner'].face;
Get.toNamed('/member?mid=$mid', arguments: {
'face': face,
'heroTag': (mid + 99).toString()
});
},
child: Padding(
padding: const EdgeInsets.only(
top: 12, bottom: 12, left: 4, right: 4),
child: Row(
children: [
NetworkImgLayer(
type: 'avatar',
src: !widget.loadingStatus
? widget.videoDetail!.owner!.face
: videoItem['owner'].face,
width: 34,
height: 34,
fadeInDuration: Duration.zero,
fadeOutDuration: Duration.zero,
),
const SizedBox(width: 10),
Text(
!widget.loadingStatus
? widget.videoDetail!.owner!.name
: videoItem['owner'].name,
style: const TextStyle(fontSize: 13),
),
const SizedBox(width: 10),
Text(
widget.loadingStatus
? '-'
: Utils.numFormat(videoIntroController
.userStat['follower']),
style: TextStyle(
fontSize: t.textTheme.labelSmall!.fontSize,
color: t.colorScheme.outline),
),
const Spacer(),
AnimatedOpacity(
opacity: widget.loadingStatus ? 0 : 1,
duration: const Duration(milliseconds: 150),
child: SizedBox(
height: 32,
child: Obx(
() => videoIntroController
.followStatus.isNotEmpty
? TextButton(
onPressed: () => videoIntroController
.actionRelationMod(),
style: TextButton.styleFrom(
padding: const EdgeInsets.only(
left: 8, right: 8),
foregroundColor:
videoIntroController
.followStatus[
'attribute'] !=
0
? t.colorScheme.outline
: t.colorScheme.onPrimary,
backgroundColor:
videoIntroController
.followStatus[
'attribute'] !=
0
? t.colorScheme
.onInverseSurface
: t.colorScheme
.primary, // 设置按钮背景色
),
child: Text(
videoIntroController.followStatus[
'attribute'] !=
0
? '已关注'
: '关注',
style: TextStyle(
fontSize: t.textTheme
.labelMedium!.fontSize),
),
)
: ElevatedButton(
onPressed: () => videoIntroController
.actionRelationMod(),
child: const Text('关注'),
onTap: () {
feedBack();
int mid = !widget.loadingStatus
? widget.videoDetail!.owner!.mid
: videoItem['owner'].mid;
String face = !widget.loadingStatus
? widget.videoDetail!.owner!.face
: videoItem['owner'].face;
Get.toNamed('/member?mid=$mid', arguments: {
'face': face,
'heroTag': (mid + 99).toString()
});
},
child: Padding(
padding: const EdgeInsets.only(
top: 12, bottom: 12, left: 4, right: 4),
child: Row(
children: [
NetworkImgLayer(
type: 'avatar',
src: !widget.loadingStatus
? widget.videoDetail!.owner!.face
: videoItem['owner'].face,
width: 34,
height: 34,
fadeInDuration: Duration.zero,
fadeOutDuration: Duration.zero,
),
const SizedBox(width: 10),
Text(
!widget.loadingStatus
? widget.videoDetail!.owner!.name
: videoItem['owner'].name,
style: const TextStyle(fontSize: 13),
),
const SizedBox(width: 6),
Text(
widget.loadingStatus
? '-'
: Utils.numFormat(
videoIntroController.userStat['follower']),
style: TextStyle(
fontSize: t.textTheme.labelSmall!.fontSize,
color: t.colorScheme.outline),
),
const Spacer(),
AnimatedOpacity(
opacity: widget.loadingStatus ? 0 : 1,
duration: const Duration(milliseconds: 150),
child: SizedBox(
height: 32,
child: Obx(
() => videoIntroController
.followStatus.isNotEmpty
? TextButton(
onPressed: () => videoIntroController
.actionRelationMod(),
style: TextButton.styleFrom(
padding: const EdgeInsets.only(
left: 8, right: 8),
foregroundColor:
videoIntroController.followStatus[
'attribute'] !=
0
? t.colorScheme.outline
: t.colorScheme.onPrimary,
backgroundColor: videoIntroController
.followStatus[
'attribute'] !=
0
? t.colorScheme.onInverseSurface
: t.colorScheme
.primary, // 设置按钮背景色
),
),
child: Text(
videoIntroController.followStatus[
'attribute'] !=
0
? '已关注'
: '关注',
style: TextStyle(
fontSize: t.textTheme.labelMedium!
.fontSize),
),
)
: ElevatedButton(
onPressed: () => videoIntroController
.actionRelationMod(),
child: const Text('关注'),
),
),
),
],
),
)),
),
],
),
),
),
],
)
: const SizedBox(
@ -357,6 +357,73 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
);
}
Widget actionGrid(BuildContext context, videoIntroController) {
return LayoutBuilder(builder: (context, constraints) {
return Padding(
padding: const EdgeInsets.only(top: 6, bottom: 10),
child: SizedBox(
height: constraints.maxWidth / 5 * 0.8,
child: GridView.count(
primary: false,
padding: const EdgeInsets.all(0),
crossAxisCount: 5,
childAspectRatio: 1.25,
children: <Widget>[
Obx(
() => ActionItem(
icon: const Icon(FontAwesomeIcons.thumbsUp),
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
onTap: () => videoIntroController.actionLikeVideo(),
selectStatus: videoIntroController.hasLike.value,
loadingStatus: widget.loadingStatus,
text: !widget.loadingStatus
? widget.videoDetail!.stat!.like!.toString()
: '-'),
),
ActionItem(
icon: const Icon(FontAwesomeIcons.clock),
onTap: () => videoIntroController.actionShareVideo(),
selectStatus: false,
loadingStatus: widget.loadingStatus,
text: '稍后再看'),
Obx(
() => ActionItem(
icon: const Icon(FontAwesomeIcons.b),
selectIcon: const Icon(FontAwesomeIcons.b),
onTap: () => videoIntroController.actionCoinVideo(),
selectStatus: videoIntroController.hasCoin.value,
loadingStatus: widget.loadingStatus,
text: !widget.loadingStatus
? widget.videoDetail!.stat!.coin!.toString()
: '-'),
),
Obx(
() => ActionItem(
icon: const Icon(FontAwesomeIcons.star),
selectIcon: const Icon(FontAwesomeIcons.solidStar),
// onTap: () => videoIntroController.actionFavVideo(),
onTap: () => showFavBottomSheet(),
selectStatus: videoIntroController.hasFav.value,
loadingStatus: widget.loadingStatus,
text: !widget.loadingStatus
? widget.videoDetail!.stat!.favorite!.toString()
: '-'),
),
ActionItem(
icon: const Icon(FontAwesomeIcons.shareFromSquare),
onTap: () => videoIntroController.actionShareVideo(),
selectStatus: false,
loadingStatus: widget.loadingStatus,
text: !widget.loadingStatus
? widget.videoDetail!.stat!.share!.toString()
: '-'),
],
),
),
);
});
}
Widget actionRow(BuildContext context, videoIntroController, videoDetailCtr) {
return Row(children: [
Obx(

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/utils/feed_back.dart';
class ActionItem extends StatelessWidget {
final Icon? icon;
@ -22,7 +23,10 @@ class ActionItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () => onTap!(),
onTap: () => {
feedBack(),
onTap!(),
},
borderRadius: StyleString.mdRadius,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@ -30,20 +34,27 @@ class ActionItem extends StatelessWidget {
const SizedBox(height: 4),
selectStatus
? Icon(selectIcon!.icon!,
size: 21, color: Theme.of(context).primaryColor)
size: 18, color: Theme.of(context).colorScheme.primary)
: Icon(icon!.icon!,
size: 21, color: Theme.of(context).colorScheme.outline),
const SizedBox(height: 4),
size: 18, color: Theme.of(context).colorScheme.outline),
const SizedBox(height: 6),
AnimatedOpacity(
opacity: loadingStatus! ? 0 : 1,
duration: const Duration(milliseconds: 200),
child: Text(
text ?? '',
style: TextStyle(
color: selectStatus
? Theme.of(context).primaryColor
: Theme.of(context).colorScheme.outline,
fontSize: Theme.of(context).textTheme.labelSmall?.fontSize),
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: Text(
text ?? '',
key: ValueKey<String>(text ?? ''),
style: TextStyle(
color: selectStatus
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.outline,
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize),
),
),
),
],

View File

@ -33,7 +33,7 @@ class ActionRowItem extends StatelessWidget {
onTap!(),
},
child: Padding(
padding: const EdgeInsets.fromLTRB(13, 6.5, 15, 6.3),
padding: const EdgeInsets.fromLTRB(15, 7, 15, 7),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
@ -62,7 +62,7 @@ class ActionRowItem extends StatelessWidget {
? Theme.of(context).colorScheme.primary
: null,
fontSize:
Theme.of(context).textTheme.labelSmall!.fontSize),
Theme.of(context).textTheme.labelMedium!.fontSize),
),
),
),

View File

@ -51,23 +51,21 @@ class IntroDetail extends StatelessWidget {
Text(
videoDetail!.title,
style: const TextStyle(
fontSize: 18,
letterSpacing: 0.5,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 10),
Row(
children: [
const SizedBox(width: 2),
StatView(
theme: 'black',
theme: 'gray',
view: videoDetail!.stat!.view,
size: 'medium',
),
const SizedBox(width: 10),
StatDanMu(
theme: 'black',
theme: 'gray',
danmu: videoDetail!.stat!.danmaku,
size: 'medium',
),
@ -75,7 +73,10 @@ class IntroDetail extends StatelessWidget {
Text(
Utils.dateFormat(videoDetail!.pubdate,
formatType: 'detail'),
style: const TextStyle(fontSize: 12),
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.outline,
),
),
],
),

View File

@ -68,7 +68,7 @@ class MenuRow extends StatelessWidget {
onTap!(),
},
child: Container(
padding: const EdgeInsets.fromLTRB(13, 5.5, 13, 5.5),
padding: const EdgeInsets.fromLTRB(13, 5.5, 13, 4.5),
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(30)),
border: Border.all(
@ -85,7 +85,11 @@ class MenuRow extends StatelessWidget {
duration: const Duration(milliseconds: 200),
child: Text(
text!,
style: const TextStyle(fontSize: 13),
style: TextStyle(
fontSize: 13,
color: selectStatus
? Theme.of(context).colorScheme.onBackground
: Theme.of(context).colorScheme.outline),
),
),
],

View File

@ -7,9 +7,10 @@ Widget seasonPanel(UgcSeason ugcSeason, cid, sheetHeight) {
int currentIndex = episodes.indexWhere((e) => e.cid == cid);
return Container(
margin: const EdgeInsets.only(
top: 15,
top: 8,
left: 2,
right: 2,
bottom: 2,
),
child: Material(
color: Theme.of(context).colorScheme.onInverseSurface,
@ -88,11 +89,11 @@ Widget seasonPanel(UgcSeason ugcSeason, cid, sheetHeight) {
Image.asset(
'assets/images/live.gif',
color: Theme.of(context).colorScheme.primary,
height: 11,
height: 12,
),
const SizedBox(width: 4),
const SizedBox(width: 10),
Text(
'${currentIndex + 1} / ${ugcSeason.epCount}',
'${currentIndex + 1}/${ugcSeason.epCount}',
style: Theme.of(context).textTheme.labelMedium,
),
const SizedBox(width: 6),

View File

@ -33,23 +33,17 @@ class VideoReplyController extends GetxController {
Future queryReplyList({type = 'init'}) async {
isLoadingMore = true;
var res = replyLevel == '1'
? await ReplyHttp.replyList(
oid: aid!,
pageNum: ++currentPage,
type: ReplyType.video.index,
sort: sortType.index,
)
: await ReplyHttp.replyReplyList(
oid: aid!,
root: rpid!,
pageNum: ++currentPage,
type: ReplyType.video.index,
);
var res = await ReplyHttp.replyList(
oid: aid!,
pageNum: currentPage + 1,
type: ReplyType.video.index,
sort: sortType.index,
);
if (res['status']) {
List<ReplyItemModel> replies = res['data'].replies;
if (replies.isNotEmpty) {
noMore.value = '加载中';
currentPage++;
noMore.value = '加载中...';
if (replyList.length == res['data'].page.acount) {
noMore.value = '没有更多了';
}

View File

@ -167,10 +167,10 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
child: TextButton.icon(
onPressed: () =>
_videoReplyController.queryBySort(),
icon: const Icon(Icons.sort, size: 15),
icon: const Icon(Icons.sort, size: 16),
label: Obx(() => Text(
_videoReplyController.sortTypeLabel.value,
style: const TextStyle(fontSize: 12),
style: const TextStyle(fontSize: 13),
)),
),
)
@ -207,9 +207,18 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
EdgeInsets.only(bottom: bottom),
height: bottom + 100,
child: Center(
child: Obx(() => Text(
child: Obx(
() => Text(
_videoReplyController
.noMore.value)),
.noMore.value,
style: TextStyle(
fontSize: 12,
color: Theme.of(context)
.colorScheme
.outline,
),
),
),
),
);
} else {

View File

@ -187,7 +187,9 @@ class ReplyItem extends StatelessWidget {
TextSpan(
children: [
if (replyItem!.isTop!)
const WidgetSpan(child: UpTag(tagText: 'TOP')),
const WidgetSpan(
alignment: PlaceholderAlignment.top,
child: UpTag(tagText: 'TOP')),
buildContent(context, replyItem!, replyReply, null),
],
),

View File

@ -17,7 +17,7 @@ class VideoReplyReplyController extends GetxController {
// 当前页
int currentPage = 0;
bool isLoadingMore = false;
RxBool noMore = false.obs;
RxString noMore = ''.obs;
// 当前回复的回复
ReplyItemModel? currentReplyItem;
@ -38,27 +38,25 @@ class VideoReplyReplyController extends GetxController {
}
isLoadingMore = true;
var res = await ReplyHttp.replyReplyList(
oid: aid!,
root: rpid!,
pageNum: currentPage + 1,
type: replyType.index);
oid: aid!,
root: rpid!,
pageNum: currentPage + 1,
type: replyType.index,
);
if (res['status']) {
res['data'] = ReplyData.fromJson(res['data']);
if (res['data'].replies.isNotEmpty) {
currentPage = currentPage + 1;
noMore.value = false;
} else {
if (currentPage == 0) {
} else {
noMore.value = true;
return;
List<ReplyItemModel> replies = res['data'].replies;
if (replies.isNotEmpty) {
noMore.value = '加载中...';
if (replyList.length == res['data'].page.count) {
noMore.value = '没有更多了';
}
} else {
// 未登录状态replies可能返回null
noMore.value = currentPage == 0 ? '还没有评论' : '没有更多了';
}
if (res['data'].replies.length >= res['data'].page.count) {
noMore.value = true;
}
currentPage++;
if (type == 'init') {
List<ReplyItemModel> replies = res['data'].replies;
// List<ReplyItemModel> replies = res['data'].replies;
// 添加置顶回复
// if (res['data'].upper.top != null) {
// bool flag = false;
@ -71,12 +69,12 @@ class VideoReplyReplyController extends GetxController {
// replies.insert(0, res['data'].upper.top);
// }
// }
replies.insertAll(0, res['data'].topReplies);
res['data'].replies = replies;
replyList.value = res['data'].replies!;
// replies.insertAll(0, res['data'].topReplies);
// res['data'].replies = replies;
replyList.value = replies;
} else {
replyList.addAll(res['data'].replies!);
res['data'].replies.addAll(replyList);
replyList.addAll(replies);
// res['data'].replies.addAll(replyList);
}
}
isLoadingMore = false;

View File

@ -85,12 +85,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'评论详情',
style: Theme.of(context).textTheme.titleMedium,
),
const Text('评论详情'),
IconButton(
icon: const Icon(Icons.close),
icon: const Icon(Icons.close, size: 20),
onPressed: () {
_videoReplyReplyController.currentPage = 0;
widget.closePanel!();
@ -115,7 +112,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
controller: _videoReplyReplyController.scrollController,
slivers: <Widget>[
if (widget.firstFloor != null) ...[
const SliverToBoxAdapter(child: SizedBox(height: 10)),
// const SliverToBoxAdapter(child: SizedBox(height: 10)),
SliverToBoxAdapter(
child: ReplyItem(
replyItem: widget.firstFloor,
@ -160,10 +157,16 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
100,
child: Center(
child: Obx(
() => Text(_videoReplyReplyController
.noMore.value
? '没有更多了'
: '加载中'),
() => Text(
_videoReplyReplyController
.noMore.value,
style: TextStyle(
fontSize: 12,
color: Theme.of(context)
.colorScheme
.outline,
),
),
),
),
);