opt: simple dialog

This commit is contained in:
My-Responsitories
2026-06-13 11:58:33 +08:00
parent c63fe3866c
commit 3085d58508
26 changed files with 1184 additions and 1433 deletions

View File

@@ -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);
},
),
],
),
);
}

View File

@@ -534,76 +534,67 @@ class _GalleryViewerState extends State<GalleryViewer>
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),
),
),
],
),
),
],
),
);
}

View File

@@ -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,
),
),
),