Added ability to dismiss settings setHost dialog
This commit is contained in:
parent
399f0d9cce
commit
a1a59f225f
|
@ -60,6 +60,11 @@
|
||||||
"description": "Text displayed for save host button, should be capitalized",
|
"description": "Text displayed for save host button, should be capitalized",
|
||||||
"context": "Visible in the host dialog"
|
"context": "Visible in the host dialog"
|
||||||
},
|
},
|
||||||
|
"hostDialogCancel": "Cancel",
|
||||||
|
"@hostDialogCancel": {
|
||||||
|
"description": "Text displayed for cancel button, should be capitalized",
|
||||||
|
"context": "Visible in the host dialog"
|
||||||
|
},
|
||||||
"noSelectedModel": "<selector>",
|
"noSelectedModel": "<selector>",
|
||||||
"@noSelectedModel": {
|
"@noSelectedModel": {
|
||||||
"description": "Text displayed when no model is selected",
|
"description": "Text displayed when no model is selected",
|
||||||
|
|
|
@ -503,7 +503,7 @@ class _MainAppState extends State<MainApp> {
|
||||||
HapticFeedback.selectionClick();
|
HapticFeedback.selectionClick();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
if (!chatAllowed) return;
|
if (!chatAllowed) return;
|
||||||
setHost(context);
|
setHost(context, false);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,7 +8,7 @@ import 'package:http/http.dart' as http;
|
||||||
import 'package:dartx/dartx.dart';
|
import 'package:dartx/dartx.dart';
|
||||||
import 'package:ollama_dart/ollama_dart.dart' as llama;
|
import 'package:ollama_dart/ollama_dart.dart' as llama;
|
||||||
|
|
||||||
void setHost(BuildContext context) {
|
void setHost(BuildContext context, [bool force = true]) {
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
bool invalidHost = false;
|
bool invalidHost = false;
|
||||||
bool invalidUrl = false;
|
bool invalidUrl = false;
|
||||||
|
@ -16,10 +16,10 @@ void setHost(BuildContext context) {
|
||||||
TextEditingController(text: prefs?.getString("host") ?? "");
|
TextEditingController(text: prefs?.getString("host") ?? "");
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: !force,
|
||||||
builder: (context) => StatefulBuilder(
|
builder: (context) => StatefulBuilder(
|
||||||
builder: (context, setState) => PopScope(
|
builder: (context, setState) => PopScope(
|
||||||
canPop: false,
|
canPop: !force,
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
title: Text(AppLocalizations.of(context)!.hostDialogTitle),
|
title: Text(AppLocalizations.of(context)!.hostDialogTitle),
|
||||||
content: loading
|
content: loading
|
||||||
|
@ -108,7 +108,15 @@ void setHost(BuildContext context) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child:
|
child:
|
||||||
Text(AppLocalizations.of(context)!.hostDialogSave))
|
Text(AppLocalizations.of(context)!.hostDialogSave)),
|
||||||
|
!force
|
||||||
|
? TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context)!.hostDialogCancel))
|
||||||
|
: const SizedBox.shrink()
|
||||||
]))));
|
]))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue