Server selection and login are on different pages. #33
2 changed files with 41 additions and 52 deletions
CleanUp and last fixes
- Borders only get overwritten in error case - Navigator.pop(context) -> Navigator.of(context).pop() - Confirm homeserver und Sign in button disabled as long as error is active
commit
248b77e4c5
|
|
@ -50,7 +50,7 @@ class LoginPage extends HookConsumerWidget {
|
||||||
);
|
);
|
||||||
isLoggingIn.value = false;
|
isLoggingIn.value = false;
|
||||||
} else {
|
} else {
|
||||||
Navigator.pop(context);
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
passwordFocusNode.requestFocus();
|
passwordFocusNode.requestFocus();
|
||||||
isLoggingIn.value = false;
|
isLoggingIn.value = false;
|
||||||
|
|
@ -60,7 +60,7 @@ class LoginPage extends HookConsumerWidget {
|
||||||
appBar: Appbar(
|
appBar: Appbar(
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(Icons.arrow_back),
|
icon: Icon(Icons.arrow_back),
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
istalri marked this conversation as resolved
Outdated
Henry-Hiles
commented
Outdated
```diff
- onPressed: () => Navigator.pop(context),
+ onPressed: Navigator.of(context).pop,
```
istalri marked this conversation as resolved
Outdated
Henry-Hiles
commented
```diff
- onPressed: () => Navigator.of(context).pop(),
+ onPressed: Navigator.of(context).pop,
```
|
|||||||
),
|
),
|
||||||
|
Henry-Hiles marked this conversation as resolved
Outdated
Henry-Hiles
commented
bad formatting here. make sure you format your code :) bad formatting here. make sure you format your code :)
istalri
commented
Yeah I totally forgot. Autoformatting is good? like ctrl + shift + i? Yeah I totally forgot. Autoformatting is good? like ctrl + shift + i?
Henry-Hiles
commented
Yeah, that should work great. I have it set to format on save. Yeah, that should work great. I have it set to format on save.
|
|||||||
),
|
),
|
||||||
|
istalri marked this conversation as resolved
Henry-Hiles
commented
prefer prefer `Navigator.of(context).pop()`
|
|||||||
body: AlertDialog(
|
body: AlertDialog(
|
||||||
|
|
@ -81,22 +81,16 @@ class LoginPage extends HookConsumerWidget {
|
||||||
},
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
label: Text("Username"),
|
label: Text("Username"),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: hasError.value
|
||||||
borderSide: BorderSide(
|
? OutlineInputBorder(
|
||||||
width: hasError.value ? 4 : 2,
|
borderSide: BorderSide(color: theme.colorScheme.error),
|
||||||
color: hasError.value
|
)
|
||||||
? theme.colorScheme.error
|
: null,
|
||||||
: theme.colorScheme.primary,
|
enabledBorder: hasError.value
|
||||||
),
|
? OutlineInputBorder(
|
||||||
),
|
borderSide: BorderSide(color: theme.colorScheme.error),
|
||||||
enabledBorder: OutlineInputBorder(
|
)
|
||||||
borderSide: BorderSide(
|
: null,
|
||||||
width: hasError.value ? 4 : 2,
|
|
||||||
color: hasError.value
|
|
||||||
? theme.colorScheme.error
|
|
||||||
: theme.colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
controller: username,
|
controller: username,
|
||||||
),
|
),
|
||||||
|
|
@ -113,22 +107,16 @@ class LoginPage extends HookConsumerWidget {
|
||||||
selectAllOnFocus: true,
|
selectAllOnFocus: true,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
label: Text("Password"),
|
label: Text("Password"),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: hasError.value
|
||||||
borderSide: BorderSide(
|
? OutlineInputBorder(
|
||||||
width: hasError.value ? 4 : 2,
|
borderSide: BorderSide(color: theme.colorScheme.error),
|
||||||
color: hasError.value
|
)
|
||||||
? theme.colorScheme.error
|
: null,
|
||||||
: theme.colorScheme.primary,
|
enabledBorder: hasError.value
|
||||||
),
|
? OutlineInputBorder(
|
||||||
),
|
borderSide: BorderSide(color: theme.colorScheme.error),
|
||||||
enabledBorder: OutlineInputBorder(
|
)
|
||||||
borderSide: BorderSide(
|
: null,
|
||||||
width: hasError.value ? 4 : 2,
|
|
||||||
color: hasError.value
|
|
||||||
? theme.colorScheme.error
|
|
||||||
: theme.colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
controller: password,
|
controller: password,
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
|
|
@ -136,7 +124,10 @@ class LoginPage extends HookConsumerWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(onPressed: () => tryLogin(), child: Text("Sign In")),
|
TextButton(
|
||||||
|
onPressed: hasError.value ? null : () => tryLogin(),
|
||||||
|
child: Text("Sign In"),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -113,28 +113,26 @@ class SelectServerPage extends HookConsumerWidget {
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: "Homeserver URL (e.g. matrix.org)",
|
labelText: "Homeserver URL (e.g. matrix.org)",
|
||||||
hintText: "e.g. matrix.org",
|
hintText: "e.g. matrix.org",
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: hasError.value
|
||||||
|
? OutlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
width: hasError.value ? 4 : 2,
|
color: theme.colorScheme.error,
|
||||||
color: hasError.value
|
|
||||||
? theme.colorScheme.error
|
|
||||||
: theme.colorScheme.primary,
|
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
enabledBorder: OutlineInputBorder(
|
: null,
|
||||||
|
enabledBorder: hasError.value
|
||||||
|
? OutlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
width: hasError.value ? 4 : 2,
|
color: theme.colorScheme.error,
|
||||||
color: hasError.value
|
|
||||||
? theme.colorScheme.error
|
|
||||||
: theme.colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton.filled(
|
IconButton.filled(
|
||||||
tooltip: "Confirm homeserver choice",
|
tooltip: "Confirm homeserver choice",
|
||||||
onPressed: isLoading.value
|
onPressed: isLoading.value || hasError.value
|
||||||
? null
|
? null
|
||||||
: () => setHomeserver(
|
: () => setHomeserver(
|
||||||
Uri.tryParse(homeserverUrl.text),
|
Uri.tryParse(homeserverUrl.text),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue