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