Smaller fixes
This commit is contained in:
parent
68d2bc343f
commit
e8820162b0
|
@ -1,4 +1,5 @@
|
|||
arb-dir: lib/l10n
|
||||
template-arb-file: app_en.arb
|
||||
preferred-supported-locales: en
|
||||
output-localization-file: app_localizations.dart
|
||||
untranslated-messages-file: untranslated_messages.json
|
||||
|
|
|
@ -1261,79 +1261,44 @@ class _MainAppState extends State<MainApp> {
|
|||
],
|
||||
),
|
||||
imageBuilder: (uri, title, alt) {
|
||||
Widget errorImage = InkWell(
|
||||
onTap: () {
|
||||
selectionHaptic();
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(
|
||||
context)!
|
||||
.notAValidImage),
|
||||
showCloseIcon: true));
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius
|
||||
.circular(8),
|
||||
color: Theme.of(context)
|
||||
.brightness ==
|
||||
Brightness.light
|
||||
? Colors.white
|
||||
: Colors.black),
|
||||
padding:
|
||||
const EdgeInsets.only(
|
||||
left: 100,
|
||||
right: 100,
|
||||
top: 32),
|
||||
child: const Image(
|
||||
image: AssetImage(
|
||||
"assets/logo512error.png"))));
|
||||
if (uri.isAbsolute) {
|
||||
return Image.network(
|
||||
uri.toString(), errorBuilder:
|
||||
(context, error,
|
||||
stackTrace) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
selectionHaptic();
|
||||
ScaffoldMessenger.of(
|
||||
context)
|
||||
.showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(
|
||||
context)!
|
||||
.notAValidImage),
|
||||
showCloseIcon:
|
||||
true));
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius
|
||||
.circular(
|
||||
8),
|
||||
color: Theme.of(context)
|
||||
.brightness ==
|
||||
Brightness
|
||||
.light
|
||||
? Colors.white
|
||||
: Colors.black),
|
||||
padding:
|
||||
const EdgeInsets
|
||||
.only(
|
||||
left: 100,
|
||||
right: 100,
|
||||
top: 32),
|
||||
child: const Image(
|
||||
image: AssetImage(
|
||||
"assets/logo512error.png"))));
|
||||
return errorImage;
|
||||
});
|
||||
} else {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
selectionHaptic();
|
||||
ScaffoldMessenger.of(
|
||||
context)
|
||||
.showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(
|
||||
context)!
|
||||
.notAValidImage),
|
||||
showCloseIcon:
|
||||
true));
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius
|
||||
.circular(8),
|
||||
color: Theme.of(context)
|
||||
.brightness ==
|
||||
Brightness
|
||||
.light
|
||||
? Colors.white
|
||||
: Colors.black),
|
||||
padding:
|
||||
const EdgeInsets.only(
|
||||
left: 100,
|
||||
right: 100,
|
||||
top: 32),
|
||||
child: const Image(
|
||||
image: AssetImage(
|
||||
"assets/logo512error.png"))));
|
||||
return errorImage;
|
||||
}
|
||||
},
|
||||
styleSheet: (p0.author == user)
|
||||
|
|
|
@ -95,14 +95,10 @@ class _ScreenSettingsVoiceState extends State<ScreenSettingsVoice> {
|
|||
: !(permissionBluetooth && permissionRecord)
|
||||
? AppLocalizations.of(context)!
|
||||
.settingsVoicePermissionNot
|
||||
: !(prefs!.getBool(
|
||||
"voiceModeEnabled") ??
|
||||
false)
|
||||
? AppLocalizations.of(context)!
|
||||
.settingsVoiceNotEnabled
|
||||
: AppLocalizations.of(context)!
|
||||
.settingsVoiceNotSupported,
|
||||
: AppLocalizations.of(context)!
|
||||
.settingsVoiceNotSupported,
|
||||
Icons.info_rounded, () {
|
||||
selectionHaptic();
|
||||
if (permissionLoading) return;
|
||||
if (!(permissionBluetooth && permissionRecord)) {
|
||||
void load() async {
|
||||
|
@ -139,7 +135,6 @@ class _ScreenSettingsVoiceState extends State<ScreenSettingsVoice> {
|
|||
} else if (!voiceLanguageOptions.contains(
|
||||
(prefs!.getString("voiceLanguage") ??
|
||||
"en_US"))) {
|
||||
selectionHaptic();
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(AppLocalizations.of(context)!
|
||||
.settingsVoiceTtsNotSupportedDescription),
|
||||
|
|
|
@ -79,6 +79,9 @@ Future<String> getTitleAi(List history) async {
|
|||
.replaceAll("_", "")
|
||||
.replaceAll("\n", " ")
|
||||
.trim();
|
||||
while (title.contains(" ")) {
|
||||
title = title.replaceAll(" ", " ");
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
|
@ -169,58 +172,58 @@ Future<String> send(String value, BuildContext context, Function setState,
|
|||
baseUrl: "$host/api");
|
||||
|
||||
try {
|
||||
if ((prefs!.getString("requestType") ?? "stream") == "stream") {
|
||||
final stream = client
|
||||
.generateChatCompletionStream(
|
||||
request: llama.GenerateChatCompletionRequest(
|
||||
model: model!,
|
||||
messages: history,
|
||||
keepAlive: int.parse(prefs!.getString("keepAlive") ?? "300")),
|
||||
)
|
||||
.timeout(const Duration(seconds: 30));
|
||||
if ((prefs!.getString("requestType") ?? "stream") == "stream") {
|
||||
final stream = client
|
||||
.generateChatCompletionStream(
|
||||
request: llama.GenerateChatCompletionRequest(
|
||||
model: model!,
|
||||
messages: history,
|
||||
keepAlive: int.parse(prefs!.getString("keepAlive") ?? "300")),
|
||||
)
|
||||
.timeout(const Duration(seconds: 30));
|
||||
|
||||
await for (final res in stream) {
|
||||
text += (res.message?.content ?? "");
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
if (messages[i].id == newId) {
|
||||
messages.removeAt(i);
|
||||
break;
|
||||
await for (final res in stream) {
|
||||
text += (res.message?.content ?? "");
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
if (messages[i].id == newId) {
|
||||
messages.removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (chatAllowed) return "";
|
||||
// if (text.trim() == "") {
|
||||
// throw Exception();
|
||||
// }
|
||||
messages.insert(
|
||||
0, types.TextMessage(author: assistant, id: newId, text: text));
|
||||
if (onStream != null) {
|
||||
onStream(text, false);
|
||||
}
|
||||
setState(() {});
|
||||
heavyHaptic();
|
||||
}
|
||||
} else {
|
||||
llama.GenerateChatCompletionResponse request;
|
||||
request = await client
|
||||
.generateChatCompletion(
|
||||
request: llama.GenerateChatCompletionRequest(
|
||||
model: model!,
|
||||
messages: history,
|
||||
keepAlive: int.parse(prefs!.getString("keepAlive") ?? "300")),
|
||||
)
|
||||
.timeout(const Duration(seconds: 30));
|
||||
if (chatAllowed) return "";
|
||||
// if (text.trim() == "") {
|
||||
// if (request.message!.content.trim() == "") {
|
||||
// throw Exception();
|
||||
// }
|
||||
messages.insert(
|
||||
0, types.TextMessage(author: assistant, id: newId, text: text));
|
||||
if (onStream != null) {
|
||||
onStream(text, false);
|
||||
}
|
||||
0,
|
||||
types.TextMessage(
|
||||
author: assistant, id: newId, text: request.message!.content));
|
||||
text = request.message!.content;
|
||||
setState(() {});
|
||||
heavyHaptic();
|
||||
}
|
||||
} else {
|
||||
llama.GenerateChatCompletionResponse request;
|
||||
request = await client
|
||||
.generateChatCompletion(
|
||||
request: llama.GenerateChatCompletionRequest(
|
||||
model: model!,
|
||||
messages: history,
|
||||
keepAlive: int.parse(prefs!.getString("keepAlive") ?? "300")),
|
||||
)
|
||||
.timeout(const Duration(seconds: 30));
|
||||
if (chatAllowed) return "";
|
||||
// if (request.message!.content.trim() == "") {
|
||||
// throw Exception();
|
||||
// }
|
||||
messages.insert(
|
||||
0,
|
||||
types.TextMessage(
|
||||
author: assistant, id: newId, text: request.message!.content));
|
||||
text = request.message!.content;
|
||||
setState(() {});
|
||||
heavyHaptic();
|
||||
}
|
||||
} catch (e) {
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
if (messages[i].id == newId) {
|
||||
|
|
|
@ -42,6 +42,7 @@ dependencies:
|
|||
dynamic_color: ^1.7.0
|
||||
volume_controller: ^2.0.7
|
||||
universal_html: ^2.2.4
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
|
Loading…
Reference in New Issue