calculator and login improvements

This commit is contained in:
2025-08-06 01:05:49 +01:00
parent ae88847543
commit 5c157c59b8
2 changed files with 26 additions and 2 deletions

View File

@@ -66,9 +66,26 @@ class _StationAutocompleteState extends State<StationAutocomplete> {
fieldViewBuilder: fieldViewBuilder:
(context, textEditingController, focusNode, onFieldSubmitted) { (context, textEditingController, focusNode, onFieldSubmitted) {
textEditingController.value = _controller.value; textEditingController.value = _controller.value;
return TextField( return TextField(
controller: textEditingController, controller: textEditingController,
focusNode: focusNode, focusNode: focusNode,
textInputAction: TextInputAction.done,
onSubmitted: (_) {
final query = textEditingController.text.toLowerCase();
final matches = widget.allStations
.map((s) => s.name)
.where((name) => name.toLowerCase().contains(query))
.toList();
if (matches.isNotEmpty) {
matches.sort((a, b) => a.length.compareTo(b.length));
final firstMatch = matches.first;
_controller.text = firstMatch;
widget.onChanged(firstMatch);
focusNode.unfocus(); // optionally close keyboard
}
},
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: 'Select station', labelText: 'Select station',
border: OutlineInputBorder(), border: OutlineInputBorder(),

View File

@@ -125,7 +125,7 @@ class _LoginPanelContentState extends State<LoginPanelContent> {
_loggingIn = true; _loggingIn = true;
}); });
try { try {
auth.login(username, password); await auth.login(username, password);
print('Login successful'); print('Login successful');
setState(() { setState(() {
_loggingIn = false; _loggingIn = false;
@@ -148,7 +148,14 @@ class _LoginPanelContentState extends State<LoginPanelContent> {
if (_loggingIn) { if (_loggingIn) {
loginButtonContent = Padding( loginButtonContent = Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: CircularProgressIndicator(), child: SizedBox(
height: 10,
width: 10,
child: CircularProgressIndicator(
color: Theme.of(context).textTheme.bodyLarge?.color,
strokeWidth: 2,
),
),
); );
} else { } else {
loginButtonContent = Text("Login"); loginButtonContent = Text("Login");