From b9f9714677f7a0d64e1d82937e242ae75c9d873d Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 21 Jul 2023 22:14:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=B3=E6=B3=A8/=E5=8F=96=E5=85=B3?= =?UTF-8?q?=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/dynamics/widgets/up_panel.dart | 6 + lib/pages/member/controller.dart | 42 ++++ lib/pages/member/view.dart | 197 +----------------- lib/pages/member/widgets/profile.dart | 193 +++++++++++++++++ lib/pages/video/detail/player/controller.dart | 0 lib/pages/video/detail/player/index.dart | 4 - lib/pages/video/detail/player/view.dart | 0 lib/pages/video/detail/view.dart | 2 +- pubspec.lock | 2 +- 9 files changed, 251 insertions(+), 195 deletions(-) create mode 100644 lib/pages/member/widgets/profile.dart delete mode 100644 lib/pages/video/detail/player/controller.dart delete mode 100644 lib/pages/video/detail/player/index.dart delete mode 100644 lib/pages/video/detail/player/view.dart diff --git a/lib/pages/dynamics/widgets/up_panel.dart b/lib/pages/dynamics/widgets/up_panel.dart index c4cebc5e..c6350249 100644 --- a/lib/pages/dynamics/widgets/up_panel.dart +++ b/lib/pages/dynamics/widgets/up_panel.dart @@ -7,6 +7,7 @@ import 'package:pilipala/models/dynamics/up.dart'; import 'package:pilipala/models/live/item.dart'; import 'package:pilipala/pages/dynamics/controller.dart'; import 'package:pilipala/utils/storage.dart'; +import 'package:pilipala/utils/utils.dart'; class UpPanel extends StatefulWidget { FollowUpModel? upData; @@ -148,6 +149,11 @@ class _UpPanelState extends State { ); } }, + onLongPress: () { + String heroTag = Utils.makeHeroTag(data.mid); + Get.toNamed('/member?mid=${data.mid}', + arguments: {'face': data.face, 'heroTag': heroTag}); + }, child: Padding( padding: itemPadding, child: AnimatedOpacity( diff --git a/lib/pages/member/controller.dart b/lib/pages/member/controller.dart index 194c1922..78f172bc 100644 --- a/lib/pages/member/controller.dart +++ b/lib/pages/member/controller.dart @@ -1,6 +1,9 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/http/member.dart'; +import 'package:pilipala/http/video.dart'; import 'package:pilipala/models/member/archive.dart'; import 'package:pilipala/models/member/info.dart'; import 'package:pilipala/utils/storage.dart'; @@ -52,4 +55,43 @@ class MemberController extends GetxController { } return res; } + + // 关注/取关up + Future actionRelationMod() async { + if (user.get(UserBoxKey.userMid) == null) { + SmartDialog.showToast('账号未登录'); + return; + } + + SmartDialog.show( + useSystem: true, + animationType: SmartAnimationType.centerFade_otherSlide, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('提示'), + content: Text(memberInfo.value.isFollowed! ? '取消关注UP主?' : '关注UP主?'), + actions: [ + TextButton( + onPressed: () => SmartDialog.dismiss(), + child: const Text('点错了')), + TextButton( + onPressed: () async { + await VideoHttp.relationMod( + mid: mid, + act: memberInfo.value.isFollowed! ? 2 : 1, + reSrc: 11, + ); + memberInfo.value.isFollowed = !memberInfo.value.isFollowed!; + SmartDialog.dismiss(); + SmartDialog.showLoading(); + SmartDialog.dismiss(); + memberInfo.update((val) {}); + }, + child: const Text('确认'), + ) + ], + ); + }, + ); + } } diff --git a/lib/pages/member/view.dart b/lib/pages/member/view.dart index ee33b954..68d752e6 100644 --- a/lib/pages/member/view.dart +++ b/lib/pages/member/view.dart @@ -9,6 +9,8 @@ import 'package:pilipala/pages/member/archive/view.dart'; import 'package:pilipala/pages/member/index.dart'; import 'package:pilipala/utils/utils.dart'; +import 'widgets/profile.dart'; + class MemberPage extends StatefulWidget { const MemberPage({super.key}); @@ -106,8 +108,7 @@ class _MemberPageState extends State crossAxisAlignment: CrossAxisAlignment.start, children: [ - profile( - _memberController.memberInfo.value), + profile(_memberController), const SizedBox(height: 14), Row( children: [ @@ -234,7 +235,8 @@ class _MemberPageState extends State } } else { // 骨架屏 - return profile(null, loadingStatus: true); + return profile(_memberController, + loadingStatus: true); } }, ), @@ -251,10 +253,10 @@ class _MemberPageState extends State onlyOneScrollInBody: true, body: Column( children: [ - Container( + SizedBox( width: double.infinity, height: 50, - child: TabBar(controller: _tabController, tabs: [ + child: TabBar(controller: _tabController, tabs: const [ Tab(text: '主页'), Tab(text: '动态'), Tab(text: '投稿'), @@ -263,7 +265,7 @@ class _MemberPageState extends State Expanded( child: TabBarView( controller: _tabController, - children: [ + children: const [ Text('主页'), Text('动态'), ArchivePanel(), @@ -274,187 +276,4 @@ class _MemberPageState extends State ), ); } - - Widget profile(memberInfo, {loadingStatus = false}) { - return Padding( - padding: EdgeInsets.only(top: 3 * MediaQuery.of(context).padding.top), - child: Row( - children: [ - Hero( - tag: _memberController.heroTag!, - child: Stack( - children: [ - NetworkImgLayer( - width: 90, - height: 90, - type: 'avatar', - src: !loadingStatus - ? memberInfo.face - : _memberController.face, - ), - if (!loadingStatus && - memberInfo.liveRoom != null && - memberInfo.liveRoom.liveStatus == 1) - Positioned( - bottom: 0, - left: 14, - child: GestureDetector( - onTap: () { - LiveItemModel liveItem = LiveItemModel.fromJson({ - 'title': memberInfo.liveRoom.title, - 'uname': memberInfo.name, - 'face': memberInfo.face, - 'roomid': memberInfo.liveRoom.roomId, - 'watched_show': memberInfo.liveRoom.watchedShow, - }); - Get.toNamed( - '/liveRoom?roomid=${memberInfo.liveRoom.roomId}', - arguments: {'liveItem': liveItem}, - ); - }, - child: Container( - padding: const EdgeInsets.fromLTRB(6, 2, 6, 2), - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primary, - borderRadius: - const BorderRadius.all(Radius.circular(10)), - ), - child: Row(children: [ - Image.asset( - 'assets/images/live.gif', - height: 10, - ), - Text( - ' 直播中', - style: TextStyle( - color: Colors.white, - fontSize: Theme.of(context) - .textTheme - .labelSmall! - .fontSize), - ) - ]), - ), - ), - ) - ], - )), - const SizedBox(width: 12), - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: const EdgeInsets.only(left: 10, right: 10), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - children: [ - Text( - !loadingStatus - ? _memberController.userStat!['following'] - .toString() - : '-', - style: const TextStyle(fontWeight: FontWeight.bold), - ), - Text( - '关注', - style: TextStyle( - fontSize: Theme.of(context) - .textTheme - .labelMedium! - .fontSize), - ) - ], - ), - Column( - children: [ - Text( - !loadingStatus - ? Utils.numFormat( - _memberController.userStat!['follower'], - ) - : '-', - style: - const TextStyle(fontWeight: FontWeight.bold)), - Text('粉丝', - style: TextStyle( - fontSize: Theme.of(context) - .textTheme - .labelMedium! - .fontSize)) - ], - ), - Column( - children: [ - const Text('-', - style: TextStyle(fontWeight: FontWeight.bold)), - Text( - '获赞', - style: TextStyle( - fontSize: Theme.of(context) - .textTheme - .labelMedium! - .fontSize), - ) - ], - ), - ], - ), - ), - const SizedBox(height: 10), - if (_memberController.ownerMid != _memberController.mid) ...[ - Row( - children: [ - TextButton( - onPressed: () {}, - style: TextButton.styleFrom( - padding: const EdgeInsets.only(left: 42, right: 42), - foregroundColor: - !loadingStatus && memberInfo.isFollowed - ? Theme.of(context).colorScheme.outline - : Theme.of(context).colorScheme.onPrimary, - backgroundColor: !loadingStatus && - memberInfo.isFollowed - ? Theme.of(context).colorScheme.onInverseSurface - : Theme.of(context) - .colorScheme - .primary, // 设置按钮背景色 - ), - child: Text(!loadingStatus && memberInfo.isFollowed - ? '取关' - : '关注'), - ), - const SizedBox(width: 8), - TextButton( - onPressed: () {}, - style: TextButton.styleFrom( - padding: const EdgeInsets.only(left: 42, right: 42), - backgroundColor: - Theme.of(context).colorScheme.onInverseSurface, - ), - child: const Text('发消息'), - ) - ], - ) - ] else ...[ - TextButton( - onPressed: () {}, - style: TextButton.styleFrom( - padding: const EdgeInsets.only(left: 80, right: 80), - foregroundColor: Theme.of(context).colorScheme.onPrimary, - backgroundColor: Theme.of(context).colorScheme.primary, - ), - child: const Text('编辑资料'), - ) - ] - ], - ), - ), - ], - ), - ); - } } diff --git a/lib/pages/member/widgets/profile.dart b/lib/pages/member/widgets/profile.dart new file mode 100644 index 00000000..c76cd39b --- /dev/null +++ b/lib/pages/member/widgets/profile.dart @@ -0,0 +1,193 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:pilipala/common/widgets/network_img_layer.dart'; +import 'package:pilipala/models/live/item.dart'; +import 'package:pilipala/models/member/info.dart'; +import 'package:pilipala/utils/utils.dart'; + +Widget profile(ctr, {loadingStatus = false}) { + MemberInfoModel memberInfo = ctr.memberInfo.value; + return Builder( + builder: ((context) { + return Padding( + padding: EdgeInsets.only(top: 3 * MediaQuery.of(context).padding.top), + child: Row( + children: [ + Hero( + tag: ctr.heroTag!, + child: Stack( + children: [ + NetworkImgLayer( + width: 90, + height: 90, + type: 'avatar', + src: !loadingStatus ? memberInfo.face : ctr.face, + ), + if (!loadingStatus && + memberInfo.liveRoom != null && + memberInfo.liveRoom!.liveStatus == 1) + Positioned( + bottom: 0, + left: 14, + child: GestureDetector( + onTap: () { + LiveItemModel liveItem = LiveItemModel.fromJson({ + 'title': memberInfo.liveRoom!.title, + 'uname': memberInfo.name, + 'face': memberInfo.face, + 'roomid': memberInfo.liveRoom!.roomId, + 'watched_show': memberInfo.liveRoom!.watchedShow, + }); + Get.toNamed( + '/liveRoom?roomid=${memberInfo.liveRoom!.roomId}', + arguments: {'liveItem': liveItem}, + ); + }, + child: Container( + padding: const EdgeInsets.fromLTRB(6, 2, 6, 2), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.primary, + borderRadius: + const BorderRadius.all(Radius.circular(10)), + ), + child: Row(children: [ + Image.asset( + 'assets/images/live.gif', + height: 10, + ), + Text( + ' 直播中', + style: TextStyle( + color: Colors.white, + fontSize: Theme.of(context) + .textTheme + .labelSmall! + .fontSize), + ) + ]), + ), + ), + ) + ], + )), + const SizedBox(width: 12), + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + Text( + !loadingStatus + ? ctr.userStat!['following'].toString() + : '-', + style: + const TextStyle(fontWeight: FontWeight.bold), + ), + Text( + '关注', + style: TextStyle( + fontSize: Theme.of(context) + .textTheme + .labelMedium! + .fontSize), + ) + ], + ), + Column( + children: [ + Text( + !loadingStatus + ? Utils.numFormat( + ctr.userStat!['follower'], + ) + : '-', + style: const TextStyle( + fontWeight: FontWeight.bold)), + Text('粉丝', + style: TextStyle( + fontSize: Theme.of(context) + .textTheme + .labelMedium! + .fontSize)) + ], + ), + Column( + children: [ + const Text('-', + style: TextStyle(fontWeight: FontWeight.bold)), + Text( + '获赞', + style: TextStyle( + fontSize: Theme.of(context) + .textTheme + .labelMedium! + .fontSize), + ) + ], + ), + ], + ), + ), + const SizedBox(height: 10), + if (ctr.ownerMid != ctr.mid) ...[ + Row( + children: [ + TextButton( + onPressed: () => ctr.actionRelationMod(), + style: TextButton.styleFrom( + padding: const EdgeInsets.only(left: 42, right: 42), + foregroundColor: + !loadingStatus && memberInfo.isFollowed! + ? Theme.of(context).colorScheme.outline + : Theme.of(context).colorScheme.onPrimary, + backgroundColor: !loadingStatus && + memberInfo.isFollowed! + ? Theme.of(context).colorScheme.onInverseSurface + : Theme.of(context) + .colorScheme + .primary, // 设置按钮背景色 + ), + child: Text(!loadingStatus && memberInfo.isFollowed! + ? '取关' + : '关注'), + ), + const SizedBox(width: 8), + TextButton( + onPressed: () {}, + style: TextButton.styleFrom( + padding: const EdgeInsets.only(left: 42, right: 42), + backgroundColor: + Theme.of(context).colorScheme.onInverseSurface, + ), + child: const Text('发消息'), + ) + ], + ) + ] else ...[ + TextButton( + onPressed: () {}, + style: TextButton.styleFrom( + padding: const EdgeInsets.only(left: 80, right: 80), + foregroundColor: + Theme.of(context).colorScheme.onPrimary, + backgroundColor: Theme.of(context).colorScheme.primary, + ), + child: const Text('编辑资料'), + ) + ] + ], + ), + ), + ], + ), + ); + }), + ); +} diff --git a/lib/pages/video/detail/player/controller.dart b/lib/pages/video/detail/player/controller.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/pages/video/detail/player/index.dart b/lib/pages/video/detail/player/index.dart deleted file mode 100644 index c5d4ff78..00000000 --- a/lib/pages/video/detail/player/index.dart +++ /dev/null @@ -1,4 +0,0 @@ -library video_player; - -export './controller.dart'; -export './view.dart'; diff --git a/lib/pages/video/detail/player/view.dart b/lib/pages/video/detail/player/view.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 1017d2e2..ff32789a 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -97,7 +97,7 @@ class _VideoDetailPageState extends State @override // 离开当前页面时 void didPushNext() async { - if (!_meeduPlayerController!.pipEnabled) { + if (!_meeduPlayerController!.pipAvailable.value) { _meeduPlayerController!.pause(); } if (videoDetailController.timer!.isActive) { diff --git a/pubspec.lock b/pubspec.lock index d96ee6ad..d569f2a3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -424,7 +424,7 @@ packages: description: path: package ref: feature-custom - resolved-ref: "3b879c2ea736ade61236f82d5009230e054db5dd" + resolved-ref: d2bc690f3bf601feaa06085479abc384f0dc5168 url: "https://github.com/guozhigq/flutter_meedu_media_kit.git" source: git version: "4.2.12"