Added path field

This commit is contained in:
Juan Gilsanz Polo
2024-02-26 15:47:41 +01:00
parent a82dbea166
commit fa0441a0e4
8 changed files with 53 additions and 8 deletions

View File

@@ -53,8 +53,8 @@ class Connect extends _$Connect {
ref.notifyListeners();
}
void validatePort(value) {
if (value != null && value != '') {
void validatePort(String value) {
if (value != '') {
if (int.tryParse(value) != null && int.parse(value) <= 65535) {
state.portError = null;
} else {
@@ -65,6 +65,20 @@ class Connect extends _$Connect {
ref.notifyListeners();
}
void validatePath(String value) {
if (value == "") {
state.pathError = null;
} else {
if (Regexps.path.hasMatch(value) == true) {
state.pathError = null;
} else {
state.pathError = t.onboarding.invalidPath;
}
}
state.validValues = validValues();
ref.notifyListeners();
}
void validateToken(String value) {
if (value != "") {
state.tokenError = null;
@@ -79,7 +93,9 @@ class Connect extends _$Connect {
return state.tokenController.text != "" &&
state.tokenError == null &&
state.ipDomainController.text != "" &&
state.ipDomainError == null;
state.ipDomainError == null &&
state.pathError == null &&
state.portError == null;
}
}

View File

@@ -21,7 +21,7 @@ final connectToServerProvider = AutoDisposeFutureProvider<bool>.internal(
);
typedef ConnectToServerRef = AutoDisposeFutureProviderRef<bool>;
String _$connectHash() => r'946ac6cce15a0ac9b3a7f8c1b606b3782e64f5e7';
String _$connectHash() => r'576283d8c543cdb4b1ae22c99cc63a23e4ff2981';
/// See also [Connect].
@ProviderFor(Connect)

View File

@@ -77,7 +77,7 @@ class _ConnectForm extends ConsumerWidget {
final connectionMethod = ConnectionMethod.values[provider.method];
final connectionString =
"${connectionMethod.name}://${provider.ipDomainController.text}${provider.portController.text != '' ? ':${provider.portController.text}' : ""}";
"${connectionMethod.name}://${provider.ipDomainController.text}${provider.portController.text != '' ? ':${provider.portController.text}' : ""}${provider.pathController.text}";
return Column(
children: [
@@ -167,6 +167,22 @@ class _ConnectForm extends ConsumerWidget {
labelText: t.onboarding.port,
),
),
const SizedBox(height: 24),
TextFormField(
controller: provider.pathController,
onChanged: ref.read(connectProvider.notifier).validatePath,
autocorrect: false,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.route_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
errorText: provider.pathError,
labelText: t.onboarding.path,
),
),
SectionLabel(
label: t.onboarding.authentication,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 24),