diff --git a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart index ab886f114..63f0236e2 100644 --- a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart +++ b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart @@ -270,6 +270,7 @@ class _InteractiveviewerGalleryState extends State itemCount: widget.sources.length, itemBuilder: (BuildContext context, int index) { final item = widget.sources[index]; + final isFileImg = item.sourceType == SourceType.fileImage; return GestureDetector( behavior: HitTestBehavior.opaque, onTap: () => EasyThrottle.throttle( @@ -285,9 +286,12 @@ class _InteractiveviewerGalleryState extends State const Duration(milliseconds: 555), onDoubleTap, ), - onLongPress: item.sourceType == SourceType.fileImage - ? null - : () => onLongPress(item), + onLongPress: !isFileImg && Utils.isMobile + ? () => onLongPress(item) + : null, + onSecondaryTap: !isFileImg && !Utils.isMobile + ? () => onLongPress(item) + : null, child: widget.itemBuilder != null ? widget.itemBuilder!( context, diff --git a/lib/common/widgets/video_card/video_card_v.dart b/lib/common/widgets/video_card/video_card_v.dart index 2607b5fa1..bc965bceb 100644 --- a/lib/common/widgets/video_card/video_card_v.dart +++ b/lib/common/widgets/video_card/video_card_v.dart @@ -67,6 +67,11 @@ class VideoCardV extends StatelessWidget { @override Widget build(BuildContext context) { + void onLongPress() => imageSaveDialog( + title: videoItem.title, + cover: videoItem.cover, + bvid: videoItem.bvid, + ); return Stack( clipBehavior: Clip.none, children: [ @@ -74,11 +79,8 @@ class VideoCardV extends StatelessWidget { clipBehavior: Clip.hardEdge, child: InkWell( onTap: () => onPushDetail(Utils.makeHeroTag(videoItem.aid)), - onLongPress: () => imageSaveDialog( - title: videoItem.title, - cover: videoItem.cover, - bvid: videoItem.bvid, - ), + onLongPress: Utils.isMobile ? onLongPress : null, + onSecondaryTap: Utils.isMobile ? null : onLongPress, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/pages/common/publish/common_rich_text_pub_page.dart b/lib/pages/common/publish/common_rich_text_pub_page.dart index 9463eb4f4..9b89dc19e 100644 --- a/lib/pages/common/publish/common_rich_text_pub_page.dart +++ b/lib/pages/common/publish/common_rich_text_pub_page.dart @@ -107,7 +107,8 @@ abstract class CommonRichTextPubPageState ); controller.restoreChatPanel(); }, - onLongPress: onClear, + onLongPress: Utils.isMobile ? onClear : null, + onSecondaryTap: Utils.isMobile ? null : onClear, child: ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(4)), child: Image( diff --git a/lib/pages/dynamics/widgets/dynamic_panel.dart b/lib/pages/dynamics/widgets/dynamic_panel.dart index bf5bf21ed..d7b4b4215 100644 --- a/lib/pages/dynamics/widgets/dynamic_panel.dart +++ b/lib/pages/dynamics/widgets/dynamic_panel.dart @@ -5,6 +5,7 @@ import 'package:PiliPlus/pages/dynamics/widgets/action_panel.dart'; import 'package:PiliPlus/pages/dynamics/widgets/author_panel.dart'; import 'package:PiliPlus/pages/dynamics/widgets/dyn_content.dart'; import 'package:PiliPlus/utils/page_utils.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart' hide InkWell; class DynamicPanel extends StatelessWidget { @@ -45,6 +46,9 @@ class DynamicPanel extends StatelessWidget { onSetTop: onSetTop, onBlock: onBlock, ); + + void showMore() => _imageSaveDialog(context, authorWidget.morePanel); + final child = Material( type: MaterialType.transparency, child: InkWell( @@ -62,7 +66,8 @@ class DynamicPanel extends StatelessWidget { }.contains(item.type) ? null : () => PageUtils.pushDynDetail(item), - onLongPress: () => _imageSaveDialog(context, authorWidget.morePanel), + onLongPress: Utils.isMobile ? showMore : null, + onSecondaryTap: Utils.isMobile ? null : showMore, child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/pages/dynamics/widgets/forward_panel.dart b/lib/pages/dynamics/widgets/forward_panel.dart index a6b87e7f8..003dcebc3 100644 --- a/lib/pages/dynamics/widgets/forward_panel.dart +++ b/lib/pages/dynamics/widgets/forward_panel.dart @@ -5,6 +5,7 @@ import 'package:PiliPlus/pages/dynamics/widgets/dyn_content.dart'; import 'package:PiliPlus/pages/dynamics/widgets/module_panel.dart'; import 'package:PiliPlus/utils/date_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart' hide InkWell; import 'package:get/get.dart'; @@ -59,44 +60,47 @@ Widget forwardPanel( return child; } + void showMore() { + String? title, cover, bvid; + switch (orig.type) { + case 'DYNAMIC_TYPE_AV': + title = major?.archive?.title; + cover = major?.archive?.cover; + bvid = major?.archive?.bvid; + break; + case 'DYNAMIC_TYPE_UGC_SEASON': + title = major?.ugcSeason?.title; + cover = major?.ugcSeason?.cover; + bvid = major?.ugcSeason?.bvid; + break; + case 'DYNAMIC_TYPE_PGC' || 'DYNAMIC_TYPE_PGC_UNION': + title = major?.pgc?.title; + cover = major?.pgc?.cover; + break; + case 'DYNAMIC_TYPE_LIVE_RCMD': + title = major?.liveRcmd?.title; + cover = major?.liveRcmd?.cover; + break; + case 'DYNAMIC_TYPE_LIVE': + title = major?.live?.title; + cover = major?.live?.cover; + break; + default: + return; + } + if (cover != null) { + imageSaveDialog( + title: title, + cover: cover, + bvid: bvid, + ); + } + } + return InkWell( onTap: () => PageUtils.pushDynDetail(orig), - onLongPress: () { - String? title, cover, bvid; - switch (orig.type) { - case 'DYNAMIC_TYPE_AV': - title = major?.archive?.title; - cover = major?.archive?.cover; - bvid = major?.archive?.bvid; - break; - case 'DYNAMIC_TYPE_UGC_SEASON': - title = major?.ugcSeason?.title; - cover = major?.ugcSeason?.cover; - bvid = major?.ugcSeason?.bvid; - break; - case 'DYNAMIC_TYPE_PGC' || 'DYNAMIC_TYPE_PGC_UNION': - title = major?.pgc?.title; - cover = major?.pgc?.cover; - break; - case 'DYNAMIC_TYPE_LIVE_RCMD': - title = major?.liveRcmd?.title; - cover = major?.liveRcmd?.cover; - break; - case 'DYNAMIC_TYPE_LIVE': - title = major?.live?.title; - cover = major?.live?.cover; - break; - default: - return; - } - if (cover != null) { - imageSaveDialog( - title: title, - cover: cover, - bvid: bvid, - ); - } - }, + onLongPress: Utils.isMobile ? showMore : null, + onSecondaryTap: Utils.isMobile ? null : showMore, child: child, ); } diff --git a/lib/pages/dynamics/widgets/up_panel.dart b/lib/pages/dynamics/widgets/up_panel.dart index 3e7a3f018..e178dfae3 100644 --- a/lib/pages/dynamics/widgets/up_panel.dart +++ b/lib/pages/dynamics/widgets/up_panel.dart @@ -7,6 +7,7 @@ import 'package:PiliPlus/pages/dynamics/controller.dart'; import 'package:PiliPlus/pages/live_follow/view.dart'; import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/page_utils.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart' hide InkWell; import 'package:get/get.dart'; @@ -25,6 +26,8 @@ class _UpPanelState extends State { late final controller = widget.dynamicsController; late final isTop = controller.upPanelPosition == UpPanelPosition.top; + void toFollowPage() => Get.to(const LiveFollowPage()); + @override Widget build(BuildContext context) { final accountService = controller.accountService; @@ -45,7 +48,8 @@ class _UpPanelState extends State { onTap: () => setState(() { controller.showLiveUp = !controller.showLiveUp; }), - onLongPress: () => Get.to(const LiveFollowPage()), + onLongPress: Utils.isMobile ? toFollowPage : null, + onSecondaryTap: Utils.isMobile ? null : toFollowPage, child: Container( alignment: Alignment.center, height: isTop ? 76 : 60, @@ -138,6 +142,10 @@ class _UpPanelState extends State { final currentMid = controller.currentMid; final isLive = data is LiveUserItem; bool isCurrent = isLive || currentMid == data.mid || currentMid == -1; + + final isAll = data.mid == -1; + void toMemberPage() => Get.toNamed('/member?mid=${data.mid}'); + return SizedBox( height: 76, width: isTop ? 70 : null, @@ -153,9 +161,8 @@ class _UpPanelState extends State { } }, // onDoubleTap: isLive ? () => _onSelect(data) : null, - onLongPress: data.mid == -1 - ? null - : () => Get.toNamed('/member?mid=${data.mid}'), + onLongPress: !isAll && Utils.isMobile ? toMemberPage : null, + onSecondaryTap: !isAll && !Utils.isMobile ? toMemberPage : null, child: AnimatedOpacity( opacity: isCurrent ? 1 : 0.6, duration: const Duration(milliseconds: 200), diff --git a/lib/pages/fan/view.dart b/lib/pages/fan/view.dart index f8564e6f1..644e5247e 100644 --- a/lib/pages/fan/view.dart +++ b/lib/pages/fan/view.dart @@ -111,6 +111,14 @@ class _FansPageState extends State { } Widget _buildItem(ColorScheme theme, int index, FansItemModel item) { + final isSelect = widget.onSelect != null; + void onRemove() => showConfirmDialog( + context: context, + title: '确定移除 ${item.uname} ?', + onConfirm: () => _fansController.onRemoveFan(index, item.mid!), + ); + + final flag = !isSelect && isOwner; return SizedBox( height: 66, child: InkWell( @@ -127,15 +135,8 @@ class _FansPageState extends State { } Get.toNamed('/member?mid=${item.mid}'); }, - onLongPress: widget.onSelect != null - ? null - : isOwner - ? () => showConfirmDialog( - context: context, - title: '确定移除 ${item.uname} ?', - onConfirm: () => _fansController.onRemoveFan(index, item.mid!), - ) - : null, + onLongPress: flag && Utils.isMobile ? onRemove : null, + onSecondaryTap: flag && !Utils.isMobile ? onRemove : null, child: Padding( padding: const EdgeInsets.symmetric( horizontal: 12, diff --git a/lib/pages/fav/note/widget/item.dart b/lib/pages/fav/note/widget/item.dart index 5037fb158..9bfbed363 100644 --- a/lib/pages/fav/note/widget/item.dart +++ b/lib/pages/fav/note/widget/item.dart @@ -4,6 +4,7 @@ import 'package:PiliPlus/common/widgets/select_mask.dart'; import 'package:PiliPlus/models_new/fav/fav_note/list.dart'; import 'package:PiliPlus/pages/fav/note/controller.dart'; import 'package:PiliPlus/utils/page_utils.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; class FavNoteItem extends StatelessWidget { @@ -18,6 +19,13 @@ class FavNoteItem extends StatelessWidget { final FavNoteController ctr; final VoidCallback onSelect; + void onLongPress() { + if (!ctr.enableMultiSelect.value) { + ctr.enableMultiSelect.value = true; + onSelect(); + } + } + @override Widget build(BuildContext context) { final theme = Theme.of(context); @@ -36,12 +44,8 @@ class FavNoteItem extends StatelessWidget { ); } }, - onLongPress: () { - if (!ctr.enableMultiSelect.value) { - ctr.enableMultiSelect.value = true; - onSelect(); - } - }, + onLongPress: Utils.isMobile ? onLongPress : null, + onSecondaryTap: Utils.isMobile ? null : onLongPress, child: Padding( padding: const EdgeInsets.symmetric( horizontal: StyleString.safeSpace, diff --git a/lib/pages/fav/pgc/widget/item.dart b/lib/pages/fav/pgc/widget/item.dart index bbaa6b030..96567c235 100644 --- a/lib/pages/fav/pgc/widget/item.dart +++ b/lib/pages/fav/pgc/widget/item.dart @@ -7,6 +7,7 @@ import 'package:PiliPlus/models/common/badge_type.dart'; import 'package:PiliPlus/models_new/fav/fav_pgc/list.dart'; import 'package:PiliPlus/pages/common/multi_select/base.dart'; import 'package:PiliPlus/utils/page_utils.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; class FavPgcItem extends StatelessWidget { @@ -23,6 +24,13 @@ class FavPgcItem extends StatelessWidget { final VoidCallback onSelect; final VoidCallback onUpdateStatus; + void onLongPress() { + if (!ctr.enableMultiSelect.value) { + ctr.enableMultiSelect.value = true; + onSelect(); + } + } + @override Widget build(BuildContext context) { final theme = Theme.of(context); @@ -39,12 +47,8 @@ class FavPgcItem extends StatelessWidget { } PageUtils.viewPgc(seasonId: item.seasonId); }, - onLongPress: () { - if (!ctr.enableMultiSelect.value) { - ctr.enableMultiSelect.value = true; - onSelect(); - } - }, + onLongPress: Utils.isMobile ? onLongPress : null, + onSecondaryTap: Utils.isMobile ? null : onLongPress, child: Padding( padding: const EdgeInsets.symmetric( horizontal: StyleString.safeSpace, diff --git a/lib/pages/fav/topic/view.dart b/lib/pages/fav/topic/view.dart index e5555928d..a56109513 100644 --- a/lib/pages/fav/topic/view.dart +++ b/lib/pages/fav/topic/view.dart @@ -6,6 +6,7 @@ import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/models_new/fav/fav_topic/topic_item.dart'; import 'package:PiliPlus/pages/fav/topic/controller.dart'; import 'package:PiliPlus/utils/grid.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -78,6 +79,13 @@ class _FavTopicPageState extends State _controller.onLoadMore(); } final item = response[index]; + + void onLongPress() => showConfirmDialog( + context: context, + title: '确定取消收藏?', + onConfirm: () => _controller.onRemove(index, item.id), + ); + return Material( color: theme.colorScheme.onInverseSurface, borderRadius: const BorderRadius.all(Radius.circular(6)), @@ -89,13 +97,8 @@ class _FavTopicPageState extends State 'name': item.name!, }, ), - onLongPress: () => showConfirmDialog( - context: context, - title: '确定取消收藏?', - onConfirm: () { - _controller.onRemove(index, item.id); - }, - ), + onLongPress: Utils.isMobile ? onLongPress : null, + onSecondaryTap: Utils.isMobile ? null : onLongPress, borderRadius: const BorderRadius.all( Radius.circular(6), ), diff --git a/lib/pages/follow/view.dart b/lib/pages/follow/view.dart index ec7e738a6..172241294 100644 --- a/lib/pages/follow/view.dart +++ b/lib/pages/follow/view.dart @@ -106,10 +106,15 @@ class _FollowPageState extends State { if (_isCustomTag(item.tagid)) { return GestureDetector( behavior: HitTestBehavior.translucent, - onLongPress: () { - Feedback.forLongPress(context); - _onHandleTag(index, item); - }, + onLongPress: Utils.isMobile + ? () { + Feedback.forLongPress(context); + _onHandleTag(index, item); + } + : null, + onSecondaryTap: Utils.isMobile + ? null + : () => _onHandleTag(index, item), child: Tab( child: Row( children: [ diff --git a/lib/pages/live/view.dart b/lib/pages/live/view.dart index 73e02b987..625f83c26 100644 --- a/lib/pages/live/view.dart +++ b/lib/pages/live/view.dart @@ -18,6 +18,7 @@ import 'package:PiliPlus/pages/live_follow/view.dart'; import 'package:PiliPlus/pages/search/widgets/search_text.dart'; import 'package:PiliPlus/utils/grid.dart'; import 'package:PiliPlus/utils/page_utils.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -287,10 +288,15 @@ class _LivePageState extends CommonPageState child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () => PageUtils.toLiveRoom(item.roomid), - onLongPress: () { - Feedback.forLongPress(context); - Get.toNamed('/member?mid=${item.uid}'); - }, + onLongPress: Utils.isMobile + ? () { + Feedback.forLongPress(context); + Get.toNamed('/member?mid=${item.uid}'); + } + : null, + onSecondaryTap: Utils.isMobile + ? null + : () => Get.toNamed('/member?mid=${item.uid}'), child: Column( mainAxisSize: MainAxisSize.min, children: [ diff --git a/lib/pages/mine/view.dart b/lib/pages/mine/view.dart index 9908fb38f..2eac85527 100644 --- a/lib/pages/mine/view.dart +++ b/lib/pages/mine/view.dart @@ -223,10 +223,15 @@ class _MediaPageState extends CommonPageState GestureDetector( behavior: HitTestBehavior.opaque, onTap: controller.onLogin, - onLongPress: () { - Feedback.forLongPress(context); - controller.onLogin(true); - }, + onLongPress: Utils.isMobile + ? () { + Feedback.forLongPress(context); + controller.onLogin(true); + } + : null, + onSecondaryTap: Utils.isMobile + ? null + : () => controller.onLogin(true), child: Row( mainAxisSize: MainAxisSize.min, children: [ diff --git a/lib/pages/pgc_review/child/view.dart b/lib/pages/pgc_review/child/view.dart index aad333d0a..571d9fd17 100644 --- a/lib/pages/pgc_review/child/view.dart +++ b/lib/pages/pgc_review/child/view.dart @@ -14,6 +14,7 @@ import 'package:PiliPlus/pages/pgc_review/post/view.dart'; import 'package:PiliPlus/utils/accounts.dart'; import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/num_utils.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:get/get.dart'; @@ -108,6 +109,76 @@ class _PgcReviewChildPageState extends State } Widget _itemWidget(ThemeData theme, int index, PgcReviewItemModel item) { + void showMore() => showDialog( + context: context, + builder: (context) => AlertDialog( + clipBehavior: Clip.hardEdge, + contentPadding: const EdgeInsets.symmetric(vertical: 12), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (item.author!.mid == Accounts.main.mid) ...[ + ListTile( + dense: true, + title: const Text( + '编辑', + style: TextStyle(fontSize: 14), + ), + onTap: () { + Get.back(); + showModalBottomSheet( + context: context, + useSafeArea: true, + isScrollControlled: true, + builder: (context) { + return PgcReviewPostPanel( + name: widget.name, + mediaId: widget.mediaId, + reviewId: item.reviewId, + content: item.content, + score: item.score, + ); + }, + ); + }, + ), + ListTile( + dense: true, + title: const Text( + '删除', + style: TextStyle(fontSize: 14), + ), + onTap: () { + Get.back(); + showConfirmDialog( + context: context, + title: '删除短评,同时删除评分?', + onConfirm: () => _controller.onDel(index, item.reviewId), + ); + }, + ), + ], + ListTile( + dense: true, + title: const Text( + '举报', + style: TextStyle(fontSize: 14), + ), + onTap: () => Get + ..back() + ..toNamed( + '/webview', + parameters: { + 'url': + 'https://www.bilibili.com/appeal/?reviewId=${item.reviewId}&type=shortComment&mediaId=${widget.mediaId}', + }, + ), + ), + ], + ), + ), + ); + return Material( type: MaterialType.transparency, child: InkWell( @@ -120,78 +191,8 @@ class _PgcReviewChildPageState extends State }, ) : null, - onLongPress: isLongReview - ? null - : () => showDialog( - context: context, - builder: (context) => AlertDialog( - clipBehavior: Clip.hardEdge, - contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - if (item.author!.mid == Accounts.main.mid) ...[ - ListTile( - dense: true, - title: const Text( - '编辑', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - showModalBottomSheet( - context: context, - useSafeArea: true, - isScrollControlled: true, - builder: (context) { - return PgcReviewPostPanel( - name: widget.name, - mediaId: widget.mediaId, - reviewId: item.reviewId, - content: item.content, - score: item.score, - ); - }, - ); - }, - ), - ListTile( - dense: true, - title: const Text( - '删除', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - showConfirmDialog( - context: context, - title: '删除短评,同时删除评分?', - onConfirm: () => - _controller.onDel(index, item.reviewId), - ); - }, - ), - ], - ListTile( - dense: true, - title: const Text( - '举报', - style: TextStyle(fontSize: 14), - ), - onTap: () => Get - ..back() - ..toNamed( - '/webview', - parameters: { - 'url': - 'https://www.bilibili.com/appeal/?reviewId=${item.reviewId}&type=shortComment&mediaId=${widget.mediaId}', - }, - ), - ), - ], - ), - ), - ), + onLongPress: !isLongReview && Utils.isMobile ? showMore : null, + onSecondaryTap: !isLongReview && !Utils.isMobile ? showMore : null, child: Padding( padding: const EdgeInsets.all(12), child: Column( diff --git a/lib/pages/search/widgets/search_text.dart b/lib/pages/search/widgets/search_text.dart index c1884912d..3abef6dd2 100644 --- a/lib/pages/search/widgets/search_text.dart +++ b/lib/pages/search/widgets/search_text.dart @@ -1,3 +1,4 @@ +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; class SearchText extends StatelessWidget { @@ -25,12 +26,18 @@ class SearchText extends StatelessWidget { @override Widget build(BuildContext context) { late final colorScheme = Theme.of(context).colorScheme; + final hasLongPress = onLongPress != null; return Material( color: bgColor ?? colorScheme.onInverseSurface, borderRadius: const BorderRadius.all(Radius.circular(6)), child: InkWell( onTap: () => onTap?.call(text), - onLongPress: onLongPress != null ? () => onLongPress!(text) : null, + onLongPress: hasLongPress && Utils.isMobile + ? () => onLongPress!(text) + : null, + onSecondaryTap: hasLongPress && !Utils.isMobile + ? () => onLongPress!(text) + : null, borderRadius: const BorderRadius.all(Radius.circular(6)), child: Padding( padding: diff --git a/lib/pages/video/reply/widgets/reply_item_grpc.dart b/lib/pages/video/reply/widgets/reply_item_grpc.dart index fcda16828..ca0df07d9 100644 --- a/lib/pages/video/reply/widgets/reply_item_grpc.dart +++ b/lib/pages/video/reply/widgets/reply_item_grpc.dart @@ -78,6 +78,25 @@ class ReplyItemGrpc extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); + + final isMobile = Utils.isMobile; + void showMore() => showModalBottomSheet( + context: context, + useSafeArea: true, + isScrollControlled: true, + constraints: BoxConstraints( + maxWidth: min(640, context.mediaQueryShortestSide), + ), + builder: (context) { + return morePanel( + context: context, + item: replyItem, + onDelete: () => onDelete?.call(replyItem, null), + isSubReply: false, + ); + }, + ); + return Material( type: MaterialType.transparency, child: InkWell( @@ -85,25 +104,13 @@ class ReplyItemGrpc extends StatelessWidget { feedBack(); replyReply?.call(replyItem, null); }, - onLongPress: () { - feedBack(); - showModalBottomSheet( - context: context, - useSafeArea: true, - isScrollControlled: true, - constraints: BoxConstraints( - maxWidth: min(640, context.mediaQueryShortestSide), - ), - builder: (context) { - return morePanel( - context: context, - item: replyItem, - onDelete: () => onDelete?.call(replyItem, null), - isSubReply: false, - ); - }, - ); - }, + onLongPress: isMobile + ? () { + feedBack(); + showMore(); + } + : null, + onSecondaryTap: isMobile ? null : showMore, child: _buildContent(context, theme), ), ); diff --git a/lib/pages/whisper_detail/widget/chat_item.dart b/lib/pages/whisper_detail/widget/chat_item.dart index 06a376e06..2e6cd90ae 100644 --- a/lib/pages/whisper_detail/widget/chat_item.dart +++ b/lib/pages/whisper_detail/widget/chat_item.dart @@ -16,6 +16,7 @@ import 'package:PiliPlus/utils/duration_utils.dart'; import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/image_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; @@ -83,12 +84,13 @@ class ChatItem extends StatelessWidget { textColor: textColor, ) : GestureDetector( - onLongPress: onLongPress == null - ? null - : () { + onLongPress: onLongPress != null && Utils.isMobile + ? () { Feedback.forLongPress(context); onLongPress!(); - }, + } + : null, + onSecondaryTap: !Utils.isMobile ? onLongPress : null, child: Row( mainAxisAlignment: isOwner ? MainAxisAlignment.end diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 52acb3bce..b9b24ee44 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -411,11 +411,17 @@ class _PLVideoPlayerState extends State ), ), onTap: widget.showViewPoints, - onLongPress: () { - Feedback.forLongPress(context); - videoDetailController.showVP.value = - !videoDetailController.showVP.value; - }, + onLongPress: Utils.isMobile + ? () { + Feedback.forLongPress(context); + videoDetailController.showVP.value = + !videoDetailController.showVP.value; + } + : null, + onSecondaryTap: Utils.isMobile + ? null + : () => videoDetailController.showVP.value = + !videoDetailController.showVP.value, ), ), diff --git a/lib/plugin/pl_player/widgets/common_btn.dart b/lib/plugin/pl_player/widgets/common_btn.dart index bda6bc283..e56ee7ce1 100644 --- a/lib/plugin/pl_player/widgets/common_btn.dart +++ b/lib/plugin/pl_player/widgets/common_btn.dart @@ -4,6 +4,7 @@ class ComBtn extends StatelessWidget { final Widget icon; final VoidCallback? onTap; final VoidCallback? onLongPress; + final VoidCallback? onSecondaryTap; final double width; final double height; final String? tooltip; @@ -13,6 +14,7 @@ class ComBtn extends StatelessWidget { required this.icon, this.onTap, this.onLongPress, + this.onSecondaryTap, this.width = 34, this.height = 34, this.tooltip, @@ -26,6 +28,7 @@ class ComBtn extends StatelessWidget { child: GestureDetector( onTap: onTap, onLongPress: onLongPress, + onSecondaryTap: onSecondaryTap, behavior: HitTestBehavior.opaque, child: icon, ),