Merge branch 'homeserver-url-username-inputs-improvements' into 'master'

Cosmetic improvements of homeserver and user inputs

Closes #64 and #34

See merge request ChristianPauly/fluffychat-flutter!97
This commit is contained in:
Christian Pauly 2020-07-02 09:10:03 +00:00
commit 0c6896f593
3 changed files with 22 additions and 12 deletions

View file

@ -8,8 +8,8 @@ class SimpleDialogs {
const SimpleDialogs(this.context); const SimpleDialogs(this.context);
Future<String> enterText({ Future<String> enterText(
String titleText, {String titleText,
String confirmText, String confirmText,
String cancelText, String cancelText,
String hintText, String hintText,
@ -18,7 +18,7 @@ class SimpleDialogs {
String suffixText, String suffixText,
bool password = false, bool password = false,
bool multiLine = false, bool multiLine = false,
}) async { TextInputType keyboardType}) async {
var textEditingController = TextEditingController(); var textEditingController = TextEditingController();
final controller = textEditingController; final controller = textEditingController;
String input; String input;
@ -38,6 +38,7 @@ class SimpleDialogs {
maxLines: multiLine ? 3 : 1, maxLines: multiLine ? 3 : 1,
obscureText: password, obscureText: password,
textInputAction: multiLine ? TextInputAction.newline : null, textInputAction: multiLine ? TextInputAction.newline : null,
keyboardType: keyboardType,
decoration: InputDecoration( decoration: InputDecoration(
hintText: hintText, hintText: hintText,
labelText: labelText, labelText: labelText,

View file

@ -12,7 +12,8 @@ class HomeserverPicker extends StatelessWidget {
final homeserver = await SimpleDialogs(context).enterText( final homeserver = await SimpleDialogs(context).enterText(
titleText: L10n.of(context).enterYourHomeserver, titleText: L10n.of(context).enterYourHomeserver,
hintText: Matrix.defaultHomeserver, hintText: Matrix.defaultHomeserver,
prefixText: 'https://'); prefixText: 'https://',
keyboardType: TextInputType.url);
if (homeserver?.isEmpty ?? true) return; if (homeserver?.isEmpty ?? true) return;
_checkHomeserverAction(homeserver, context); _checkHomeserverAction(homeserver, context);
} }
@ -21,6 +22,13 @@ class HomeserverPicker extends StatelessWidget {
if (!homeserver.startsWith('https://')) { if (!homeserver.startsWith('https://')) {
homeserver = 'https://$homeserver'; 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( final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
Matrix.of(context).client.checkServer(homeserver)); Matrix.of(context).client.checkServer(homeserver));
if (success != false) { if (success != false) {

View file

@ -131,6 +131,7 @@ class _LoginState extends State<Login> {
readOnly: loading, readOnly: loading,
autocorrect: false, autocorrect: false,
autofocus: true, autofocus: true,
keyboardType: TextInputType.emailAddress,
onChanged: (t) => _checkWellKnownWithCoolDown(t, context), onChanged: (t) => _checkWellKnownWithCoolDown(t, context),
controller: usernameController, controller: usernameController,
decoration: InputDecoration( decoration: InputDecoration(