mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-09 02:07:58 -06:00
fix: Move server address validation logic to form field.
This commit is contained in:
@@ -42,15 +42,6 @@ class _ServerAddressFormFieldState extends State<ServerAddressFormField> {
|
|||||||
initialValue: widget.initialValue,
|
initialValue: widget.initialValue,
|
||||||
name: ServerAddressFormField.fkServerAddress,
|
name: ServerAddressFormField.fkServerAddress,
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
validator: (value) {
|
|
||||||
if (value?.trim().isEmpty ?? true) {
|
|
||||||
return S.of(context)!.serverAddressMustNotBeEmpty;
|
|
||||||
}
|
|
||||||
if (!RegExp(r"https?://.*").hasMatch(value!)) {
|
|
||||||
return S.of(context)!.serverAddressMustIncludeAScheme;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
builder: (field) {
|
builder: (field) {
|
||||||
return RawAutocomplete<String>(
|
return RawAutocomplete<String>(
|
||||||
focusNode: _focusNode,
|
focusNode: _focusNode,
|
||||||
@@ -74,7 +65,7 @@ class _ServerAddressFormFieldState extends State<ServerAddressFormField> {
|
|||||||
},
|
},
|
||||||
fieldViewBuilder:
|
fieldViewBuilder:
|
||||||
(context, textEditingController, focusNode, onFieldSubmitted) {
|
(context, textEditingController, focusNode, onFieldSubmitted) {
|
||||||
return TextField(
|
return TextFormField(
|
||||||
controller: textEditingController,
|
controller: textEditingController,
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@@ -93,10 +84,20 @@ class _ServerAddressFormFieldState extends State<ServerAddressFormField> {
|
|||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
onSubmitted: (_) {
|
onFieldSubmitted: (_) {
|
||||||
onFieldSubmitted();
|
onFieldSubmitted();
|
||||||
_formatInput();
|
_formatInput();
|
||||||
},
|
},
|
||||||
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
|
validator: (value) {
|
||||||
|
if (value?.trim().isEmpty ?? true) {
|
||||||
|
return S.of(context)!.serverAddressMustNotBeEmpty;
|
||||||
|
}
|
||||||
|
if (!RegExp(r"^https?://.*").hasMatch(value!)) {
|
||||||
|
return S.of(context)!.serverAddressMustIncludeAScheme;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
keyboardType: TextInputType.url,
|
keyboardType: TextInputType.url,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
field.didChange(value);
|
field.didChange(value);
|
||||||
|
|||||||
Reference in New Issue
Block a user