From a3d623539a18a50c12a63d84beaba87871c48fa1 Mon Sep 17 00:00:00 2001 From: orz12 Date: Mon, 22 Apr 2024 20:12:38 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E6=97=A0=E7=97=95=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=9D=A1=E6=9B=BF=E6=8D=A2=E4=B8=BASmartDial?= =?UTF-8?q?og=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/mine/controller.dart | 154 +++++++++++++++++++-------------- 1 file changed, 91 insertions(+), 63 deletions(-) diff --git a/lib/pages/mine/controller.dart b/lib/pages/mine/controller.dart index 57bea061..f61397a4 100644 --- a/lib/pages/mine/controller.dart +++ b/lib/pages/mine/controller.dart @@ -94,71 +94,99 @@ class MineController extends GetxController { static onChangeAnonymity(BuildContext context) { anonymity = !anonymity; if (anonymity) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Column(children: [ - const Row( - children: [ - Icon( - Icons.check, - color: Colors.green, - ), - SizedBox(width: 10), - Text('已进入无痕模式', style: TextStyle(fontSize: 15, height: 1.5)) - ], - ), - const SizedBox(height: 10), - const Text( - '搜索、观看视频/直播不携带Cookie与CSRF\n' - '不产生查询或播放记录\n' - '点赞等其它操作不受影响\n' - '(前往隐私设置了解详情)', - style: TextStyle(fontSize: 12.5, height: 1.5)), - Row(children: [ - TextButton( - style: ButtonStyle( - foregroundColor: MaterialStateProperty.resolveWith((states) { - return Theme.of(context).snackBarTheme.actionTextColor; - }), - ), - onPressed: () { - GStrorage.setting.put(SettingBoxKey.anonymity, true); - anonymity = true; - SmartDialog.showToast('已设为永久无痕模式'); - }, - child: const Text('保存为永久')), - const SizedBox(width: 10), - TextButton( - style: ButtonStyle( - foregroundColor: MaterialStateProperty.resolveWith((states) { - return Theme.of(context).snackBarTheme.actionTextColor; - }), - ), - onPressed: () { - GStrorage.setting.put(SettingBoxKey.anonymity, false); - anonymity = true; - SmartDialog.showToast('已设为临时无痕模式'); - }, - child: const Text('仅本次(默认)')) - ]) - ]), - duration: const Duration(seconds: 2), - showCloseIcon: true, - ), - ); + SmartDialog.show( + clickMaskDismiss: false, + usePenetrate: true, + displayTime: const Duration(seconds: 2), + alignment: Alignment.bottomCenter, + builder: (context) { + return ColoredBox( + color: Theme.of(context).colorScheme.secondaryContainer, + child: Padding( + padding: + const EdgeInsets.symmetric(vertical: 15, horizontal: 20), + child: + Column(mainAxisSize: MainAxisSize.min, children: [ + const Row( + children: [ + Icon( + Icons.check, + color: Colors.green, + ), + SizedBox(width: 10), + Text('已进入无痕模式', + style: TextStyle(fontSize: 15, height: 1.5)) + ], + ), + const SizedBox(height: 10), + const Text( + '搜索、观看视频/直播不携带Cookie与CSRF\n' + '不产生查询或播放记录\n' + '点赞等其它操作不受影响\n' + '(前往隐私设置了解详情)', + style: TextStyle(fontSize: 12.5, height: 1.5)), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + TextButton( + onPressed: () { + SmartDialog.dismiss(); + GStrorage.setting + .put(SettingBoxKey.anonymity, true); + anonymity = true; + SmartDialog.showToast('已设为永久无痕模式'); + }, + child: Text( + '保存为永久', + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + ), + )), + const SizedBox(width: 10), + TextButton( + onPressed: () { + SmartDialog.dismiss(); + GStrorage.setting + .put(SettingBoxKey.anonymity, false); + anonymity = true; + SmartDialog.showToast('已设为临时无痕模式'); + }, + child: Text( + '仅本次(默认)', + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + ), + )), + ]), + ])), + // duration: const Duration(seconds: 2), + // showCloseIcon: true, + ); + }); } else { GStrorage.setting.put(SettingBoxKey.anonymity, false); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('已退出无痕模式'), - duration: Duration(seconds: 1), - // action: SnackBarAction( - // label: '确认', - // onPressed: () {}, - // ), - showCloseIcon: true, - ), - ); + SmartDialog.show( + clickMaskDismiss: false, + usePenetrate: true, + displayTime: const Duration(seconds: 1), + alignment: Alignment.bottomCenter, + builder: (context) { + return ColoredBox( + color: Theme.of(context).colorScheme.secondaryContainer, + child: const Padding( + padding: EdgeInsets.symmetric(vertical: 15, horizontal: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon( + Icons.check, + color: Colors.green, + ), + SizedBox(width: 10), + Text('已退出无痕模式'), + ], + ))); + }); } }