feat: custom reply length limit

Closes #55

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-12-26 20:46:00 +08:00
parent 79da08b285
commit 81a23ea59d
5 changed files with 82 additions and 16 deletions

View File

@@ -179,8 +179,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
content: TextFormField(
autofocus: true,
initialValue: dynamicPeriod.toString(),
keyboardType:
TextInputType.numberWithOptions(decimal: true),
keyboardType: TextInputType.numberWithOptions(),
onChanged: (value) {
dynamicPeriod = int.tryParse(value) ?? 5;
},
@@ -280,6 +279,63 @@ class _ExtraSettingState extends State<ExtraSetting> {
setKey: SettingBoxKey.horizontalMemberPage,
defaultVal: false,
),
ListTile(
title: Text('评论折叠行数', style: titleStyle),
subtitle: Text('0行为不折叠', style: subTitleStyle),
leading: const Icon(Icons.compress),
trailing: Text(
'${GlobalData().replyLengthLimit.toString()}',
style: Theme.of(context).textTheme.titleSmall,
),
onTap: () {
String replyLengthLimit =
GlobalData().replyLengthLimit.toString();
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('评论折叠行数', style: TextStyle(fontSize: 18)),
content: TextFormField(
autofocus: true,
initialValue: replyLengthLimit,
keyboardType: TextInputType.numberWithOptions(),
onChanged: (value) {
replyLengthLimit = value;
},
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'\d+')),
],
decoration: InputDecoration(suffixText: ''),
),
actions: [
TextButton(
onPressed: Get.back,
child: Text(
'取消',
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
),
),
),
TextButton(
onPressed: () async {
Get.back();
GlobalData().replyLengthLimit =
int.tryParse(replyLengthLimit) ?? 6;
await setting.put(
SettingBoxKey.replyLengthLimit,
GlobalData().replyLengthLimit,
);
setState(() {});
},
child: Text('确定'),
)
],
);
},
);
},
),
Obx(
() => ListTile(
enableFeedback: true,