Files
flutter/lib/widgets/auth/server_field.dart
Roland Geider ece38a39d2 Refactor login screen
The api token toggle is now only visible when showing a custom server, since at
the moment this is the only time when such an auth method makes sense (plus it
keeps the rest of the UI cleaner). The different fields in the screen have been
moved to individual files, to make the structure clearer.
2025-04-30 22:50:55 +02:00

38 lines
1003 B
Dart

import 'package:flutter/material.dart';
import 'package:wger/l10n/generated/app_localizations.dart';
class ServerField extends StatelessWidget {
final TextEditingController controller;
final Function(String?) onSaved;
const ServerField({
required this.controller,
required this.onSaved,
super.key,
});
@override
Widget build(BuildContext context) {
return TextFormField(
key: const Key('inputServer'),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).customServerUrl,
helperText: AppLocalizations.of(context).customServerHint,
helperMaxLines: 4,
),
controller: controller,
validator: (value) {
if (Uri.tryParse(value!) == null) {
return AppLocalizations.of(context).invalidUrl;
}
if (value.isEmpty || !value.contains('http')) {
return AppLocalizations.of(context).invalidUrl;
}
return null;
},
onSaved: onSaved,
);
}
}