From cbe7daa8c443d8b7650a17cf7c7758a810b94c24 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Mon, 27 May 2024 21:44:20 +0800 Subject: [PATCH] fix & opt. --- lib/view/page/setting.dart | 88 +++++++++++++++++++++++++++++++++++--- pubspec.lock | 8 ++-- pubspec.yaml | 8 ++-- 3 files changed, 89 insertions(+), 15 deletions(-) diff --git a/lib/view/page/setting.dart b/lib/view/page/setting.dart index 361c444..a76cf95 100644 --- a/lib/view/page/setting.dart +++ b/lib/view/page/setting.dart @@ -435,18 +435,22 @@ class _SettingPageState extends State { actions: [ TextButton( onPressed: () { + void onSave(String s) { + context.pop(); + OpenAICfg.current = OpenAICfg.current.copyWith(model: s); + _cfgRN.build(); + } + context.pop(); + final ctrl = TextEditingController(); context.showRoundDialog( title: l10n.custom, child: Input( + controller: ctrl, hint: kChatModel, - onSubmitted: (s) { - context.pop(); - OpenAICfg.current = OpenAICfg.current.copyWith(model: s); - _cfgRN.build(); - }, + onSubmitted: (s) => onSave(s), ), - actions: Btns.oks(onTap: context.pop), + actions: Btns.oks(onTap: () => onSave(ctrl.text)), ); }, child: Text(l10n.custom), @@ -489,6 +493,30 @@ class _SettingPageState extends State { items: modelStrs, initial: val, title: l10n.model, + actions: [ + TextButton( + onPressed: () { + void onSave(String s) { + context.pop(); + OpenAICfg.current = OpenAICfg.current.copyWith(model: s); + _cfgRN.build(); + } + + context.pop(); + final ctrl = TextEditingController(); + context.showRoundDialog( + title: l10n.custom, + child: Input( + controller: ctrl, + hint: kChatModel, + onSubmitted: (s) => onSave(s), + ), + actions: Btns.oks(onTap: () => onSave(ctrl.text)), + ); + }, + child: Text(l10n.custom), + ), + ], ); if (model != null) { OpenAICfg.current = OpenAICfg.current.copyWith(model: model); @@ -526,6 +554,30 @@ class _SettingPageState extends State { items: modelStrs, initial: val, title: l10n.model, + actions: [ + TextButton( + onPressed: () { + void onSave(String s) { + context.pop(); + OpenAICfg.current = OpenAICfg.current.copyWith(model: s); + _cfgRN.build(); + } + + context.pop(); + final ctrl = TextEditingController(); + context.showRoundDialog( + title: l10n.custom, + child: Input( + controller: ctrl, + hint: kChatModel, + onSubmitted: (s) => onSave(s), + ), + actions: Btns.oks(onTap: () => onSave(ctrl.text)), + ); + }, + child: Text(l10n.custom), + ), + ], ); if (model != null) { OpenAICfg.current = OpenAICfg.current.copyWith(model: model); @@ -563,6 +615,30 @@ class _SettingPageState extends State { items: modelStrs, initial: val, title: l10n.model, + actions: [ + TextButton( + onPressed: () { + void onSave(String s) { + context.pop(); + OpenAICfg.current = OpenAICfg.current.copyWith(model: s); + _cfgRN.build(); + } + + context.pop(); + final ctrl = TextEditingController(); + context.showRoundDialog( + title: l10n.custom, + child: Input( + controller: ctrl, + hint: kChatModel, + onSubmitted: (s) => onSave(s), + ), + actions: Btns.oks(onTap: () => onSave(ctrl.text)), + ); + }, + child: Text(l10n.custom), + ), + ], ); if (model != null) { OpenAICfg.current = OpenAICfg.current.copyWith(model: model); diff --git a/pubspec.lock b/pubspec.lock index 83e64ba..ef77ab9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -405,11 +405,9 @@ packages: fl_lib: dependency: "direct main" description: - path: "." - ref: main - resolved-ref: "8877ee5b4597e03a9a316eb3d40ae5ffcf957709" - url: "https://github.com/lollipopkit/fl_lib" - source: git + path: "../fl_lib" + relative: true + source: path version: "0.0.1" flutter: dependency: "direct main" diff --git a/pubspec.yaml b/pubspec.yaml index 2289e7b..a1fee34 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,10 +24,10 @@ dependencies: image_picker: ^1.0.7 audioplayers: ^6.0.0 fl_lib: - git: - url: https://github.com/lollipopkit/fl_lib - ref: main - # path: ../fl_lib + # git: + # url: https://github.com/lollipopkit/fl_lib + # ref: main + path: ../fl_lib dev_dependencies: flutter_test: