mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
fix UI api
This commit is contained in:
@@ -714,6 +714,8 @@ mixin class _JsUiApi {
|
||||
var content = message['content'];
|
||||
var actions = <String, JSAutoFreeFunction>{};
|
||||
for (var action in message['actions']) {
|
||||
// [message] will be released after the method call, causing the action to be invalid, so we need to duplicate it
|
||||
(action['callback'] as JSInvokable).dup();
|
||||
actions[action['text']] = JSAutoFreeFunction(action['callback']);
|
||||
}
|
||||
showDialog(context: App.rootContext, builder: (context) {
|
||||
@@ -724,6 +726,7 @@ mixin class _JsUiApi {
|
||||
return TextButton(
|
||||
onPressed: () {
|
||||
entry.value.call([]);
|
||||
context.pop();
|
||||
},
|
||||
child: Text(entry.key),
|
||||
);
|
||||
|
@@ -246,7 +246,7 @@ class _BodyState extends State<_Body> {
|
||||
),
|
||||
);
|
||||
} else if (type == "callback") {
|
||||
yield _CallbackSetting(setting: item);
|
||||
yield _CallbackSetting(setting: item, sourceKey: source.key);
|
||||
}
|
||||
} catch (e, s) {
|
||||
Log.error("ComicSourcePage", "Failed to build a setting\n$e\n$s");
|
||||
@@ -682,10 +682,12 @@ class _CheckUpdatesButtonState extends State<_CheckUpdatesButton> {
|
||||
}
|
||||
|
||||
class _CallbackSetting extends StatefulWidget {
|
||||
const _CallbackSetting({required this.setting});
|
||||
const _CallbackSetting({required this.setting, required this.sourceKey});
|
||||
|
||||
final MapEntry<String, Map<String, dynamic>> setting;
|
||||
|
||||
final String sourceKey;
|
||||
|
||||
@override
|
||||
State<_CallbackSetting> createState() => _CallbackSettingState();
|
||||
}
|
||||
@@ -719,11 +721,11 @@ class _CallbackSettingState extends State<_CallbackSetting> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
title: Text(title.ts(key)),
|
||||
title: Text(title.ts(widget.sourceKey)),
|
||||
trailing: Button.normal(
|
||||
onPressed: onClick,
|
||||
isLoading: isLoading,
|
||||
child: Text(buttonText.ts(key)),
|
||||
child: Text(buttonText.ts(widget.sourceKey)),
|
||||
).fixHeight(32),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user