feat: custom danmaku line height

Closes #56

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-12-26 22:01:48 +08:00
parent 81a23ea59d
commit 45a965135e
7 changed files with 111 additions and 3 deletions

View File

@@ -33,6 +33,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
late dynamic enableSystemProxy;
late String defaultSystemProxyHost;
late String defaultSystemProxyPort;
late double danmakuLineHeight = GStorage.danmakuLineHeight;
bool userLogin = false;
Box get setting => GStorage.setting;
@@ -336,6 +337,64 @@ class _ExtraSettingState extends State<ExtraSetting> {
);
},
),
ListTile(
title: Text('弹幕行高', style: titleStyle),
subtitle: Text('默认1.6', style: subTitleStyle),
leading: const Icon(Icons.subtitles_outlined),
trailing: Text(
danmakuLineHeight.toString(),
style: Theme.of(context).textTheme.titleSmall,
),
onTap: () {
String danmakuLineHeight = this.danmakuLineHeight.toString();
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('弹幕行高', style: TextStyle(fontSize: 18)),
content: TextFormField(
autofocus: true,
initialValue: danmakuLineHeight,
keyboardType:
TextInputType.numberWithOptions(decimal: true),
onChanged: (value) {
danmakuLineHeight = value;
},
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[\d\.]+')),
],
),
actions: [
TextButton(
onPressed: Get.back,
child: Text(
'取消',
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
),
),
),
TextButton(
onPressed: () async {
Get.back();
this.danmakuLineHeight = max(
1.0,
double.tryParse(danmakuLineHeight) ?? 1.6,
);
await setting.put(
SettingBoxKey.danmakuLineHeight,
this.danmakuLineHeight,
);
setState(() {});
},
child: Text('确定'),
)
],
);
},
);
},
),
Obx(
() => ListTile(
enableFeedback: true,