diff --git a/lib/components/dialogs/simple_dialogs.dart b/lib/components/dialogs/simple_dialogs.dart index b1fd04e..527d0e6 100644 --- a/lib/components/dialogs/simple_dialogs.dart +++ b/lib/components/dialogs/simple_dialogs.dart @@ -8,17 +8,17 @@ class SimpleDialogs { const SimpleDialogs(this.context); - Future enterText({ - String titleText, - String confirmText, - String cancelText, - String hintText, - String labelText, - String prefixText, - String suffixText, - bool password = false, - bool multiLine = false, - }) async { + Future enterText( + {String titleText, + String confirmText, + String cancelText, + String hintText, + String labelText, + String prefixText, + String suffixText, + bool password = false, + bool multiLine = false, + TextInputType keyboardType}) async { var textEditingController = TextEditingController(); final controller = textEditingController; String input; @@ -38,6 +38,7 @@ class SimpleDialogs { maxLines: multiLine ? 3 : 1, obscureText: password, textInputAction: multiLine ? TextInputAction.newline : null, + keyboardType: keyboardType, decoration: InputDecoration( hintText: hintText, labelText: labelText, diff --git a/lib/views/homeserver_picker.dart b/lib/views/homeserver_picker.dart index 8f6dbec..85568be 100644 --- a/lib/views/homeserver_picker.dart +++ b/lib/views/homeserver_picker.dart @@ -12,7 +12,8 @@ class HomeserverPicker extends StatelessWidget { final homeserver = await SimpleDialogs(context).enterText( titleText: L10n.of(context).enterYourHomeserver, hintText: Matrix.defaultHomeserver, - prefixText: 'https://'); + prefixText: 'https://', + keyboardType: TextInputType.url); if (homeserver?.isEmpty ?? true) return; _checkHomeserverAction(homeserver, context); } @@ -21,6 +22,13 @@ class HomeserverPicker extends StatelessWidget { if (!homeserver.startsWith('https://')) { homeserver = 'https://$homeserver'; } + + // removes trailing spaces and slash from url if present (api errors on it) + homeserver = homeserver.trim(); + if (homeserver.endsWith('/')) { + homeserver = homeserver.substring(0, homeserver.length - 1); + } + final success = await SimpleDialogs(context).tryRequestWithLoadingDialog( Matrix.of(context).client.checkServer(homeserver)); if (success != false) { diff --git a/lib/views/login.dart b/lib/views/login.dart index 306c4ac..8f36078 100644 --- a/lib/views/login.dart +++ b/lib/views/login.dart @@ -131,6 +131,7 @@ class _LoginState extends State { readOnly: loading, autocorrect: false, autofocus: true, + keyboardType: TextInputType.emailAddress, onChanged: (t) => _checkWellKnownWithCoolDown(t, context), controller: usernameController, decoration: InputDecoration(