mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
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.
38 lines
1003 B
Dart
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,
|
|
);
|
|
}
|
|
}
|