diff --git a/lib/common/widgets/dialog/dialog.dart b/lib/common/widgets/dialog/dialog.dart index 9d9ff7b22..db4b717f5 100644 --- a/lib/common/widgets/dialog/dialog.dart +++ b/lib/common/widgets/dialog/dialog.dart @@ -64,42 +64,39 @@ void showPgcFollowDialog({ showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ...const [ - (followStatus: 3, title: '看过'), - (followStatus: 2, title: '在看'), - (followStatus: 1, title: '想看'), - ].map( - (item) => statusItem( - enabled: followStatus != item.followStatus, - text: item.title, - onTap: () { - Get.back(); - onUpdateStatus(item.followStatus); - }, - ), - ), - ListTile( - dense: true, - title: Padding( - padding: const EdgeInsets.only(left: 10), - child: Text( - '取消$type', - style: const TextStyle(fontSize: 14), - ), - ), + children: [ + ...const [ + (followStatus: 3, title: '看过'), + (followStatus: 2, title: '在看'), + (followStatus: 1, title: '想看'), + ].map( + (item) => statusItem( + enabled: followStatus != item.followStatus, + text: item.title, onTap: () { Get.back(); - onUpdateStatus(-1); + onUpdateStatus(item.followStatus); }, ), - ], - ), + ), + ListTile( + dense: true, + title: Padding( + padding: const EdgeInsets.only(left: 10), + child: Text( + '取消$type', + style: const TextStyle(fontSize: 14), + ), + ), + onTap: () { + Get.back(); + onUpdateStatus(-1); + }, + ), + ], ), ); } diff --git a/lib/common/widgets/image_viewer/gallery_viewer.dart b/lib/common/widgets/image_viewer/gallery_viewer.dart index 30ba4be0a..58c623ffb 100644 --- a/lib/common/widgets/image_viewer/gallery_viewer.dart +++ b/lib/common/widgets/image_viewer/gallery_viewer.dart @@ -534,76 +534,67 @@ class _GalleryViewerState extends State HapticFeedback.mediumImpact(); showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - if (PlatformUtils.isMobile) - ListTile( - onTap: () { - Get.back(); - ImageUtils.onShareImg(item.url); - }, - dense: true, - title: const Text('分享', style: TextStyle(fontSize: 14)), - ), - ListTile( - onTap: () { + children: [ + if (PlatformUtils.isMobile) + SimpleDialogOption( + onPressed: () { Get.back(); - Utils.copyText(item.url); + ImageUtils.onShareImg(item.url); }, - dense: true, - title: const Text('复制链接', style: TextStyle(fontSize: 14)), + child: const Text('分享', style: TextStyle(fontSize: 14)), ), - ListTile( - onTap: () { + SimpleDialogOption( + onPressed: () { + Get.back(); + Utils.copyText(item.url); + }, + child: const Text('复制链接', style: TextStyle(fontSize: 14)), + ), + SimpleDialogOption( + onPressed: () { + Get.back(); + ImageUtils.downloadImg([item.url]); + }, + child: const Text('保存图片', style: TextStyle(fontSize: 14)), + ), + if (PlatformUtils.isDesktop) + SimpleDialogOption( + onPressed: () { Get.back(); - ImageUtils.downloadImg([item.url]); + PageUtils.launchURL(item.url); }, - dense: true, - title: const Text('保存图片', style: TextStyle(fontSize: 14)), + child: const Text('网页打开', style: TextStyle(fontSize: 14)), + ) + else if (widget.sources.length > 1) + SimpleDialogOption( + onPressed: () { + Get.back(); + ImageUtils.downloadImg( + widget.sources.map((item) => item.url).toList(), + ); + }, + child: const Text('保存全部图片', style: TextStyle(fontSize: 14)), ), - if (PlatformUtils.isDesktop) - ListTile( - onTap: () { - Get.back(); - PageUtils.launchURL(item.url); - }, - dense: true, - title: const Text('网页打开', style: TextStyle(fontSize: 14)), - ) - else if (widget.sources.length > 1) - ListTile( - onTap: () { - Get.back(); - ImageUtils.downloadImg( - widget.sources.map((item) => item.url).toList(), - ); - }, - dense: true, - title: const Text('保存全部图片', style: TextStyle(fontSize: 14)), + if (item.sourceType == SourceType.livePhoto) + SimpleDialogOption( + onPressed: () { + Get.back(); + ImageUtils.downloadLivePhoto( + url: item.url, + liveUrl: item.liveUrl!, + width: item.width!, + height: item.height!, + ); + }, + child: Text( + '保存${Platform.isIOS ? ' Live Photo' : '视频'}', + style: const TextStyle(fontSize: 14), ), - if (item.sourceType == SourceType.livePhoto) - ListTile( - onTap: () { - Get.back(); - ImageUtils.downloadLivePhoto( - url: item.url, - liveUrl: item.liveUrl!, - width: item.width!, - height: item.height!, - ); - }, - dense: true, - title: Text( - '保存${Platform.isIOS ? ' Live Photo' : '视频'}', - style: const TextStyle(fontSize: 14), - ), - ), - ], - ), + ), + ], ), ); } diff --git a/lib/common/widgets/video_popup_menu.dart b/lib/common/widgets/video_popup_menu.dart index cde21a56f..5827544ea 100644 --- a/lib/common/widgets/video_popup_menu.dart +++ b/lib/common/widgets/video_popup_menu.dart @@ -147,134 +147,114 @@ class VideoPopupMenu extends StatelessWidget { showDialog( context: context, builder: (context) { - return AlertDialog( - content: SingleChildScrollView( - child: Column( - crossAxisAlignment: .start, - children: [ - if (tp.dislikeReasons != null) ...[ - const Text('我不想看'), - const SizedBox(height: 5), - Wrap( - spacing: 8.0, - runSpacing: 8.0, - children: tp.dislikeReasons!.map(( - item, - ) { - return actionButton(item, null); - }).toList(), - ), - ], - if (tp.feedbacks != null) ...[ - const SizedBox(height: 5), - const Text('反馈'), - const SizedBox(height: 5), - Wrap( - spacing: 8.0, - runSpacing: 8.0, - children: tp.feedbacks!.map((item) { - return actionButton(null, item); - }).toList(), - ), - ], - const Divider(), - Center( - child: FilledButton.tonal( - onPressed: () async { - SmartDialog.showLoading( - msg: '正在提交', + return SimpleDialog( + contentPadding: const .fromLTRB(24, 16, 24, 24), + children: [ + if (tp.dislikeReasons != null) ...[ + const Text('我不想看'), + const SizedBox(height: 5), + Wrap( + spacing: 8.0, + runSpacing: 8.0, + children: tp.dislikeReasons! + .map((item) => actionButton(item, null)) + .toList(), + ), + ], + if (tp.feedbacks != null) ...[ + const SizedBox(height: 5), + const Text('反馈'), + const SizedBox(height: 5), + Wrap( + spacing: 8.0, + runSpacing: 8.0, + children: tp.feedbacks! + .map((item) => actionButton(null, item)) + .toList(), + ), + ], + const Divider(), + Center( + child: FilledButton.tonal( + onPressed: () async { + SmartDialog.showLoading( + msg: '正在提交', + ); + final res = + await VideoHttp.feedDislikeCancel( + id: item.param!, + goto: item.goto!, ); - final res = - await VideoHttp.feedDislikeCancel( - id: item.param!, - goto: item.goto!, - ); - SmartDialog.dismiss(); - SmartDialog.showToast( - res.isSuccess - ? "成功" - : res.toString(), - ); - Get.back(); - }, - style: FilledButton.styleFrom( - visualDensity: VisualDensity.compact, - ), - child: const Text("撤销"), - ), + SmartDialog.dismiss(); + SmartDialog.showToast( + res.isSuccess ? "成功" : res.toString(), + ); + Get.back(); + }, + style: FilledButton.styleFrom( + visualDensity: VisualDensity.compact, ), - ], + child: const Text("撤销"), + ), ), - ), + ], ); }, ); } else { showDialog( context: context, - builder: (context) => AlertDialog( - content: SingleChildScrollView( - child: Column( + builder: (context) => SimpleDialog( + contentPadding: const .all(24), + children: [ + const Text("web端暂不支持精细选择"), + const SizedBox(height: 5), + Wrap( + spacing: 5.0, + runSpacing: 2.0, children: [ - const SizedBox(height: 5), - const Text("web端暂不支持精细选择"), - const SizedBox(height: 5), - Wrap( - spacing: 5.0, - runSpacing: 2.0, - children: [ - FilledButton.tonal( - onPressed: () async { - Get.back(); - SmartDialog.showLoading( - msg: '正在提交', - ); - final res = - await VideoHttp.dislikeVideo( - bvid: videoItem.bvid!, - type: true, - ); - SmartDialog.dismiss(); - if (res.isSuccess) { - SmartDialog.showToast('点踩成功'); - onRemove?.call(); - } else { - res.toast(); - } - }, - style: FilledButton.styleFrom( - visualDensity: VisualDensity.compact, - ), - child: const Text("点踩"), - ), - FilledButton.tonal( - onPressed: () async { - Get.back(); - SmartDialog.showLoading( - msg: '正在提交', - ); - final res = - await VideoHttp.dislikeVideo( - bvid: videoItem.bvid!, - type: false, - ); - SmartDialog.dismiss(); - SmartDialog.showToast( - res.isSuccess - ? '取消踩' - : res.toString(), - ); - }, - style: FilledButton.styleFrom( - visualDensity: VisualDensity.compact, - ), - child: const Text("撤销"), - ), - ], + FilledButton.tonal( + onPressed: () async { + Get.back(); + SmartDialog.showLoading(msg: '正在提交'); + final res = await VideoHttp.dislikeVideo( + bvid: videoItem.bvid!, + type: true, + ); + SmartDialog.dismiss(); + if (res.isSuccess) { + SmartDialog.showToast('点踩成功'); + onRemove?.call(); + } else { + res.toast(); + } + }, + style: FilledButton.styleFrom( + visualDensity: .compact, + ), + child: const Text("点踩"), + ), + FilledButton.tonal( + onPressed: () async { + Get.back(); + SmartDialog.showLoading(msg: '正在提交'); + final res = await VideoHttp.dislikeVideo( + bvid: videoItem.bvid!, + type: false, + ); + SmartDialog.dismiss(); + SmartDialog.showToast( + res.isSuccess ? '取消踩' : res.toString(), + ); + }, + style: FilledButton.styleFrom( + visualDensity: .compact, + ), + child: const Text("撤销"), ), ], ), - ), + ], ), ); } @@ -298,9 +278,7 @@ class VideoPopupMenu extends StatelessWidget { child: Text( '点错了', style: TextStyle( - color: Theme.of( - context, - ).colorScheme.outline, + color: ColorScheme.of(context).outline, ), ), ), diff --git a/lib/http/sponsor_block.dart b/lib/http/sponsor_block.dart index 553f2f051..0dfaa69b6 100644 --- a/lib/http/sponsor_block.dart +++ b/lib/http/sponsor_block.dart @@ -79,7 +79,7 @@ abstract final class SponsorBlock { int? type, SegmentType? category, }) async { - assert((type == null) == (category == null)); + assert((type == null) != (category == null)); final res = await Request().post( _api(SponsorBlockApi.voteOnSponsorTime), queryParameters: { diff --git a/lib/pages/audio/controller.dart b/lib/pages/audio/controller.dart index 8544b4082..9be2fe14b 100644 --- a/lib/pages/audio/controller.dart +++ b/lib/pages/audio/controller.dart @@ -533,116 +533,93 @@ class AudioController extends GetxController : '${HttpString.baseUrl}/audio/au$oid'; showDialog( context: context, - builder: (_) => AlertDialog( + builder: (_) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - dense: true, - title: const Text( - '复制链接', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - Utils.copyText(audioUrl); - }, - ), - ListTile( - dense: true, - title: const Text( - '其它app打开', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - PageUtils.launchURL(audioUrl); - }, - ), - if (PlatformUtils.isMobile) - ListTile( - dense: true, - title: const Text( - '分享视频', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - if (audioItem.value case DetailItem( - :final arc, - :final owner, - )) { - ShareUtils.shareText( - '${arc.title} ' - 'UP主: ${owner.name}' - ' - $audioUrl', - ); - } - }, - ), - ListTile( - dense: true, - title: const Text( - '分享至动态', - style: TextStyle(fontSize: 14), - ), - onTap: () { + children: [ + SimpleDialogOption( + child: const Text('复制链接', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + Utils.copyText(audioUrl); + }, + ), + SimpleDialogOption( + child: const Text('其它app打开', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + PageUtils.launchURL(audioUrl); + }, + ), + if (PlatformUtils.isMobile) + SimpleDialogOption( + child: const Text('分享视频', style: TextStyle(fontSize: 14)), + onPressed: () { Get.back(); if (audioItem.value case DetailItem( :final arc, :final owner, )) { - showModalBottomSheet( - context: context, - isScrollControlled: true, - useSafeArea: true, - builder: (context) => RepostPanel( - rid: oid.toInt(), - dynType: isUgc ? 8 : 256, - pic: arc.cover, - title: arc.title, - uname: owner.name, - ), + ShareUtils.shareText( + '${arc.title} ' + 'UP主: ${owner.name}' + ' - $audioUrl', ); } }, ), - if (isUgc) - ListTile( - dense: true, - title: const Text( - '分享至消息', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - if (audioItem.value case DetailItem( - :final arc, - :final owner, - )) { - try { - PageUtils.pmShare( - context, - content: { - "id": oid.toString(), - "title": arc.title, - "headline": arc.title, - "source": 5, - "thumb": arc.cover, - "author": owner.name, - "author_id": owner.mid.toString(), - }, - ); - } catch (e) { - SmartDialog.showToast(e.toString()); - } + SimpleDialogOption( + child: const Text('分享至动态', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + if (audioItem.value case DetailItem( + :final arc, + :final owner, + )) { + showModalBottomSheet( + context: context, + isScrollControlled: true, + useSafeArea: true, + builder: (context) => RepostPanel( + rid: oid.toInt(), + dynType: isUgc ? 8 : 256, + pic: arc.cover, + title: arc.title, + uname: owner.name, + ), + ); + } + }, + ), + if (isUgc) + SimpleDialogOption( + child: const Text('分享至消息', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + if (audioItem.value case DetailItem( + :final arc, + :final owner, + )) { + try { + PageUtils.pmShare( + context, + content: { + "id": oid.toString(), + "title": arc.title, + "headline": arc.title, + "source": 5, + "thumb": arc.cover, + "author": owner.name, + "author_id": owner.mid.toString(), + }, + ); + } catch (e) { + SmartDialog.showToast(e.toString()); } - }, - ), - ], - ), + } + }, + ), + ], ), ); } diff --git a/lib/pages/bubble/view.dart b/lib/pages/bubble/view.dart index 159ece5ca..d3940c341 100644 --- a/lib/pages/bubble/view.dart +++ b/lib/pages/bubble/view.dart @@ -91,34 +91,31 @@ class _BubblePageState extends State tooltip: '排序', onPressed: () => showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: .hardEdge, contentPadding: const .symmetric(vertical: 12), - content: Column( - mainAxisSize: .min, - children: sortInfo.sortItems!.map( - (e) { - final isSelected = item.sortType == e.sortType; - return ListTile( - dense: true, - enabled: !isSelected, - onTap: () { - Get.back(); - if (!isSelected) { - _controller.onSort(e.sortType); - } - }, - title: Text( - e.text!, - style: const TextStyle(fontSize: 14), - ), - trailing: isSelected - ? const Icon(size: 22, Icons.check) - : null, - ); - }, - ).toList(), - ), + children: sortInfo.sortItems!.map( + (e) { + final isSelected = item.sortType == e.sortType; + return ListTile( + dense: true, + enabled: !isSelected, + onTap: () { + Get.back(); + if (!isSelected) { + _controller.onSort(e.sortType); + } + }, + title: Text( + e.text!, + style: const TextStyle(fontSize: 14), + ), + trailing: isSelected + ? const Icon(size: 22, Icons.check) + : null, + ); + }, + ).toList(), ), ), icon: const Icon(Icons.sort, size: 20), diff --git a/lib/pages/download/detail/widgets/item.dart b/lib/pages/download/detail/widgets/item.dart index ac1c9e813..fca13e59a 100644 --- a/lib/pages/download/detail/widgets/item.dart +++ b/lib/pages/download/detail/widgets/item.dart @@ -61,48 +61,37 @@ class DetailItem extends StatelessWidget { void onLongPress() => canDel && !enableMultiSelect ? showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - onTap: () { - Get.back(); - showConfirmDialog( - context: context, - title: const Text('确定删除该视频?'), - onConfirm: onDelete, - ); - }, - dense: true, - title: const Text( - '删除', - style: TextStyle(fontSize: 14), - ), - ), - ListTile( - onTap: () async { - Get.back(); - final res = await downloadService.downloadDanmaku( - entry: entry, - isUpdate: true, - ); - if (res) { - SmartDialog.showToast('更新成功'); - } else { - SmartDialog.showToast('更新失败'); - } - }, - dense: true, - title: const Text( - '更新弹幕', - style: TextStyle(fontSize: 14), - ), - ), - ], - ), + children: [ + SimpleDialogOption( + onPressed: () { + Get.back(); + showConfirmDialog( + context: context, + title: const Text('确定删除该视频?'), + onConfirm: onDelete, + ); + }, + child: const Text('删除', style: TextStyle(fontSize: 14)), + ), + SimpleDialogOption( + onPressed: () async { + Get.back(); + final res = await downloadService.downloadDanmaku( + entry: entry, + isUpdate: true, + ); + if (res) { + SmartDialog.showToast('更新成功'); + } else { + SmartDialog.showToast('更新失败'); + } + }, + child: const Text('更新弹幕', style: TextStyle(fontSize: 14)), + ), + ], ), ) : null; diff --git a/lib/pages/download/view.dart b/lib/pages/download/view.dart index eba4574a5..fc9cfaf4a 100644 --- a/lib/pages/download/view.dart +++ b/lib/pages/download/view.dart @@ -232,59 +232,48 @@ class _DownloadPageState extends State { ? null : showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - onTap: () { - Get.back(); - showConfirmDialog( - context: context, - title: const Text('确定删除?'), - onConfirm: () async { - await GStorage.watchProgress.deleteAll( - pageInfo.entries.map((e) => e.cid.toString()), - ); - _downloadService.deletePage( - pageDirPath: pageInfo.dirPath, - ); - }, - ); - }, - dense: true, - title: const Text( - '删除', - style: TextStyle(fontSize: 14), - ), - ), - ListTile( - onTap: () async { - Get.back(); - final res = await Future.wait( - pageInfo.entries.map( - (e) => _downloadService.downloadDanmaku( - entry: e, - isUpdate: true, - ), + children: [ + SimpleDialogOption( + onPressed: () { + Get.back(); + showConfirmDialog( + context: context, + title: const Text('确定删除?'), + onConfirm: () async { + await GStorage.watchProgress.deleteAll( + pageInfo.entries.map((e) => e.cid.toString()), + ); + _downloadService.deletePage( + pageDirPath: pageInfo.dirPath, + ); + }, + ); + }, + child: const Text('删除', style: TextStyle(fontSize: 14)), + ), + SimpleDialogOption( + onPressed: () async { + Get.back(); + final res = await Future.wait( + pageInfo.entries.map( + (e) => _downloadService.downloadDanmaku( + entry: e, + isUpdate: true, ), - ); - if (res.every((e) => e)) { - SmartDialog.showToast('更新成功'); - } else { - SmartDialog.showToast('更新失败'); - } - }, - dense: true, - title: const Text( - '更新弹幕', - style: TextStyle(fontSize: 14), - ), - ), - ], - ), + ), + ); + if (res.every((e) => e)) { + SmartDialog.showToast('更新成功'); + } else { + SmartDialog.showToast('更新失败'); + } + }, + child: const Text('更新弹幕', style: TextStyle(fontSize: 14)), + ), + ], ), ); final first = pageInfo.entries.first; diff --git a/lib/pages/dynamics/widgets/author_panel.dart b/lib/pages/dynamics/widgets/author_panel.dart index 99ed4664d..008cb5bb8 100644 --- a/lib/pages/dynamics/widgets/author_panel.dart +++ b/lib/pages/dynamics/widgets/author_panel.dart @@ -431,41 +431,37 @@ class AuthorPanel extends StatelessWidget { final reply = response.upReply; final enableReply = reply.status == 1; - return AlertDialog( + return SimpleDialog( clipBehavior: .hardEdge, contentPadding: const .symmetric(vertical: 12), - content: Column( - mainAxisSize: .min, - crossAxisAlignment: .start, - children: [ - ListTile( - dense: true, - enabled: selection.canModify, - title: Text( - '${enableSelection ? '停止' : '开启'}评论精选', - style: const TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - onSetReplySubject!( - enableSelection ? 2 : 1, - ); - }, + children: [ + ListTile( + dense: true, + enabled: selection.canModify, + title: Text( + '${enableSelection ? '停止' : '开启'}评论精选', + style: const TextStyle(fontSize: 14), ), - ListTile( - dense: true, - enabled: reply.canModify, - title: Text( - '${enableReply ? '关闭' : '恢复'}评论', - style: const TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - onSetReplySubject!(enableReply ? 3 : 4); - }, + onTap: () { + Get.back(); + onSetReplySubject!( + enableSelection ? 2 : 1, + ); + }, + ), + ListTile( + dense: true, + enabled: reply.canModify, + title: Text( + '${enableReply ? '关闭' : '恢复'}评论', + style: const TextStyle(fontSize: 14), ), - ], - ), + onTap: () { + Get.back(); + onSetReplySubject!(enableReply ? 3 : 4); + }, + ), + ], ); }, ); @@ -504,32 +500,29 @@ class AuthorPanel extends StatelessWidget { showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const .symmetric(vertical: 12), - content: Column( - mainAxisSize: .min, - children: [ - ListTile( - dense: true, - enabled: isPrivate, - title: const Text( - '所有用户可见', - style: TextStyle(fontSize: 14), - ), - onTap: onTap, + children: [ + ListTile( + dense: true, + enabled: isPrivate, + title: const Text( + '所有用户可见', + style: TextStyle(fontSize: 14), ), - ListTile( - dense: true, - enabled: !isPrivate, - title: const Text( - '仅自己可见', - style: TextStyle(fontSize: 14), - ), - onTap: onTap, + onTap: onTap, + ), + ListTile( + dense: true, + enabled: !isPrivate, + title: const Text( + '仅自己可见', + style: TextStyle(fontSize: 14), ), - ], - ), + onTap: onTap, + ), + ], ), ); }, diff --git a/lib/pages/dynamics/widgets/vote.dart b/lib/pages/dynamics/widgets/vote.dart index 4ef0daced..d99673ef6 100644 --- a/lib/pages/dynamics/widgets/vote.dart +++ b/lib/pages/dynamics/widgets/vote.dart @@ -159,57 +159,52 @@ class _VotePanelState extends State { context: context, builder: (context) { final colorScheme = ColorScheme.of(context); - return AlertDialog( + return SimpleDialog( clipBehavior: .hardEdge, title: const Text('关注的人的投票'), contentPadding: const .only(top: 10, bottom: 12), - content: SingleChildScrollView( - child: Column( - mainAxisSize: .min, - children: list - .map( - (e) => ListTile( - dense: true, - onTap: () => - Get.toNamed('/member?mid=${e.mid}'), - leading: NetworkImgLayer( - src: e.face, - width: 40, - height: 40, - type: .avatar, - ), - title: Text.rich( - style: const TextStyle(fontSize: 13), + children: list + .map( + (e) => ListTile( + dense: true, + onTap: () => + Get.toNamed('/member?mid=${e.mid}'), + leading: NetworkImgLayer( + src: e.face, + width: 40, + height: 40, + type: .avatar, + ), + title: Text.rich( + style: const TextStyle(fontSize: 13), + TextSpan( + children: [ + TextSpan(text: e.name), TextSpan( - children: [ - TextSpan(text: e.name), - TextSpan( - text: ' 投给了', - style: TextStyle( - fontSize: 12, - color: colorScheme.outline, - ), - ), - ], + text: ' 投给了', + style: TextStyle( + fontSize: 12, + color: colorScheme.outline, + ), ), - ), - subtitle: Text( - style: const TextStyle(fontSize: 13), - e.votes - .map( - (vote) => _voteInfo.options - .firstWhereOrNull( - (e) => e.optIdx == vote, - ) - ?.optDesc, - ) - .join('、'), - ), + ], ), - ) - .toList(), - ), - ), + ), + subtitle: Text( + style: const TextStyle(fontSize: 13), + e.votes + .map( + (vote) => _voteInfo.options + .firstWhereOrNull( + (e) => e.optIdx == vote, + ) + ?.optDesc, + ) + .join('、'), + ), + ), + ) + .toList(), ); }, ); diff --git a/lib/pages/fav_create/view.dart b/lib/pages/fav_create/view.dart index 4b9faba17..3fc8363ee 100644 --- a/lib/pages/fav_create/view.dart +++ b/lib/pages/fav_create/view.dart @@ -195,37 +195,32 @@ class _CreateFavPageState extends State { if (_cover?.isNotEmpty == true) { showDialog( context: context, - builder: (_) => AlertDialog( + builder: (_) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const .symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - dense: true, - onTap: () { - Get.back(); - _pickImg(context, theme); - }, - title: const Text( - '替换封面', - style: TextStyle(fontSize: 14), - ), + children: [ + SimpleDialogOption( + onPressed: () { + Get.back(); + _pickImg(context, theme); + }, + child: const Text( + '替换封面', + style: TextStyle(fontSize: 14), ), - ListTile( - dense: true, - onTap: () { - Get.back(); - _cover = null; - (context as Element).markNeedsBuild(); - }, - title: const Text( - '移除封面', - style: TextStyle(fontSize: 14), - ), + ), + SimpleDialogOption( + onPressed: () { + Get.back(); + _cover = null; + (context as Element).markNeedsBuild(); + }, + child: const Text( + '移除封面', + style: TextStyle(fontSize: 14), ), - ], - ), + ), + ], ), ); } else { diff --git a/lib/pages/follow/view.dart b/lib/pages/follow/view.dart index 13688820e..57c90055f 100644 --- a/lib/pages/follow/view.dart +++ b/lib/pages/follow/view.dart @@ -194,62 +194,48 @@ class _FollowPageState extends State { void _onHandleTag(int index, MemberTagItemModel item) { showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - onTap: () { - Get.back(); - String tagName = item.name!; - showConfirmDialog( - context: context, - title: const Text('编辑分组名称'), - content: TextFormField( - autofocus: true, - initialValue: tagName, - onChanged: (value) => tagName = value, - inputFormatters: [ - LengthLimitingTextInputFormatter(16), - ], - decoration: const InputDecoration( - border: OutlineInputBorder(), - ), + children: [ + SimpleDialogOption( + onPressed: () { + Get.back(); + String tagName = item.name!; + showConfirmDialog( + context: context, + title: const Text('编辑分组名称'), + content: TextFormField( + autofocus: true, + initialValue: tagName, + onChanged: (value) => tagName = value, + inputFormatters: [LengthLimitingTextInputFormatter(16)], + decoration: const InputDecoration( + border: OutlineInputBorder(), ), - onConfirm: () { - if (tagName.isNotEmpty) { - _followController.onUpdateTag(item, tagName); - } - }, - ); - }, - dense: true, - title: const Text( - '修改名称', - style: TextStyle(fontSize: 14), - ), - ), - ListTile( - onTap: () { - Get.back(); - showConfirmDialog( - context: context, - title: const Text('删除分组'), - content: const Text('删除后,该分组下的用户依旧保留?'), - onConfirm: () => - _followController.onDelTag(index, item.tagid!), - ); - }, - dense: true, - title: const Text( - '删除分组', - style: TextStyle(fontSize: 14), - ), - ), - ], - ), + ), + onConfirm: () { + if (tagName.isNotEmpty) { + _followController.onUpdateTag(item, tagName); + } + }, + ); + }, + child: const Text('修改名称', style: TextStyle(fontSize: 14)), + ), + SimpleDialogOption( + onPressed: () { + Get.back(); + showConfirmDialog( + context: context, + title: const Text('删除分组'), + content: const Text('删除后,该分组下的用户依旧保留?'), + onConfirm: () => _followController.onDelTag(index, item.tagid!), + ); + }, + child: const Text('删除分组', style: TextStyle(fontSize: 14)), + ), + ], ), ); } diff --git a/lib/pages/member_opus/view.dart b/lib/pages/member_opus/view.dart index 22e4152b5..b4e0b1c77 100644 --- a/lib/pages/member_opus/view.dart +++ b/lib/pages/member_opus/view.dart @@ -98,37 +98,32 @@ class _MemberOpusState extends State child: FloatingActionButton.extended( onPressed: () => showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: _controller.filter! - .map( - (e) => ListTile( - onTap: () { - if (e == _controller.type.value) { - return; - } - Get.back(); - _controller - ..type.value = e - ..onReload(); - }, - tileColor: e == _controller.type.value - ? Theme.of( - context, - ).colorScheme.onInverseSurface - : null, - dense: true, - title: Text( - e.text ?? e.tabName!, - style: const TextStyle(fontSize: 14), - ), + children: _controller.filter! + .map( + (e) => ListTile( + dense: true, + onTap: () { + if (e == _controller.type.value) { + return; + } + Get.back(); + _controller + ..type.value = e + ..onReload(); + }, + tileColor: e == _controller.type.value + ? ColorScheme.of(context).onInverseSurface + : null, + title: Text( + e.text ?? e.tabName!, + style: const TextStyle(fontSize: 14), ), - ) - .toList(), - ), + ), + ) + .toList(), ), ), icon: const Icon(size: 20, Icons.sort), diff --git a/lib/pages/member_profile/view.dart b/lib/pages/member_profile/view.dart index 0fe5f38e7..debf999a1 100644 --- a/lib/pages/member_profile/view.dart +++ b/lib/pages/member_profile/view.dart @@ -247,17 +247,14 @@ class _EditProfilePageState extends State { } Widget _sexDialog(int current) { - return AlertDialog( + return SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - _sexDialogItem(1, current, '男'), - _sexDialogItem(0, current, '保密'), - _sexDialogItem(2, current, '女'), - ], - ), + children: [ + _sexDialogItem(1, current, '男'), + _sexDialogItem(0, current, '保密'), + _sexDialogItem(2, current, '女'), + ], ); } diff --git a/lib/pages/msg_feed_top/like_me/view.dart b/lib/pages/msg_feed_top/like_me/view.dart index c5164002c..fb8036b3e 100644 --- a/lib/pages/msg_feed_top/like_me/view.dart +++ b/lib/pages/msg_feed_top/like_me/view.dart @@ -97,13 +97,9 @@ class _LikeMePageState extends State { if (total.isEmpty && index == latest.length - 1) { _likeMeController.onLoadMore(); } - return _buildItem( - theme, - latest[index], - (id) { - _likeMeController.onRemove(id, index, true); - }, - ); + return _buildItem(theme, latest[index], (id) { + _likeMeController.onRemove(id, index, true); + }); }, itemCount: latest.length, separatorBuilder: (context, index) => divider, @@ -116,13 +112,9 @@ class _LikeMePageState extends State { if (index == total.length - 1) { _likeMeController.onLoadMore(); } - return _buildItem( - theme, - total[index], - (id) { - _likeMeController.onRemove(id, index, false); - }, - ); + return _buildItem(theme, total[index], (id) { + _likeMeController.onRemove(id, index, false); + }); }, itemCount: total.length, separatorBuilder: (context, index) => divider, @@ -200,51 +192,43 @@ class _LikeMePageState extends State { context: context, builder: (context) { final isNotice = item.noticeState == 0; - return AlertDialog( + return SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - onTap: () { - Get.back(); + children: [ + SimpleDialogOption( + onPressed: () { + Get.back(); + showConfirmDialog( + context: context, + title: const Text('删除'), + content: const Text('该条通知删除后,当有新点赞时会重新出现在列表,是否继续?'), + onConfirm: () => onRemove(item.id), + ); + }, + child: const Text('删除', style: TextStyle(fontSize: 14)), + ), + SimpleDialogOption( + onPressed: () { + Get.back(); + if (isNotice) { showConfirmDialog( context: context, - title: const Text('删除'), - content: const Text('该条通知删除后,当有新点赞时会重新出现在列表,是否继续?'), - onConfirm: () => onRemove(item.id), + title: const Text('不再通知'), + content: const Text('这条内容的点赞将不再通知,但仍可在列表内查看,是否继续?'), + onConfirm: () => + _likeMeController.onSetNotice(item, isNotice), ); - }, - dense: true, - title: const Text( - '删除', - style: TextStyle(fontSize: 14), - ), + } else { + _likeMeController.onSetNotice(item, isNotice); + } + }, + child: Text( + isNotice ? '不再通知' : '接收通知', + style: const TextStyle(fontSize: 14), ), - ListTile( - onTap: () { - Get.back(); - if (isNotice) { - showConfirmDialog( - context: context, - title: const Text('不再通知'), - content: const Text('这条内容的点赞将不再通知,但仍可在列表内查看,是否继续?'), - onConfirm: () => - _likeMeController.onSetNotice(item, isNotice), - ); - } else { - _likeMeController.onSetNotice(item, isNotice); - } - }, - dense: true, - title: Text( - isNotice ? '不再通知' : '接收通知', - style: const TextStyle(fontSize: 14), - ), - ), - ], - ), + ), + ], ); }, ); @@ -336,9 +320,7 @@ class _LikeMePageState extends State { width: 45, height: 45, src: item.item!.image, - borderRadius: const BorderRadius.all( - Radius.circular(8), - ), + borderRadius: const BorderRadius.all(Radius.circular(8)), ), if (item.noticeState == 1) ...[ if (item.item?.image?.isNotEmpty == true) const SizedBox(width: 4), diff --git a/lib/pages/pgc_review/child/view.dart b/lib/pages/pgc_review/child/view.dart index 6718180e1..f051e8203 100644 --- a/lib/pages/pgc_review/child/view.dart +++ b/lib/pages/pgc_review/child/view.dart @@ -120,71 +120,56 @@ class _PgcReviewChildPageState extends State Widget _itemWidget(ThemeData theme, int index, PgcReviewItemModel item) { void showMore() => showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( 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: const Text('删除短评,同时删除评分?'), - 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}', + children: [ + if (item.author!.mid == Accounts.main.mid) ...[ + SimpleDialogOption( + child: const Text('编辑', style: TextStyle(fontSize: 14)), + onPressed: () { + 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, + ); }, - ), + ); + }, + ), + SimpleDialogOption( + child: const Text('删除', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + showConfirmDialog( + context: context, + title: const Text('删除短评,同时删除评分?'), + onConfirm: () => _controller.onDel(index, item.reviewId!), + ); + }, ), ], - ), + SimpleDialogOption( + child: const Text('举报', style: TextStyle(fontSize: 14)), + onPressed: () => Get + ..back() + ..toNamed( + '/webview', + parameters: { + 'url': + 'https://www.bilibili.com/appeal/?reviewId=${item.reviewId}&type=shortComment&mediaId=${widget.mediaId}', + }, + ), + ), + ], ), ); diff --git a/lib/pages/pgc_review/view.dart b/lib/pages/pgc_review/view.dart index 3d23873d2..980a2cdc8 100644 --- a/lib/pages/pgc_review/view.dart +++ b/lib/pages/pgc_review/view.dart @@ -115,51 +115,40 @@ class _PgcReviewPageState extends State child: FloatingActionButton( onPressed: () => showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - dense: true, - title: const Text( - '写短评', - style: TextStyle(fontSize: 14), + children: [ + SimpleDialogOption( + child: const Text('写短评', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + showModalBottomSheet( + context: context, + useSafeArea: true, + isScrollControlled: true, + builder: (context) { + return PgcReviewPostPanel( + name: widget.name, + mediaId: widget.mediaId, + ); + }, + ); + }, + ), + SimpleDialogOption( + child: const Text('写长评', style: TextStyle(fontSize: 14)), + onPressed: () => Get + ..back() + ..toNamed( + '/webview', + parameters: { + 'url': + 'https://member.bilibili.com/article-text/mobile?theme=${theme.isDark ? 1 : 0}&media_id=${widget.mediaId}', + }, ), - onTap: () { - Get.back(); - showModalBottomSheet( - context: context, - useSafeArea: true, - isScrollControlled: true, - builder: (context) { - return PgcReviewPostPanel( - name: widget.name, - mediaId: widget.mediaId, - ); - }, - ); - }, - ), - ListTile( - dense: true, - title: const Text( - '写长评', - style: TextStyle(fontSize: 14), - ), - onTap: () => Get - ..back() - ..toNamed( - '/webview', - parameters: { - 'url': - 'https://member.bilibili.com/article-text/mobile?theme=${theme.isDark ? 1 : 0}&media_id=${widget.mediaId}', - }, - ), - ), - ], - ), + ), + ], ), ), child: const Icon(Icons.edit), diff --git a/lib/pages/setting/models/extra_settings.dart b/lib/pages/setting/models/extra_settings.dart index e7e72cd64..f5c334588 100644 --- a/lib/pages/setting/models/extra_settings.dart +++ b/lib/pages/setting/models/extra_settings.dart @@ -712,48 +712,42 @@ Future audioNormalization( void _showDownPathDialog(BuildContext context, VoidCallback setState) { showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - onTap: () { - Get.back(); - Utils.copyText(downloadPath); - }, - dense: true, - title: const Text('复制', style: TextStyle(fontSize: 14)), - ), - ListTile( - onTap: () { - Get.back(); - final defPath = defDownloadPath; - if (downloadPath == defPath) return; - downloadPath = defPath; - setState(); - Get.find().initDownloadList(); - GStorage.setting.delete(SettingBoxKey.downloadPath); - }, - dense: true, - title: const Text('重置', style: TextStyle(fontSize: 14)), - ), - ListTile( - onTap: () async { - Get.back(); - final path = await FilePicker.getDirectoryPath(); - if (path == null || path == downloadPath) return; - downloadPath = path; - setState(); - Get.find().initDownloadList(); - GStorage.setting.put(SettingBoxKey.downloadPath, path); - }, - dense: true, - title: const Text('设置新路径', style: TextStyle(fontSize: 14)), - ), - ], - ), + children: [ + SimpleDialogOption( + onPressed: () { + Get.back(); + Utils.copyText(downloadPath); + }, + child: const Text('复制', style: TextStyle(fontSize: 14)), + ), + SimpleDialogOption( + onPressed: () { + Get.back(); + final defPath = defDownloadPath; + if (downloadPath == defPath) return; + downloadPath = defPath; + setState(); + Get.find().initDownloadList(); + GStorage.setting.delete(SettingBoxKey.downloadPath); + }, + child: const Text('重置', style: TextStyle(fontSize: 14)), + ), + SimpleDialogOption( + onPressed: () async { + Get.back(); + final path = await FilePicker.getDirectoryPath(); + if (path == null || path == downloadPath) return; + downloadPath = path; + setState(); + Get.find().initDownloadList(); + GStorage.setting.put(SettingBoxKey.downloadPath, path); + }, + child: const Text('设置新路径', style: TextStyle(fontSize: 14)), + ), + ], ), ); } diff --git a/lib/pages/setting/models/privacy_settings.dart b/lib/pages/setting/models/privacy_settings.dart index 1a241d7ff..3734b72bf 100644 --- a/lib/pages/setting/models/privacy_settings.dart +++ b/lib/pages/setting/models/privacy_settings.dart @@ -25,9 +25,7 @@ List get privacySettings => [ context: context, builder: (context) => AlertDialog( title: const Text('账号模式详情'), - content: SingleChildScrollView( - child: _getAccountDetail(context), - ), + content: SingleChildScrollView(child: _getAccountDetail(context)), actions: [ TextButton( onPressed: Get.back, diff --git a/lib/pages/sponsor_block/block_mixin.dart b/lib/pages/sponsor_block/block_mixin.dart index 907908545..30c0e4f83 100644 --- a/lib/pages/sponsor_block/block_mixin.dart +++ b/lib/pages/sponsor_block/block_mixin.dart @@ -285,40 +285,32 @@ mixin BlockMixin on GetxController { void _showVoteDialog(SegmentModel segment) { showDialog( context: Get.context!, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.fromLTRB(0, 10, 0, 10), - content: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - dense: true, - title: const Text('赞成票', style: TextStyle(fontSize: 14)), - onTap: () { - Get.back(); - _doVote(segment.uuid, 1); - }, - ), - ListTile( - dense: true, - title: const Text('反对票', style: TextStyle(fontSize: 14)), - onTap: () { - Get.back(); - _doVote(segment.uuid, 0); - }, - ), - ListTile( - dense: true, - title: const Text('更改类别', style: TextStyle(fontSize: 14)), - onTap: () { - Get.back(); - _showCategoryDialog(segment); - }, - ), - ], + children: [ + SimpleDialogOption( + child: const Text('赞成票', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + _doVote(segment.uuid, 1); + }, ), - ), + SimpleDialogOption( + child: const Text('反对票', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + _doVote(segment.uuid, 0); + }, + ), + SimpleDialogOption( + child: const Text('更改类别', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + _showCategoryDialog(segment); + }, + ), + ], ), ); } @@ -331,54 +323,49 @@ mixin BlockMixin on GetxController { void _showCategoryDialog(SegmentModel segment) { showDialog( context: Get.context!, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.fromLTRB(0, 10, 0, 10), - content: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.min, - children: SegmentType.values - .map( - (item) => ListTile( - dense: true, - onTap: () { - Get.back(); - SponsorBlock.voteOnSponsorTime( - uuid: segment.uuid, - category: item, - ).then((i) { - SmartDialog.showToast( - '类别更改${i.isSuccess ? '成功' : '失败: $i'}', - ); - }); - }, - title: Text.rich( - TextSpan( - children: [ - WidgetSpan( - alignment: PlaceholderAlignment.middle, - child: Container( - height: 10, - width: 10, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: blockConfig._getColor(item), - ), - ), - style: const TextStyle(fontSize: 14, height: 1), + children: SegmentType.values + .map( + (item) => ListTile( + dense: true, + onTap: () { + Get.back(); + SponsorBlock.voteOnSponsorTime( + uuid: segment.uuid, + category: item, + ).then((i) { + SmartDialog.showToast( + '类别更改${i.isSuccess ? '成功' : '失败: $i'}', + ); + }); + }, + title: Text.rich( + TextSpan( + children: [ + WidgetSpan( + alignment: PlaceholderAlignment.middle, + child: Container( + height: 10, + width: 10, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: blockConfig._getColor(item), ), - TextSpan( - text: ' ${item.title}', - style: const TextStyle(fontSize: 14, height: 1), - ), - ], + ), + style: const TextStyle(fontSize: 14, height: 1), ), - ), + TextSpan( + text: ' ${item.title}', + style: const TextStyle(fontSize: 14, height: 1), + ), + ], ), - ) - .toList(), - ), - ), + ), + ), + ) + .toList(), ), ); } @@ -386,96 +373,91 @@ mixin BlockMixin on GetxController { void showSBDetail() { showDialog( context: Get.context!, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.fromLTRB(0, 10, 0, 10), - content: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.min, - children: _segmentList - .map( - (item) => ListTile( - onTap: () { - Get.back(); - if (isBlock) { - _showVoteDialog(item); - } - }, - dense: true, - title: Text.rich( - TextSpan( - children: [ - WidgetSpan( - alignment: PlaceholderAlignment.middle, - child: Container( - height: 10, - width: 10, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: blockConfig._getColor(item.segmentType), - ), - ), - style: const TextStyle(fontSize: 14, height: 1), + children: _segmentList + .map( + (item) => ListTile( + onTap: () { + Get.back(); + if (isBlock) { + _showVoteDialog(item); + } + }, + dense: true, + title: Text.rich( + TextSpan( + children: [ + WidgetSpan( + alignment: PlaceholderAlignment.middle, + child: Container( + height: 10, + width: 10, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: blockConfig._getColor(item.segmentType), ), - TextSpan( - text: ' ${item.segmentType.title}', - style: const TextStyle(fontSize: 14, height: 1), - ), - ], + ), + style: const TextStyle(fontSize: 14, height: 1), ), - ), - contentPadding: const EdgeInsets.only(left: 16, right: 8), - subtitle: Text( - '${DurationUtils.formatDuration(item.segment.$1 / 1000)} 至 ${DurationUtils.formatDuration(item.segment.$2 / 1000)}', + TextSpan( + text: ' ${item.segmentType.title}', + style: const TextStyle(fontSize: 14, height: 1), + ), + ], + ), + ), + contentPadding: const EdgeInsets.only(left: 16, right: 8), + subtitle: Text( + '${DurationUtils.formatDuration(item.segment.$1 / 1000)} 至 ${DurationUtils.formatDuration(item.segment.$2 / 1000)}', + style: const TextStyle(fontSize: 13), + ), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + item.skipType.label, style: const TextStyle(fontSize: 13), ), - trailing: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - item.skipType.label, - style: const TextStyle(fontSize: 13), + if (item.segment.$2 != 0) + SizedBox( + width: 36, + height: 36, + child: IconButton( + tooltip: item.skipType == SkipType.showOnly + ? '跳至此片段' + : '跳过此片段', + onPressed: () { + Get.back(); + onSkip( + item, + isSkip: item.skipType != SkipType.showOnly, + isSeek: false, + ); + }, + style: IconButton.styleFrom( + padding: EdgeInsets.zero, + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + ), + icon: Icon( + item.skipType == SkipType.showOnly + ? Icons.my_location + : MdiIcons.debugStepOver, + size: 18, + color: ColorScheme.of( + context, + ).onSurface.withValues(alpha: 0.7), + ), ), - if (item.segment.$2 != 0) - SizedBox( - width: 36, - height: 36, - child: IconButton( - tooltip: item.skipType == SkipType.showOnly - ? '跳至此片段' - : '跳过此片段', - onPressed: () { - Get.back(); - onSkip( - item, - isSkip: item.skipType != SkipType.showOnly, - isSeek: false, - ); - }, - style: IconButton.styleFrom( - padding: EdgeInsets.zero, - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - ), - icon: Icon( - item.skipType == SkipType.showOnly - ? Icons.my_location - : MdiIcons.debugStepOver, - size: 18, - color: Theme.of( - context, - ).colorScheme.onSurface.withValues(alpha: 0.7), - ), - ), - ) - else - const SizedBox(width: 10), - ], - ), - ), - ) - .toList(), - ), - ), + ) + else + const SizedBox(width: 10), + ], + ), + ), + ) + .toList(), ), ); } diff --git a/lib/pages/video/introduction/pgc/controller.dart b/lib/pages/video/introduction/pgc/controller.dart index 21cb48e02..3b3b77686 100644 --- a/lib/pages/video/introduction/pgc/controller.dart +++ b/lib/pages/video/introduction/pgc/controller.dart @@ -123,137 +123,117 @@ class PgcIntroController extends CommonIntroController { '${HttpString.baseUrl}/bangumi/play/ep$epId${videoDetailCtr.playedTimePos}'; showDialog( context: context, - builder: (_) => AlertDialog( + builder: (_) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - dense: true, - title: const Text( - '复制链接', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - Utils.copyText(videoUrl); - }, - ), - ListTile( - dense: true, - title: const Text( - '其它app打开', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - PageUtils.launchURL(videoUrl); - }, - ), - if (PlatformUtils.isMobile) - ListTile( - dense: true, - title: const Text( - '分享视频', - style: TextStyle(fontSize: 14), - ), - onTap: () { - final item = pgcItem.episodes?.firstWhereOrNull( - (item) => item.epId == epId, - ); - Get.back(); - ShareUtils.shareText( - '${pgcItem.title}${item != null ? ' ${item.showTitle}' : ''}' - ' - $videoUrl', - ); - }, - ), - ListTile( - dense: true, - title: const Text( - '分享至动态', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); + children: [ + SimpleDialogOption( + child: const Text('复制链接', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + Utils.copyText(videoUrl); + }, + ), + SimpleDialogOption( + child: const Text('其它app打开', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + PageUtils.launchURL(videoUrl); + }, + ), + if (PlatformUtils.isMobile) + SimpleDialogOption( + child: const Text('分享视频', style: TextStyle(fontSize: 14)), + onPressed: () { final item = pgcItem.episodes?.firstWhereOrNull( (item) => item.epId == epId, ); - showModalBottomSheet( - context: context, - isScrollControlled: true, - useSafeArea: true, - builder: (context) => RepostPanel( - rid: epId, - /** - * 1:番剧 // 4097 - 2:电影 // 4098 - 3:纪录片 // 4101 - 4:国创 // 4100 - 5:电视剧 // 4099 - 6:漫画 - 7:综艺 // 4099 - */ - dynType: switch (pgcItem.type) { - 1 => 4097, - 2 => 4098, - 3 => 4101, - 4 => 4100, - 5 || 7 => 4099, - _ => -1, - }, - pic: pgcItem.cover, - title: - '${pgcItem.title}${item != null ? '\n${item.showTitle}' : ''}', - uname: '', - ), + Get.back(); + ShareUtils.shareText( + '${pgcItem.title}${item != null ? ' ${item.showTitle}' : ''}' + ' - $videoUrl', ); }, ), - ListTile( - dense: true, - title: const Text( - '分享至消息', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - try { - EpisodeItem item = pgcItem.episodes!.firstWhere( - (item) => item.epId == epId, - ); - final title = - item.shareCopy ?? - '${pgcItem.title} ${item.showTitle ?? item.longTitle}'; - PageUtils.pmShare( - context, - content: { - "id": epId!.toString(), - "title": title, - "url": item.shareUrl, - "headline": title, - "source": 16, - "thumb": item.cover, - "source_desc": switch (pgcItem.type) { - 1 => '番剧', - 2 => '电影', - 3 => '纪录片', - 4 => '国创', - 5 => '电视剧', - 6 => '漫画', - 7 => '综艺', - _ => null, - }, - }, - ); - } catch (e) { - SmartDialog.showToast(e.toString()); - } - }, + SimpleDialogOption( + child: const Text('分享至动态', style: TextStyle(fontSize: 14)), + onPressed: () { + Get.back(); + final item = pgcItem.episodes?.firstWhereOrNull( + (item) => item.epId == epId, + ); + showModalBottomSheet( + context: context, + isScrollControlled: true, + useSafeArea: true, + builder: (context) => RepostPanel( + rid: epId, + /* + 1:番剧 // 4097 + 2:电影 // 4098 + 3:纪录片 // 4101 + 4:国创 // 4100 + 5:电视剧 // 4099 + 6:漫画 + 7:综艺 // 4099 + */ + dynType: switch (pgcItem.type) { + 1 => 4097, + 2 => 4098, + 3 => 4101, + 4 => 4100, + 5 || 7 => 4099, + _ => -1, + }, + pic: pgcItem.cover, + title: + '${pgcItem.title}${item != null ? '\n${item.showTitle}' : ''}', + uname: '', + ), + ); + }, + ), + SimpleDialogOption( + child: const Text( + '分享至消息', + style: TextStyle(fontSize: 14), ), - ], - ), + onPressed: () { + Get.back(); + try { + final item = pgcItem.episodes!.firstWhere( + (item) => item.epId == epId, + ); + final title = + item.shareCopy ?? + '${pgcItem.title} ${item.showTitle ?? item.longTitle}'; + PageUtils.pmShare( + context, + content: { + "id": epId!.toString(), + "title": title, + "url": item.shareUrl, + "headline": title, + "source": 16, + "thumb": item.cover, + "source_desc": switch (pgcItem.type) { + 1 => '番剧', + 2 => '电影', + 3 => '纪录片', + 4 => '国创', + 5 => '电视剧', + 6 => '漫画', + 7 => '综艺', + _ => null, + }, + }, + ); + } catch (e) { + SmartDialog.showToast(e.toString()); + } + }, + ), + ], ), ); } diff --git a/lib/pages/video/introduction/ugc/controller.dart b/lib/pages/video/introduction/ugc/controller.dart index dc1b10c92..12e46b918 100644 --- a/lib/pages/video/introduction/ugc/controller.dart +++ b/lib/pages/video/introduction/ugc/controller.dart @@ -292,110 +292,107 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { String videoUrl = '${HttpString.baseUrl}/video/$bvid'; showDialog( context: context, - builder: (_) => AlertDialog( + builder: (_) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - dense: true, - title: const Text( - '复制链接', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - Utils.copyText(videoUrl); - }, - trailing: playedTimePos.isNotEmpty - ? iconButton( - tooltip: '精确分享', - icon: const Icon(Icons.timer_outlined), - onPressed: () { - Get.back(); - Utils.copyText('$videoUrl$playedTimePos'); - }, - ) - : null, + children: [ + ListTile( + dense: true, + title: const Text( + '复制链接', + style: TextStyle(fontSize: 14), ), - ListTile( - dense: true, - title: const Text( - '其它app打开', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - PageUtils.launchURL(videoUrl); - }, + onTap: () { + Get.back(); + Utils.copyText(videoUrl); + }, + trailing: playedTimePos.isNotEmpty + ? iconButton( + tooltip: '精确分享', + icon: const Icon(Icons.timer_outlined), + onPressed: () { + Get.back(); + Utils.copyText('$videoUrl$playedTimePos'); + }, + ) + : null, + ), + ListTile( + dense: true, + title: const Text( + '其它app打开', + style: TextStyle(fontSize: 14), ), - if (PlatformUtils.isMobile) - ListTile( - dense: true, - title: const Text( - '分享视频', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - ShareUtils.shareText( - '${videoDetail.title} ' - 'UP主: ${videoDetail.owner!.name!}' - ' - $videoUrl', - ); - }, - ), + onTap: () { + Get.back(); + PageUtils.launchURL(videoUrl); + }, + ), + if (PlatformUtils.isMobile) ListTile( dense: true, title: const Text( - '分享至动态', + '分享视频', style: TextStyle(fontSize: 14), ), onTap: () { Get.back(); - showModalBottomSheet( - context: context, - isScrollControlled: true, - useSafeArea: true, - builder: (context) => RepostPanel( - rid: videoDetail.aid, - dynType: 8, - pic: videoDetail.pic, - title: videoDetail.title, - uname: videoDetail.owner?.name, - ), + ShareUtils.shareText( + '${videoDetail.title} ' + 'UP主: ${videoDetail.owner!.name!}' + ' - $videoUrl', ); }, ), - ListTile( - dense: true, - title: const Text( - '分享至消息', - style: TextStyle(fontSize: 14), - ), - onTap: () { - Get.back(); - try { - PageUtils.pmShare( - context, - content: { - "id": videoDetail.aid!.toString(), - "title": videoDetail.title!, - "headline": videoDetail.title!, - "source": 5, - "thumb": videoDetail.pic!, - "author": videoDetail.owner!.name!, - "author_id": videoDetail.owner!.mid!.toString(), - }, - ); - } catch (e) { - SmartDialog.showToast(e.toString()); - } - }, + ListTile( + dense: true, + title: const Text( + '分享至动态', + style: TextStyle(fontSize: 14), ), - ], - ), + onTap: () { + Get.back(); + showModalBottomSheet( + context: context, + isScrollControlled: true, + useSafeArea: true, + builder: (context) => RepostPanel( + rid: videoDetail.aid, + dynType: 8, + pic: videoDetail.pic, + title: videoDetail.title, + uname: videoDetail.owner?.name, + ), + ); + }, + ), + ListTile( + dense: true, + title: const Text( + '分享至消息', + style: TextStyle(fontSize: 14), + ), + onTap: () { + Get.back(); + try { + PageUtils.pmShare( + context, + content: { + "id": videoDetail.aid!.toString(), + "title": videoDetail.title!, + "headline": videoDetail.title!, + "source": 5, + "thumb": videoDetail.pic!, + "author": videoDetail.owner!.name!, + "author_id": videoDetail.owner!.mid!.toString(), + }, + ); + } catch (e) { + SmartDialog.showToast(e.toString()); + } + }, + ), + ], ), ); } diff --git a/lib/pages/video/widgets/header_control.dart b/lib/pages/video/widgets/header_control.dart index 5d1bcca05..df97e72f9 100644 --- a/lib/pages/video/widgets/header_control.dart +++ b/lib/pages/video/widgets/header_control.dart @@ -789,9 +789,7 @@ class HeaderControlState extends State content: Material( type: MaterialType.transparency, child: ListTileTheme( - contentPadding: const EdgeInsets.symmetric( - horizontal: 24, - ), + contentPadding: const .symmetric(horizontal: 24), child: SingleChildScrollView( child: Column( children: [ @@ -1152,65 +1150,57 @@ class HeaderControlState extends State void onExportSubtitle() { showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12), title: const Text('保存字幕'), - content: SingleChildScrollView( - child: Column( - children: videoDetailCtr.subtitles - .map( - (item) => ListTile( - dense: true, - onTap: () async { - Get.back(); - final url = item.subtitleUrl; - if (url == null || url.isEmpty) return; - try { - final res = await Request.dio.get( - url.http2https, - options: Options( - responseType: ResponseType.bytes, - headers: Constants.baseHeaders, - extra: {'account': const NoAccount()}, - ), + children: videoDetailCtr.subtitles + .map( + (item) => SimpleDialogOption( + onPressed: () async { + Get.back(); + final url = item.subtitleUrl; + if (url == null || url.isEmpty) return; + try { + final res = await Request.dio.get( + url.http2https, + options: Options( + responseType: ResponseType.bytes, + headers: Constants.baseHeaders, + extra: {'account': const NoAccount()}, + ), + ); + if (res.statusCode == 200) { + final bytes = Uint8List.fromList( + Request.responseBytesDecoder( + res.data!, + res.headers.map, + ), + ); + String name = + '${introController.videoDetail.value.title}-${videoDetailCtr.bvid}-${videoDetailCtr.cid.value}-${item.lanDoc}.json'; + if (Platform.isWindows) { + // Reserved characters may not be used in file names. See: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions + name = name.replaceAll( + RegExp(r'[<>:/\\|?*"]'), + '', ); - if (res.statusCode == 200) { - final bytes = Uint8List.fromList( - Request.responseBytesDecoder( - res.data!, - res.headers.map, - ), - ); - String name = - '${introController.videoDetail.value.title}-${videoDetailCtr.bvid}-${videoDetailCtr.cid.value}-${item.lanDoc}.json'; - if (Platform.isWindows) { - // Reserved characters may not be used in file names. See: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions - name = name.replaceAll( - RegExp(r'[<>:/\\|?*"]'), - '', - ); - } - StorageUtils.saveBytes2File( - name: name, - bytes: bytes, - allowedExtensions: const ['json'], - ); - } - } catch (e, s) { - Utils.reportError(e, s); - SmartDialog.showToast(e.toString()); } - }, - title: Text( - item.lanDoc!, - style: const TextStyle(fontSize: 14), - ), - ), - ) - .toList(), - ), - ), + StorageUtils.saveBytes2File( + name: name, + bytes: bytes, + allowedExtensions: const ['json'], + ); + } + } catch (e, s) { + Utils.reportError(e, s); + SmartDialog.showToast(e.toString()); + } + }, + child: Text(item.lanDoc!, style: const TextStyle(fontSize: 14)), + ), + ) + .toList(), ), ); } diff --git a/lib/pages/whisper/widgets/item.dart b/lib/pages/whisper/widgets/item.dart index cb0b1c265..ad7c0d7cb 100644 --- a/lib/pages/whisper/widgets/item.dart +++ b/lib/pages/whisper/widgets/item.dart @@ -56,47 +56,41 @@ class WhisperSessionItem extends StatelessWidget { : null, onLongPress: () => showDialog( context: context, - builder: (context) => AlertDialog( - clipBehavior: Clip.hardEdge, - contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: DefaultTextStyle( - style: const TextStyle(fontSize: 14), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - dense: true, - onTap: () { + builder: (context) => DefaultTextStyle( + style: const TextStyle(fontSize: 14), + child: SimpleDialog( + clipBehavior: Clip.hardEdge, + contentPadding: const EdgeInsets.symmetric(vertical: 12), + children: [ + SimpleDialogOption( + onPressed: () { + Get.back(); + onSetTop(item.isPinned, item.id); + }, + child: Text(item.isPinned ? '移除置顶' : '置顶'), + ), + if (item.id.privateId.hasTalkerUid()) + SimpleDialogOption( + onPressed: () { Get.back(); - onSetTop(item.isPinned, item.id); + onSetMute(item.isMuted, item.id.privateId.talkerUid); }, - title: Text(item.isPinned ? '移除置顶' : '置顶'), + child: Text('${item.isMuted ? '关闭' : '开启'}免打扰'), ), - if (item.id.privateId.hasTalkerUid()) - ListTile( - dense: true, - onTap: () { - Get.back(); - onSetMute(item.isMuted, item.id.privateId.talkerUid); - }, - title: Text('${item.isMuted ? '关闭' : '开启'}免打扰'), - ), - if (item.id.privateId.hasTalkerUid()) - ListTile( - dense: true, - onTap: () { - Get.back(); - showConfirmDialog( - context: context, - title: const Text('确定删除该对话?'), - onConfirm: () => - onRemove(item.id.privateId.talkerUid.toInt()), - ); - }, - title: const Text('删除'), - ), - ], - ), + if (item.id.privateId.hasTalkerUid()) + SimpleDialogOption( + onPressed: () { + Get.back(); + showConfirmDialog( + context: context, + title: const Text('确定删除该对话?'), + onConfirm: () => + onRemove(item.id.privateId.talkerUid.toInt()), + ); + }, + child: const Text('删除'), + ), + ], ), ), ), diff --git a/lib/pages/whisper_settings/view.dart b/lib/pages/whisper_settings/view.dart index 070a983f6..0592a14b3 100644 --- a/lib/pages/whisper_settings/view.dart +++ b/lib/pages/whisper_settings/view.dart @@ -82,49 +82,45 @@ class _WhisperSettingsPageState extends State { String? selected; showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: item.redirect.windowSelect.item.map( - (e) { - if (e.selected) { - selected ??= e.text; - } - return ListTile( - dense: true, - onTap: () async { - if (!e.selected) { - Get.back(); - for (final j in item.redirect.windowSelect.item) { - j.selected = false; - } - item.redirect.selectedSummary = e.text; - e.selected = true; - _controller.loadingState.refresh(); - final settings = {key: item}; - final res = await _controller.onSet(settings); - if (!res) { - for (final j in item.redirect.windowSelect.item) { - j.selected = j.text == selected; - } - item.redirect.selectedSummary = selected!; - _controller.loadingState.refresh(); - } + children: item.redirect.windowSelect.item.map( + (e) { + if (e.selected) { + selected ??= e.text; + } + return SimpleDialogOption( + onPressed: () async { + if (!e.selected) { + Get.back(); + for (final j in item.redirect.windowSelect.item) { + j.selected = false; } - }, - title: Text( - e.text, - style: TextStyle( - fontSize: 14, - color: e.selected ? theme.colorScheme.primary : null, - ), + item.redirect.selectedSummary = e.text; + e.selected = true; + _controller.loadingState.refresh(); + final settings = {key: item}; + final res = await _controller.onSet(settings); + if (!res) { + for (final j in item.redirect.windowSelect.item) { + j.selected = j.text == selected; + } + item.redirect.selectedSummary = selected!; + _controller.loadingState.refresh(); + } + } + }, + child: Text( + e.text, + style: TextStyle( + fontSize: 14, + color: e.selected ? theme.colorScheme.primary : null, ), - ); - }, - ).toList(), - ), + ), + ); + }, + ).toList(), ), ); } else if (item.redirect.otherPage.hasUrl()) { diff --git a/lib/utils/request_utils.dart b/lib/utils/request_utils.dart index 9deb098a4..82ca8b6c2 100644 --- a/lib/utils/request_utils.dart +++ b/lib/utils/request_utils.dart @@ -169,99 +169,84 @@ abstract final class RequestUtils { String text = isSpecialFollowed ? '移除特别关注' : '加入特别关注'; showDialog( context: context, - builder: (context) => AlertDialog( + builder: (context) => SimpleDialog( clipBehavior: Clip.hardEdge, contentPadding: const EdgeInsets.symmetric(vertical: 12), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - dense: true, - onTap: () async { - Get.back(); - final res = await MemberHttp.specialAction( - fid: mid, - isAdd: !isSpecialFollowed, - ); - if (res.isSuccess) { - SmartDialog.showToast('$text成功'); - afterMod?.call(isSpecialFollowed ? 2 : -10); - } else { - res.toast(); - } - }, - title: Text( - text, - style: const TextStyle(fontSize: 14), - ), - ), - ListTile( - dense: true, - onTap: () async { - Get.back(); - final result = await showModalBottomSheet>( - context: context, - useSafeArea: true, - isScrollControlled: true, - constraints: BoxConstraints( - maxWidth: min(640, context.mediaQueryShortestSide), - ), - builder: (BuildContext context) { - final maxChildSize = - PlatformUtils.isMobile && - !context.mediaQuerySize.isPortrait - ? 1.0 - : 0.7; - return DraggableScrollableSheet( - minChildSize: 0, - maxChildSize: 1, - snap: true, - expand: false, - snapSizes: [maxChildSize], - initialChildSize: maxChildSize, - builder: (context, scrollController) { - return GroupPanel( - mid: mid, - tags: followStatus!.tag, - scrollController: scrollController, - ); - }, - ); - }, - ); - if (result != null) { - followStatus!.tag = result.toList(); - afterMod?.call(result.contains(-10) ? -10 : 2); - } - }, - title: const Text( - '设置分组', - style: TextStyle(fontSize: 14), - ), - ), - ListTile( - dense: true, - onTap: () async { - Get.back(); - final res = await VideoHttp.relationMod( - mid: mid, - act: 2, - reSrc: 11, - ); - if (res.isSuccess) { - SmartDialog.showToast('取消关注成功'); - afterMod?.call(0); - } else { - res.toast(); - } - }, - title: const Text( - '取消关注', - style: TextStyle(fontSize: 14), - ), - ), - ], - ), + children: [ + SimpleDialogOption( + onPressed: () async { + Get.back(); + final res = await MemberHttp.specialAction( + fid: mid, + isAdd: !isSpecialFollowed, + ); + if (res.isSuccess) { + SmartDialog.showToast('$text成功'); + afterMod?.call(isSpecialFollowed ? 2 : -10); + } else { + res.toast(); + } + }, + child: Text(text, style: const TextStyle(fontSize: 14)), + ), + SimpleDialogOption( + onPressed: () async { + Get.back(); + final result = await showModalBottomSheet>( + context: context, + useSafeArea: true, + isScrollControlled: true, + constraints: BoxConstraints( + maxWidth: min(640, context.mediaQueryShortestSide), + ), + builder: (BuildContext context) { + final maxChildSize = + PlatformUtils.isMobile && + !context.mediaQuerySize.isPortrait + ? 1.0 + : 0.7; + return DraggableScrollableSheet( + minChildSize: 0, + maxChildSize: 1, + snap: true, + expand: false, + snapSizes: [maxChildSize], + initialChildSize: maxChildSize, + builder: (context, scrollController) { + return GroupPanel( + mid: mid, + tags: followStatus!.tag, + scrollController: scrollController, + ); + }, + ); + }, + ); + if (result != null) { + followStatus!.tag = result.toList(); + afterMod?.call(result.contains(-10) ? -10 : 2); + } + }, + child: const Text('设置分组', style: TextStyle(fontSize: 14)), + ), + SimpleDialogOption( + onPressed: () async { + Get.back(); + final res = await VideoHttp.relationMod( + mid: mid, + act: 2, + reSrc: 11, + ); + if (res.isSuccess) { + SmartDialog.showToast('取消关注成功'); + afterMod?.call(0); + } else { + res.toast(); + } + }, + child: const Text('取消关注', style: TextStyle(fontSize: 14)), + ), + ], ), ); }