@@ -327,24 +327,32 @@ class _PasswordLoginPageState extends State<PasswordLoginPage> {
327
327
@override
328
328
Widget build (BuildContext context) {
329
329
assert (! PerAccountStoreWidget .debugExistsOf (context));
330
+ final requireEmailFormatUsernames = widget.serverSettings.requireEmailFormatUsernames;
330
331
331
332
final usernameField = TextFormField (
332
333
key: _usernameKey,
333
- autofillHints: const [AutofillHints .email],
334
+ autofillHints: [
335
+ if (! requireEmailFormatUsernames) AutofillHints .username,
336
+ AutofillHints .email,
337
+ ],
334
338
keyboardType: TextInputType .emailAddress,
335
339
// TODO(upstream?): Apparently pressing "next" doesn't count
336
340
// as user interaction, and validation isn't done.
337
341
autovalidateMode: AutovalidateMode .onUserInteraction,
338
342
validator: (value) {
339
343
if (value == null || value.trim ().isEmpty) {
340
- return 'Please enter your email.' ;
344
+ return requireEmailFormatUsernames
345
+ ? 'Please enter your email.'
346
+ : 'Please enter your username.' ;
347
+ }
348
+ if (requireEmailFormatUsernames) {
349
+ // TODO(#35): validate is in the shape of an email
341
350
}
342
- // TODO(#35): validate is in the shape of an email
343
351
return null ;
344
352
},
345
353
textInputAction: TextInputAction .next,
346
- decoration: const InputDecoration (
347
- labelText: 'Email address' ,
354
+ decoration: InputDecoration (
355
+ labelText: requireEmailFormatUsernames ? 'Email address' : 'Username ' ,
348
356
helperText: kLayoutPinningHelperText,
349
357
));
350
358
0 commit comments