mod: 无痕模式提示条替换为SmartDialog实现

This commit is contained in:
orz12
2024-04-22 20:12:38 +08:00
parent 42af6ec3f7
commit a3d623539a

View File

@@ -94,9 +94,19 @@ class MineController extends GetxController {
static onChangeAnonymity(BuildContext context) { static onChangeAnonymity(BuildContext context) {
anonymity = !anonymity; anonymity = !anonymity;
if (anonymity) { if (anonymity) {
ScaffoldMessenger.of(context).showSnackBar( SmartDialog.show(
SnackBar( clickMaskDismiss: false,
content: Column(children: <Widget>[ 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: <Widget>[
const Row( const Row(
children: <Widget>[ children: <Widget>[
Icon( Icon(
@@ -104,7 +114,8 @@ class MineController extends GetxController {
color: Colors.green, color: Colors.green,
), ),
SizedBox(width: 10), SizedBox(width: 10),
Text('已进入无痕模式', style: TextStyle(fontSize: 15, height: 1.5)) Text('已进入无痕模式',
style: TextStyle(fontSize: 15, height: 1.5))
], ],
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
@@ -114,51 +125,68 @@ class MineController extends GetxController {
'点赞等其它操作不受影响\n' '点赞等其它操作不受影响\n'
'(前往隐私设置了解详情)', '(前往隐私设置了解详情)',
style: TextStyle(fontSize: 12.5, height: 1.5)), style: TextStyle(fontSize: 12.5, height: 1.5)),
Row(children: [ Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
TextButton( TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith((states) {
return Theme.of(context).snackBarTheme.actionTextColor;
}),
),
onPressed: () { onPressed: () {
GStrorage.setting.put(SettingBoxKey.anonymity, true); SmartDialog.dismiss();
GStrorage.setting
.put(SettingBoxKey.anonymity, true);
anonymity = true; anonymity = true;
SmartDialog.showToast('已设为永久无痕模式'); SmartDialog.showToast('已设为永久无痕模式');
}, },
child: const Text('保存为永久')), child: Text(
'保存为永久',
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
),
)),
const SizedBox(width: 10), const SizedBox(width: 10),
TextButton( TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith((states) {
return Theme.of(context).snackBarTheme.actionTextColor;
}),
),
onPressed: () { onPressed: () {
GStrorage.setting.put(SettingBoxKey.anonymity, false); SmartDialog.dismiss();
GStrorage.setting
.put(SettingBoxKey.anonymity, false);
anonymity = true; anonymity = true;
SmartDialog.showToast('已设为临时无痕模式'); SmartDialog.showToast('已设为临时无痕模式');
}, },
child: const Text('仅本次(默认)')) child: Text(
]) '仅本次(默认)',
]), style: TextStyle(
duration: const Duration(seconds: 2), color: Theme.of(context).colorScheme.primary,
showCloseIcon: true,
), ),
)),
]),
])),
// duration: const Duration(seconds: 2),
// showCloseIcon: true,
); );
});
} else { } else {
GStrorage.setting.put(SettingBoxKey.anonymity, false); GStrorage.setting.put(SettingBoxKey.anonymity, false);
ScaffoldMessenger.of(context).showSnackBar( SmartDialog.show(
const SnackBar( clickMaskDismiss: false,
content: Text('已退出无痕模式'), usePenetrate: true,
duration: Duration(seconds: 1), displayTime: const Duration(seconds: 1),
// action: SnackBarAction( alignment: Alignment.bottomCenter,
// label: '确认', builder: (context) {
// onPressed: () {}, return ColoredBox(
// ), color: Theme.of(context).colorScheme.secondaryContainer,
showCloseIcon: true, 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('已退出无痕模式'),
],
)));
});
} }
} }