mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-06 11:04:53 +08:00
@@ -35,7 +35,7 @@ class NormalModel extends SettingsModel {
|
||||
final String? title;
|
||||
final ValueGetter<String>? getTitle;
|
||||
final ValueGetter<String>? getSubtitle;
|
||||
final Widget Function()? getTrailing;
|
||||
final Widget Function(ThemeData theme)? getTrailing;
|
||||
final void Function(BuildContext context, VoidCallback setState)? onTap;
|
||||
|
||||
const NormalModel({
|
||||
@@ -125,49 +125,47 @@ SettingsModel getBanWordModel({
|
||||
String editValue = banWord;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
constraints: StyleString.dialogFixedConstraints,
|
||||
title: Text(title),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('使用|隔开,如:尝试|测试'),
|
||||
TextFormField(
|
||||
autofocus: true,
|
||||
initialValue: editValue,
|
||||
textInputAction: TextInputAction.newline,
|
||||
minLines: 1,
|
||||
maxLines: 4,
|
||||
onChanged: (value) => editValue = value,
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('保存'),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
banWord = editValue;
|
||||
setState();
|
||||
onChanged(RegExp(banWord, caseSensitive: false));
|
||||
SmartDialog.showToast('已保存');
|
||||
GStorage.setting.put(key, banWord);
|
||||
},
|
||||
builder: (context) => AlertDialog(
|
||||
constraints: StyleString.dialogFixedConstraints,
|
||||
title: Text(title),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('使用|隔开,如:尝试|测试'),
|
||||
TextFormField(
|
||||
autofocus: true,
|
||||
initialValue: editValue,
|
||||
textInputAction: TextInputAction.newline,
|
||||
minLines: 1,
|
||||
maxLines: 4,
|
||||
onChanged: (value) => editValue = value,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('保存'),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
banWord = editValue;
|
||||
setState();
|
||||
onChanged(RegExp(banWord, caseSensitive: false));
|
||||
SmartDialog.showToast('已保存');
|
||||
GStorage.setting.put(key, banWord);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -197,57 +195,53 @@ SettingsModel getVideoFilterSelectModel({
|
||||
onTap: (context, setState) async {
|
||||
var result = await showDialog<int>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SelectDialog<int>(
|
||||
title: '选择$title${isFilter ? '(0即不过滤)' : ''}',
|
||||
value: value,
|
||||
values:
|
||||
(values
|
||||
..addIf(!values.contains(value), value)
|
||||
..sort())
|
||||
.map(
|
||||
(e) => (e, suffix == null ? e.toString() : '$e $suffix'),
|
||||
)
|
||||
.toList()
|
||||
..add((-1, '自定义')),
|
||||
);
|
||||
},
|
||||
builder: (context) => SelectDialog<int>(
|
||||
title: '选择$title${isFilter ? '(0即不过滤)' : ''}',
|
||||
value: value,
|
||||
values:
|
||||
(values
|
||||
..addIf(!values.contains(value), value)
|
||||
..sort())
|
||||
.map(
|
||||
(e) => (e, suffix == null ? e.toString() : '$e $suffix'),
|
||||
)
|
||||
.toList()
|
||||
..add((-1, '自定义')),
|
||||
),
|
||||
);
|
||||
if (result != null) {
|
||||
if (result == -1 && context.mounted) {
|
||||
String valueStr = '';
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
String valueStr = '';
|
||||
return AlertDialog(
|
||||
title: Text('自定义$title'),
|
||||
content: TextField(
|
||||
autofocus: true,
|
||||
onChanged: (value) => valueStr = value,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||
decoration: InputDecoration(suffixText: suffix),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('自定义$title'),
|
||||
content: TextField(
|
||||
autofocus: true,
|
||||
onChanged: (value) => valueStr = value,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||
decoration: InputDecoration(suffixText: suffix),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
result = int.tryParse(valueStr) ?? 0;
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
result = int.tryParse(valueStr) ?? 0;
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
if (result != -1) {
|
||||
@@ -275,9 +269,9 @@ SettingsModel getPopupMenuModel({
|
||||
subtitle: subtitle,
|
||||
leading: leading,
|
||||
// onTap: (context, setState) => globalKey.currentState?.showButtonMenu(),
|
||||
getTrailing: () => Builder(
|
||||
getTrailing: (theme) => Builder(
|
||||
builder: (context) {
|
||||
final color = ColorScheme.of(context).secondary;
|
||||
final color = theme.colorScheme.secondary;
|
||||
final v = values[GStorage.setting.get(key, defaultValue: defaultIndex)];
|
||||
return PopupMenuButton(
|
||||
// key: globalKey,
|
||||
|
||||
Reference in New Issue
Block a user