diff --git a/.gitignore b/.gitignore index 24476c5d..7bc3f845 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release +/*/flutter/[Gg]enerated*[Pp]lugin* diff --git a/lib/common/widgets/video_card_h.dart b/lib/common/widgets/video_card_h.dart index c4472b42..b00f1759 100644 --- a/lib/common/widgets/video_card_h.dart +++ b/lib/common/widgets/video_card_h.dart @@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import '../../http/search.dart'; import '../../http/user.dart'; +import '../../http/video.dart'; import '../../utils/utils.dart'; import '../constants.dart'; import 'badge.dart'; @@ -265,7 +266,6 @@ class VideoContent extends StatelessWidget { height: 24, child: PopupMenuButton( padding: EdgeInsets.zero, - tooltip: '稍后再看', icon: Icon( Icons.more_vert_outlined, color: Theme.of(context).colorScheme.outline, @@ -280,10 +280,10 @@ class VideoContent extends StatelessWidget { onTap: () async { var res = await UserHttp.toViewLater( bvid: videoItem.bvid as String); - SmartDialog.showToast(res['msg'] as String); + SmartDialog.showToast(res['msg']); }, value: 'pause', - height: 35, + height: 40, child: const Row( children: [ Icon(Icons.watch_later_outlined, size: 16), @@ -292,6 +292,59 @@ class VideoContent extends StatelessWidget { ], ), ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () async { + SmartDialog.show( + useSystem: true, + animationType: + SmartAnimationType.centerFade_otherSlide, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('提示'), + content: Text( + '确定拉黑:${videoItem.owner.name}(${videoItem.owner.mid})?' + '\n\n注:被拉黑的Up可以在隐私设置-黑名单管理中解除'), + actions: [ + TextButton( + onPressed: () => SmartDialog.dismiss(), + child: Text( + '点错了', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .outline), + ), + ), + TextButton( + onPressed: () async { + var res = await VideoHttp.relationMod( + mid: videoItem.owner.mid, + act: 5, + reSrc: 11, + ); + SmartDialog.dismiss(); + SmartDialog.showToast( + res['msg'] ?? '成功'); + }, + child: const Text('确认'), + ) + ], + ); + }, + ); + }, + value: 'pause', + height: 40, + child: Row( + children: [ + const Icon(Icons.block, size: 16), + const SizedBox(width: 6), + Text('拉黑:${videoItem.owner.name}', + style: const TextStyle(fontSize: 13)) + ], + ), + ), ], ), ), diff --git a/lib/common/widgets/video_card_v.dart b/lib/common/widgets/video_card_v.dart index 1b6edbbf..c5577af3 100644 --- a/lib/common/widgets/video_card_v.dart +++ b/lib/common/widgets/video_card_v.dart @@ -4,6 +4,7 @@ import 'package:get/get.dart'; import '../../http/dynamics.dart'; import '../../http/search.dart'; import '../../http/user.dart'; +import '../../http/video.dart'; import '../../models/common/search_type.dart'; import '../../utils/id_utils.dart'; import '../../utils/utils.dart'; @@ -215,15 +216,10 @@ class VideoContent extends StatelessWidget { ), if (videoItem.goto == 'av' && crossAxisCount == 1) ...[ const SizedBox(width: 10), - WatchLater( + VideoPopupMenu( size: 32, iconSize: 18, - callFn: () async { - int aid = videoItem.param; - var res = - await UserHttp.toViewLater(bvid: IdUtils.av2bv(aid)); - SmartDialog.showToast(res['msg']); - }, + videoItem: videoItem, ), ], ], @@ -299,15 +295,10 @@ class VideoContent extends StatelessWidget { const Spacer(), ], if (videoItem.goto == 'av' && crossAxisCount != 1) ...[ - WatchLater( + VideoPopupMenu( size: 24, iconSize: 14, - callFn: () async { - int aid = videoItem.param; - var res = - await UserHttp.toViewLater(bvid: IdUtils.av2bv(aid)); - SmartDialog.showToast(res['msg']); - }, + videoItem: videoItem, ), ] else ...[ const SizedBox(height: 24) @@ -349,16 +340,16 @@ class VideoStat extends StatelessWidget { } } -class WatchLater extends StatelessWidget { +class VideoPopupMenu extends StatelessWidget { final double? size; final double? iconSize; - final Function? callFn; + final dynamic videoItem; - const WatchLater({ + const VideoPopupMenu({ Key? key, required this.size, required this.iconSize, - this.callFn, + required this.videoItem, }) : super(key: key); @override @@ -368,7 +359,6 @@ class WatchLater extends StatelessWidget { height: size, child: PopupMenuButton( padding: EdgeInsets.zero, - tooltip: '稍后再看', icon: Icon( Icons.more_vert_outlined, color: Theme.of(context).colorScheme.outline, @@ -379,9 +369,13 @@ class WatchLater extends StatelessWidget { onSelected: (String type) {}, itemBuilder: (BuildContext context) => >[ PopupMenuItem( - onTap: () => callFn!(), + onTap: () async { + var res = + await UserHttp.toViewLater(bvid: videoItem.bvid as String); + SmartDialog.showToast(res['msg']); + }, value: 'pause', - height: 35, + height: 40, child: const Row( children: [ Icon(Icons.watch_later_outlined, size: 16), @@ -390,6 +384,55 @@ class WatchLater extends StatelessWidget { ], ), ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () async { + SmartDialog.show( + useSystem: true, + animationType: SmartAnimationType.centerFade_otherSlide, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('提示'), + content: Text( + '确定拉黑:${videoItem.owner.name}(${videoItem.owner.mid})?' + '\n\n注:被拉黑的Up可以在隐私设置-黑名单管理中解除'), + actions: [ + TextButton( + onPressed: () => SmartDialog.dismiss(), + child: Text( + '点错了', + style: TextStyle( + color: Theme.of(context).colorScheme.outline), + ), + ), + TextButton( + onPressed: () async { + var res = await VideoHttp.relationMod( + mid: videoItem.owner.mid, + act: 5, + reSrc: 11, + ); + SmartDialog.dismiss(); + SmartDialog.showToast(res['msg'] ?? '成功'); + }, + child: const Text('确认'), + ) + ], + ); + }, + ); + }, + value: 'pause', + height: 40, + child: Row( + children: [ + const Icon(Icons.block, size: 16), + const SizedBox(width: 6), + Text('拉黑:${videoItem.owner.name}', + style: const TextStyle(fontSize: 13)) + ], + ), + ), ], ), );