diff --git a/lib/common/widgets/video_card/video_card_h.dart b/lib/common/widgets/video_card/video_card_h.dart index bf6afbc8..cefeb56a 100644 --- a/lib/common/widgets/video_card/video_card_h.dart +++ b/lib/common/widgets/video_card/video_card_h.dart @@ -60,62 +60,54 @@ class VideoCardH extends StatelessWidget { label: Utils.videoItemSemantics(videoItem), excludeSemantics: true, child: InkWell( - onLongPress: () { - if (onLongPress != null) { - onLongPress!(); - } else { - imageSaveDialog( - title: videoItem.title, - cover: videoItem.pic, - ); - } - }, - onTap: () async { - if (onTap != null) { - onTap!(); - return; - } - if (type == 'ketang') { - SmartDialog.showToast('课堂视频暂不支持播放'); - return; - } else if (type == 'live_room') { - if (videoItem case SearchVideoItemModel item) { - int? roomId = item.id; - if (roomId != null) { - Get.toNamed('/liveRoom?roomid=$roomId'); + onLongPress: onLongPress ?? + () => imageSaveDialog( + title: videoItem.title, + cover: videoItem.pic, + ), + onTap: onTap ?? + () async { + if (type == 'ketang') { + SmartDialog.showToast('课堂视频暂不支持播放'); + return; + } else if (type == 'live_room') { + if (videoItem case SearchVideoItemModel item) { + int? roomId = item.id; + if (roomId != null) { + Get.toNamed('/liveRoom?roomid=$roomId'); + } + } else { + SmartDialog.showToast( + 'err: live_room : ${videoItem.runtimeType}'); + } + return; } - } else { - SmartDialog.showToast( - 'err: live_room : ${videoItem.runtimeType}'); - } - return; - } - if (videoItem case HotVideoItemModel item) { - if (item.redirectUrl?.isNotEmpty == true && - PageUtils.viewPgcFromUri(item.redirectUrl!)) { - return; - } - } - try { - final int? cid = videoItem.cid ?? - await SearchHttp.ab2c(aid: aid, bvid: bvid); - if (cid != null) { - if (source == 'later') { - onViewLater!(cid); - } else { - PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'videoItem': videoItem, - 'heroTag': Utils.makeHeroTag(aid) - }, - ); + if (videoItem case HotVideoItemModel item) { + if (item.redirectUrl?.isNotEmpty == true && + PageUtils.viewPgcFromUri(item.redirectUrl!)) { + return; + } } - } - } catch (err) { - SmartDialog.showToast(err.toString()); - } - }, + try { + final int? cid = videoItem.cid ?? + await SearchHttp.ab2c(aid: aid, bvid: bvid); + if (cid != null) { + if (source == 'later') { + onViewLater!(cid); + } else { + PageUtils.toVideoPage( + 'bvid=$bvid&cid=$cid', + arguments: { + 'videoItem': videoItem, + 'heroTag': Utils.makeHeroTag(aid) + }, + ); + } + } + } catch (err) { + SmartDialog.showToast(err.toString()); + } + }, child: Padding( padding: const EdgeInsets.symmetric( horizontal: StyleString.safeSpace, diff --git a/lib/common/widgets/video_card/video_card_h_member_video.dart b/lib/common/widgets/video_card/video_card_h_member_video.dart index beb9d910..debe46b3 100644 --- a/lib/common/widgets/video_card/video_card_h_member_video.dart +++ b/lib/common/widgets/video_card/video_card_h_member_video.dart @@ -37,30 +37,28 @@ class VideoCardHMemberVideo extends StatelessWidget { title: videoItem.title, cover: videoItem.cover, ), - onTap: () async { - if (onTap != null) { - onTap!(); - return; - } - if (videoItem.isPgc == true && videoItem.uri?.isNotEmpty == true) { - if (PageUtils.viewPgcFromUri(videoItem.uri!)) { - return; - } - } - if (videoItem.bvid == null || videoItem.cid == null) { - return; - } - try { - PageUtils.toVideoPage( - 'bvid=${videoItem.bvid}&cid=${videoItem.cid}', - arguments: { - 'heroTag': Utils.makeHeroTag(videoItem.bvid), - }, - ); - } catch (err) { - SmartDialog.showToast(err.toString()); - } - }, + onTap: onTap ?? + () async { + if (videoItem.isPgc == true && + videoItem.uri?.isNotEmpty == true) { + if (PageUtils.viewPgcFromUri(videoItem.uri!)) { + return; + } + } + if (videoItem.bvid == null || videoItem.cid == null) { + return; + } + try { + PageUtils.toVideoPage( + 'bvid=${videoItem.bvid}&cid=${videoItem.cid}', + arguments: { + 'heroTag': Utils.makeHeroTag(videoItem.bvid), + }, + ); + } catch (err) { + SmartDialog.showToast(err.toString()); + } + }, child: Padding( padding: const EdgeInsets.symmetric( horizontal: StyleString.safeSpace, diff --git a/lib/http/search.dart b/lib/http/search.dart index 101c0c5d..0b261f7c 100644 --- a/lib/http/search.dart +++ b/lib/http/search.dart @@ -215,14 +215,13 @@ class SearchHttp { dynamic seasonId, dynamic epId, }) async { - final Map data = {}; - if (seasonId != null) { - data['season_id'] = seasonId; - } else if (epId != null) { - data['ep_id'] = epId; - } - var res = await Request().get(Api.bangumiInfo, queryParameters: data); - + var res = await Request().get( + Api.bangumiInfo, + queryParameters: { + if (seasonId != null) 'season_id': seasonId, + if (epId != null) 'ep_id': epId, + }, + ); if (res.data['code'] == 0) { return { 'status': true, diff --git a/lib/pages/dynamics/widgets/up_panel.dart b/lib/pages/dynamics/widgets/up_panel.dart index e5232577..03e883fd 100644 --- a/lib/pages/dynamics/widgets/up_panel.dart +++ b/lib/pages/dynamics/widgets/up_panel.dart @@ -149,14 +149,13 @@ class _UpPanelState extends State { } }, onDoubleTap: data is LiveUserItem ? () => _onSelect(data) : null, - onLongPress: () { - if (data.mid == -1) { - return; - } - String heroTag = Utils.makeHeroTag(data.mid); - Get.toNamed('/member?mid=${data.mid}', - arguments: {'face': data.face, 'heroTag': heroTag}); - }, + onLongPress: data.mid == -1 + ? null + : () { + String heroTag = Utils.makeHeroTag(data.mid); + Get.toNamed('/member?mid=${data.mid}', + arguments: {'face': data.face, 'heroTag': heroTag}); + }, child: AnimatedOpacity( opacity: isCurrent ? 1 : 0.6, duration: const Duration(milliseconds: 200), diff --git a/lib/pages/fav_detail/widget/fav_video_card.dart b/lib/pages/fav_detail/widget/fav_video_card.dart index 73e33ea6..cb34211e 100644 --- a/lib/pages/fav_detail/widget/fav_video_card.dart +++ b/lib/pages/fav_detail/widget/fav_video_card.dart @@ -35,40 +35,31 @@ class FavVideoCardH extends StatelessWidget { return InkWell( onTap: isSort == true ? null - : () async { - if (onTap != null) { - onTap!(); - return; - } + : onTap ?? + () { + if (!const [0, 16].contains(videoItem.attr)) { + Get.toNamed('/member?mid=${videoItem.owner.mid}'); + return; + } - if (!const [0, 16].contains(videoItem.attr)) { - Get.toNamed('/member?mid=${videoItem.owner.mid}'); - return; - } + // pgc + if (videoItem.type == 24) { + PageUtils.viewBangumi( + seasonId: videoItem.ogv!.seasonId, + epId: videoItem.epId, + ); + return; + } - // pgc - if (videoItem.type == 24) { - PageUtils.viewBangumi( - seasonId: videoItem.ogv!.seasonId, - epId: videoItem.epId, - ); - return; - } - - onViewFav?.call(); - }, + onViewFav?.call(); + }, onLongPress: isSort == true ? null - : () { - if (onLongPress != null) { - onLongPress!(); - } else { - imageSaveDialog( - title: videoItem.title, - cover: videoItem.pic, - ); - } - }, + : onLongPress ?? + () => imageSaveDialog( + title: videoItem.title, + cover: videoItem.pic, + ), child: Padding( padding: const EdgeInsets.symmetric( horizontal: StyleString.safeSpace, diff --git a/lib/pages/video/introduction/pgc/widgets/intro_detail.dart b/lib/pages/video/introduction/pgc/widgets/intro_detail.dart index 096d8412..4ca2b86e 100644 --- a/lib/pages/video/introduction/pgc/widgets/intro_detail.dart +++ b/lib/pages/video/introduction/pgc/widgets/intro_detail.dart @@ -173,7 +173,7 @@ class _IntroDetailState extends CommonCollapseSlidePageState { '/searchResult', parameters: {'keyword': tagName}, ), - onLongPress: (tagName) => Utils.copyText(tagName), + onLongPress: Utils.copyText, ), ) .toList(), diff --git a/lib/pages/video/introduction/ugc/view.dart b/lib/pages/video/introduction/ugc/view.dart index 099917a1..ffb68571 100644 --- a/lib/pages/video/introduction/ugc/view.dart +++ b/lib/pages/video/introduction/ugc/view.dart @@ -719,8 +719,7 @@ class _VideoInfoState extends State { '/searchResult', parameters: {'keyword': tagName}, ), - onLongPress: (tagName) => - Utils.copyText(tagName), + onLongPress: Utils.copyText, ), ) .toList(), diff --git a/lib/pages/video/introduction/ugc/widgets/action_item.dart b/lib/pages/video/introduction/ugc/widgets/action_item.dart index 7174c459..f692805a 100644 --- a/lib/pages/video/introduction/ugc/widgets/action_item.dart +++ b/lib/pages/video/introduction/ugc/widgets/action_item.dart @@ -145,9 +145,9 @@ class ActionItemState extends State widget.onTap?.call(); }, onLongPress: _isThumbsUp ? null : widget.onLongPress, - onTapDown: (details) => _isThumbsUp ? _startLongPress() : null, - onTapUp: (details) => _isThumbsUp ? _cancelLongPress() : null, - onTapCancel: () => _isThumbsUp ? _cancelLongPress(true) : null, + onTapDown: _isThumbsUp ? (details) => _startLongPress() : null, + onTapUp: _isThumbsUp ? (details) => _cancelLongPress() : null, + onTapCancel: _isThumbsUp ? () => _cancelLongPress(true) : null, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index ab48982d..ff28c006 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -85,9 +85,10 @@ class PiliScheme { if (id != null) { bool isEp = path.contains('/ep/'); PageUtils.viewBangumi( - seasonId: isEp ? null : id, - epId: isEp ? id : null, - progress: uri.queryParameters['start_progress']); + seasonId: isEp ? null : id, + epId: isEp ? id : null, + progress: uri.queryParameters['start_progress'], + ); return true; } return false; diff --git a/lib/utils/page_utils.dart b/lib/utils/page_utils.dart index 94ac96f4..66f43d8a 100644 --- a/lib/utils/page_utils.dart +++ b/lib/utils/page_utils.dart @@ -697,7 +697,7 @@ class PageUtils { } static Future viewBangumi( - {dynamic seasonId, dynamic epId, dynamic progress}) async { + {dynamic seasonId, dynamic epId, String? progress}) async { try { SmartDialog.showLoading(msg: '资源获取中'); var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);