feat: 视频动态稍后再看功能 issues #150

This commit is contained in:
guozhigq
2023-09-29 22:17:31 +08:00
parent 4e147b6f18
commit 8f987e8352
3 changed files with 146 additions and 52 deletions

View File

@ -177,7 +177,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
return AnimatedOpacity( return AnimatedOpacity(
opacity: snapshot.data ? 1 : 0, opacity: snapshot.data ? 1 : 0,
duration: const Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
child: author(_dynamicDetailController!.item, context), child: AuthorPanel(item: _dynamicDetailController.item),
); );
}, },
), ),

View File

@ -1,65 +1,159 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/http/user.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/utils.dart'; import 'package:pilipala/utils/utils.dart';
Widget author(item, context) { class AuthorPanel extends StatelessWidget {
String heroTag = Utils.makeHeroTag(item.modules.moduleAuthor.mid); final dynamic item;
return Row( const AuthorPanel({super.key, required this.item});
children: [
GestureDetector( @override
onTap: () { Widget build(BuildContext context) {
feedBack(); String heroTag = Utils.makeHeroTag(item.modules.moduleAuthor.mid);
Get.toNamed( return Row(
'/member?mid=${item.modules.moduleAuthor.mid}', children: [
arguments: { GestureDetector(
'face': item.modules.moduleAuthor.face, onTap: () {
'heroTag': heroTag feedBack();
}, Get.toNamed(
); '/member?mid=${item.modules.moduleAuthor.mid}',
}, arguments: {
child: Hero( 'face': item.modules.moduleAuthor.face,
tag: heroTag, 'heroTag': heroTag
child: NetworkImgLayer( },
width: 40, );
height: 40, },
type: 'avatar', child: Hero(
src: item.modules.moduleAuthor.face, tag: heroTag,
child: NetworkImgLayer(
width: 40,
height: 40,
type: 'avatar',
src: item.modules.moduleAuthor.face,
),
), ),
), ),
), const SizedBox(width: 10),
const SizedBox(width: 10), Column(
Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ Text(
Text( item.modules.moduleAuthor.name,
item.modules.moduleAuthor.name, style: TextStyle(
style: TextStyle( color: item.modules.moduleAuthor!.vip != null &&
color: item.modules.moduleAuthor!.vip != null && item.modules.moduleAuthor!.vip['status'] > 0
item.modules.moduleAuthor!.vip['status'] > 0 ? const Color.fromARGB(255, 251, 100, 163)
? const Color.fromARGB(255, 251, 100, 163) : Theme.of(context).colorScheme.onBackground,
: Theme.of(context).colorScheme.onBackground, fontSize: Theme.of(context).textTheme.titleSmall!.fontSize,
fontSize: Theme.of(context).textTheme.titleSmall!.fontSize, ),
),
DefaultTextStyle.merge(
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
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),
],
),
)
],
),
const Spacer(),
if (item.type == 'DYNAMIC_TYPE_AV')
SizedBox(
width: 32,
height: 32,
child: IconButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () {
showModalBottomSheet(
context: context,
useRootNavigator: true,
isScrollControlled: true,
builder: (context) {
return MorePanel(item: item);
},
);
},
icon: const Icon(Icons.more_vert_outlined, size: 18),
), ),
), ),
DefaultTextStyle.merge( ],
style: TextStyle( );
color: Theme.of(context).colorScheme.outline, }
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize, }
class MorePanel extends StatelessWidget {
final dynamic item;
const MorePanel({super.key, required this.item});
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
// clipBehavior: Clip.hardEdge,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: () => Get.back(),
child: Container(
height: 35,
padding: const EdgeInsets.only(bottom: 2),
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.outline,
borderRadius: const BorderRadius.all(Radius.circular(3))),
),
),
), ),
child: Row( ),
children: [ ListTile(
Text(item.modules.moduleAuthor.pubTime), onTap: () async {
if (item.modules.moduleAuthor.pubTime != '' && try {
item.modules.moduleAuthor.pubAction != '') String bvid = item.modules.moduleDynamic.major.archive.bvid;
const Text(' '), var res = await UserHttp.toViewLater(bvid: bvid);
Text(item.modules.moduleAuthor.pubAction), SmartDialog.showToast(res['msg']);
], Get.back();
} catch (err) {
SmartDialog.showToast('出错了:${err.toString()}');
}
},
minLeadingWidth: 0,
// dense: true,
leading: const Icon(Icons.watch_later_outlined, size: 19),
title: Text(
'稍后再看',
style: Theme.of(context).textTheme.titleSmall,
), ),
) ),
const Divider(thickness: 0.1, height: 1),
ListTile(
onTap: () => Get.back(),
minLeadingWidth: 0,
dense: true,
title: Text(
'取消',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
textAlign: TextAlign.center,
),
),
], ],
), ),
], );
); }
} }

View File

@ -39,7 +39,7 @@ class DynamicPanel extends StatelessWidget {
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.fromLTRB(12, 12, 12, 8), padding: const EdgeInsets.fromLTRB(12, 12, 12, 8),
child: author(item, context), child: AuthorPanel(item: item),
), ),
if (item!.modules!.moduleDynamic!.desc != null || if (item!.modules!.moduleDynamic!.desc != null ||
item!.modules!.moduleDynamic!.major != null) item!.modules!.moduleDynamic!.major != null)