From 8f987e8352521ba621fdc1bfed66aa5c7f9dc98f Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 29 Sep 2023 22:17:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A7=86=E9=A2=91=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E7=A8=8D=E5=90=8E=E5=86=8D=E7=9C=8B=E5=8A=9F=E8=83=BD=20issues?= =?UTF-8?q?=20#150?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/dynamics/deatil/view.dart | 2 +- lib/pages/dynamics/widgets/author_panel.dart | 194 +++++++++++++----- lib/pages/dynamics/widgets/dynamic_panel.dart | 2 +- 3 files changed, 146 insertions(+), 52 deletions(-) diff --git a/lib/pages/dynamics/deatil/view.dart b/lib/pages/dynamics/deatil/view.dart index 4c49ecc7..116e0d27 100644 --- a/lib/pages/dynamics/deatil/view.dart +++ b/lib/pages/dynamics/deatil/view.dart @@ -177,7 +177,7 @@ class _DynamicDetailPageState extends State return AnimatedOpacity( opacity: snapshot.data ? 1 : 0, duration: const Duration(milliseconds: 300), - child: author(_dynamicDetailController!.item, context), + child: AuthorPanel(item: _dynamicDetailController.item), ); }, ), diff --git a/lib/pages/dynamics/widgets/author_panel.dart b/lib/pages/dynamics/widgets/author_panel.dart index 67a21371..a30d666e 100644 --- a/lib/pages/dynamics/widgets/author_panel.dart +++ b/lib/pages/dynamics/widgets/author_panel.dart @@ -1,65 +1,159 @@ import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.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/utils.dart'; -Widget author(item, context) { - String heroTag = Utils.makeHeroTag(item.modules.moduleAuthor.mid); - return Row( - children: [ - GestureDetector( - onTap: () { - feedBack(); - Get.toNamed( - '/member?mid=${item.modules.moduleAuthor.mid}', - arguments: { - 'face': item.modules.moduleAuthor.face, - 'heroTag': heroTag - }, - ); - }, - child: Hero( - tag: heroTag, - child: NetworkImgLayer( - width: 40, - height: 40, - type: 'avatar', - src: item.modules.moduleAuthor.face, +class AuthorPanel extends StatelessWidget { + final dynamic item; + const AuthorPanel({super.key, required this.item}); + + @override + Widget build(BuildContext context) { + String heroTag = Utils.makeHeroTag(item.modules.moduleAuthor.mid); + return Row( + children: [ + GestureDetector( + onTap: () { + feedBack(); + Get.toNamed( + '/member?mid=${item.modules.moduleAuthor.mid}', + arguments: { + 'face': item.modules.moduleAuthor.face, + 'heroTag': heroTag + }, + ); + }, + child: Hero( + tag: heroTag, + child: NetworkImgLayer( + width: 40, + height: 40, + type: 'avatar', + src: item.modules.moduleAuthor.face, + ), ), ), - ), - const SizedBox(width: 10), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - item.modules.moduleAuthor.name, - style: TextStyle( - color: item.modules.moduleAuthor!.vip != null && - item.modules.moduleAuthor!.vip['status'] > 0 - ? const Color.fromARGB(255, 251, 100, 163) - : Theme.of(context).colorScheme.onBackground, - fontSize: Theme.of(context).textTheme.titleSmall!.fontSize, + const SizedBox(width: 10), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item.modules.moduleAuthor.name, + style: TextStyle( + color: item.modules.moduleAuthor!.vip != null && + item.modules.moduleAuthor!.vip['status'] > 0 + ? const Color.fromARGB(255, 251, 100, 163) + : Theme.of(context).colorScheme.onBackground, + 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: [ - Text(item.modules.moduleAuthor.pubTime), - if (item.modules.moduleAuthor.pubTime != '' && - item.modules.moduleAuthor.pubAction != '') - const Text(' '), - Text(item.modules.moduleAuthor.pubAction), - ], + ), + ListTile( + onTap: () async { + try { + String bvid = item.modules.moduleDynamic.major.archive.bvid; + var res = await UserHttp.toViewLater(bvid: bvid); + 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, + ), + ), ], ), - ], - ); + ); + } } diff --git a/lib/pages/dynamics/widgets/dynamic_panel.dart b/lib/pages/dynamics/widgets/dynamic_panel.dart index 42670ac1..366f7ffe 100644 --- a/lib/pages/dynamics/widgets/dynamic_panel.dart +++ b/lib/pages/dynamics/widgets/dynamic_panel.dart @@ -39,7 +39,7 @@ class DynamicPanel extends StatelessWidget { children: [ Padding( padding: const EdgeInsets.fromLTRB(12, 12, 12, 8), - child: author(item, context), + child: AuthorPanel(item: item), ), if (item!.modules!.moduleDynamic!.desc != null || item!.modules!.moduleDynamic!.major != null)