Skip to content

Commit f43be9e

Browse files
authored
Merge pull request #387 from tejasbirsingh/user-profile-UI-changes
Add icons, merge email and its verify fields
2 parents d044e03 + 090abe9 commit f43be9e

File tree

3 files changed

+40
-29
lines changed

3 files changed

+40
-29
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Aman Negi - <https://github.com/AmanNegi>
2020
- Sandi Milohanic - <https://github.com/sandimilohanic>
2121
- Miroslav Mazel - <https://gitlab.com/12people>
22+
- Tejas Bir Singh - <https://github.com/tejasbirsingh>
2223

2324
## Translators
2425

lib/l10n/app_en.arb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@
241241
},
242242
"save": "Save",
243243
"@save": {},
244+
"verify": "Verify",
245+
"@verify": {},
244246
"addSet": "Add set",
245247
"@addSet": {
246248
"description": "Label for the button that adds a set (to a workout day)"

lib/widgets/user/forms.dart

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
2222
import 'package:provider/provider.dart';
2323
import 'package:wger/models/user/profile.dart';
2424
import 'package:wger/providers/user.dart';
25+
import 'package:wger/theme/theme.dart';
2526

2627
class UserProfileForm extends StatelessWidget {
2728
late final Profile _profile;
@@ -40,39 +41,23 @@ class UserProfileForm extends StatelessWidget {
4041
child: Column(
4142
children: [
4243
ListTile(
44+
leading: const Icon(Icons.person, color: wgerPrimaryColor),
4345
title: Text(AppLocalizations.of(context).username),
4446
subtitle: Text(_profile.username),
4547
),
4648
ListTile(
47-
title: Text(
48-
_profile.emailVerified
49-
? AppLocalizations.of(context).verifiedEmail
50-
: AppLocalizations.of(context).unVerifiedEmail,
51-
),
52-
subtitle: Text(AppLocalizations.of(context).verifiedEmailReason),
53-
trailing: _profile.emailVerified
54-
? const Icon(Icons.mark_email_read, color: Colors.green)
55-
: const Icon(Icons.forward_to_inbox),
56-
onTap: () async {
57-
// Email is already verified
58-
if (_profile.emailVerified) {
59-
return;
60-
}
61-
62-
// Verify
63-
await context.read<UserProvider>().verifyEmail();
64-
ScaffoldMessenger.of(context).showSnackBar(
65-
SnackBar(
66-
content: Text(
67-
AppLocalizations.of(context).verifiedEmailInfo(_profile.email),
68-
),
69-
),
70-
);
71-
},
72-
),
73-
ListTile(
49+
leading: const Icon(Icons.email_rounded, color: wgerPrimaryColor),
7450
title: TextFormField(
75-
decoration: InputDecoration(labelText: AppLocalizations.of(context).email),
51+
decoration: InputDecoration(
52+
labelText: _profile.emailVerified
53+
? AppLocalizations.of(context).verifiedEmail
54+
: AppLocalizations.of(context).unVerifiedEmail,
55+
suffixIcon: _profile.emailVerified
56+
? const Icon(
57+
Icons.check_circle,
58+
color: Colors.green,
59+
)
60+
: null),
7661
controller: emailController,
7762
keyboardType: TextInputType.emailAddress,
7863
onSaved: (newValue) {
@@ -86,8 +71,30 @@ class UserProfileForm extends StatelessWidget {
8671
},
8772
),
8873
),
74+
if (!_profile.emailVerified)
75+
OutlinedButton(
76+
onPressed: () async {
77+
// Email is already verified
78+
if (_profile.emailVerified) {
79+
return;
80+
}
81+
82+
// Verify
83+
await context.read<UserProvider>().verifyEmail();
84+
ScaffoldMessenger.of(context).showSnackBar(
85+
SnackBar(
86+
content: Text(
87+
AppLocalizations.of(context).verifiedEmailInfo(_profile.email),
88+
),
89+
),
90+
);
91+
},
92+
child: Text(AppLocalizations.of(context).verify),
93+
),
8994
ElevatedButton(
90-
child: Text(AppLocalizations.of(context).save),
95+
style: ElevatedButton.styleFrom(
96+
backgroundColor: wgerPrimaryButtonColor,
97+
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50))),
9198
onPressed: () async {
9299
// Validate and save the current values to the weightEntry
93100
final isValid = _form.currentState!.validate();
@@ -103,6 +110,7 @@ class UserProfileForm extends StatelessWidget {
103110
SnackBar(content: Text(AppLocalizations.of(context).successfullySaved)),
104111
);
105112
},
113+
child: Text(AppLocalizations.of(context).save),
106114
),
107115
],
108116
),

0 commit comments

Comments
 (0)