Added path field
This commit is contained in:
@@ -5,4 +5,5 @@ class Regexps {
|
||||
RegExp(r'[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)');
|
||||
static final ipAddress = RegExp(r'^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$');
|
||||
static final domain = RegExp(r'^(([a-z0-9|-]+\.)*[a-z0-9|-]+\.[a-z]+)$');
|
||||
static final path = RegExp(r'^\/\b([A-Za-z0-9_\-~/]*)[^\/|\.|\:]$');
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
/// To regenerate, run: `dart run slang`
|
||||
///
|
||||
/// Locales: 2
|
||||
/// Strings: 280 (140 per locale)
|
||||
/// Strings: 284 (142 per locale)
|
||||
///
|
||||
/// Built on 2024-02-26 at 09:50 UTC
|
||||
/// Built on 2024-02-26 at 14:46 UTC
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
@@ -194,6 +194,8 @@ class _StringsOnboardingEn {
|
||||
String get createConnectionSubtitle => 'Enter all the required details to create a connection to your server.';
|
||||
String get ipAddressOrDomain => 'IP address or domain';
|
||||
String get port => 'Port';
|
||||
String get path => 'Path';
|
||||
String get invalidPath => 'Invalid path';
|
||||
String get token => 'Token';
|
||||
String get required => 'Required';
|
||||
String get serverDetails => 'Server details';
|
||||
@@ -520,6 +522,8 @@ class _StringsOnboardingEs implements _StringsOnboardingEn {
|
||||
@override String get createConnectionSubtitle => 'Introduce todos los detalles requeridos para crear una conexión con el servidor';
|
||||
@override String get ipAddressOrDomain => 'Dirección IP o dominio';
|
||||
@override String get port => 'Puerto';
|
||||
@override String get path => 'Ruta';
|
||||
@override String get invalidPath => 'Ruta no válida';
|
||||
@override String get token => 'Token';
|
||||
@override String get required => 'Requerido';
|
||||
@override String get serverDetails => 'Detalles del servidor';
|
||||
@@ -803,6 +807,8 @@ extension on Translations {
|
||||
case 'onboarding.createConnectionSubtitle': return 'Enter all the required details to create a connection to your server.';
|
||||
case 'onboarding.ipAddressOrDomain': return 'IP address or domain';
|
||||
case 'onboarding.port': return 'Port';
|
||||
case 'onboarding.path': return 'Path';
|
||||
case 'onboarding.invalidPath': return 'Invalid path';
|
||||
case 'onboarding.token': return 'Token';
|
||||
case 'onboarding.required': return 'Required';
|
||||
case 'onboarding.serverDetails': return 'Server details';
|
||||
@@ -951,6 +957,8 @@ extension on _StringsEs {
|
||||
case 'onboarding.createConnectionSubtitle': return 'Introduce todos los detalles requeridos para crear una conexión con el servidor';
|
||||
case 'onboarding.ipAddressOrDomain': return 'Dirección IP o dominio';
|
||||
case 'onboarding.port': return 'Puerto';
|
||||
case 'onboarding.path': return 'Ruta';
|
||||
case 'onboarding.invalidPath': return 'Ruta no válida';
|
||||
case 'onboarding.token': return 'Token';
|
||||
case 'onboarding.required': return 'Requerido';
|
||||
case 'onboarding.serverDetails': return 'Detalles del servidor';
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
"createConnectionSubtitle": "Enter all the required details to create a connection to your server.",
|
||||
"ipAddressOrDomain": "IP address or domain",
|
||||
"port": "Port",
|
||||
"path": "Path",
|
||||
"invalidPath": "Invalid path",
|
||||
"token": "Token",
|
||||
"required": "Required",
|
||||
"serverDetails": "Server details",
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
"createConnectionSubtitle": "Introduce todos los detalles requeridos para crear una conexión con el servidor",
|
||||
"ipAddressOrDomain": "Dirección IP o dominio",
|
||||
"port": "Puerto",
|
||||
"path": "Ruta",
|
||||
"invalidPath": "Ruta no válida",
|
||||
"token": "Token",
|
||||
"required": "Requerido",
|
||||
"serverDetails": "Detalles del servidor",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:linkdy/models/server_instance.dart';
|
||||
|
||||
String apiBaseUrl(ServerInstance server) {
|
||||
return "${server.method}://${server.ipDomain}${server.port != null ? ':${server.port}' : ""}/api";
|
||||
return "${server.method}://${server.ipDomain}${server.port != null ? ':${server.port}' : ""}${server.path}/api";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user