@@ -22,6 +22,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
22
22
import 'package:provider/provider.dart' ;
23
23
import 'package:wger/models/user/profile.dart' ;
24
24
import 'package:wger/providers/user.dart' ;
25
+ import 'package:wger/theme/theme.dart' ;
25
26
26
27
class UserProfileForm extends StatelessWidget {
27
28
late final Profile _profile;
@@ -40,39 +41,23 @@ class UserProfileForm extends StatelessWidget {
40
41
child: Column (
41
42
children: [
42
43
ListTile (
44
+ leading: const Icon (Icons .person, color: wgerPrimaryColor),
43
45
title: Text (AppLocalizations .of (context).username),
44
46
subtitle: Text (_profile.username),
45
47
),
46
48
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),
74
50
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 ),
76
61
controller: emailController,
77
62
keyboardType: TextInputType .emailAddress,
78
63
onSaved: (newValue) {
@@ -86,8 +71,30 @@ class UserProfileForm extends StatelessWidget {
86
71
},
87
72
),
88
73
),
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
+ ),
89
94
ElevatedButton (
90
- child: Text (AppLocalizations .of (context).save),
95
+ style: ElevatedButton .styleFrom (
96
+ backgroundColor: wgerPrimaryButtonColor,
97
+ shape: RoundedRectangleBorder (borderRadius: BorderRadius .circular (50 ))),
91
98
onPressed: () async {
92
99
// Validate and save the current values to the weightEntry
93
100
final isValid = _form.currentState! .validate ();
@@ -103,6 +110,7 @@ class UserProfileForm extends StatelessWidget {
103
110
SnackBar (content: Text (AppLocalizations .of (context).successfullySaved)),
104
111
);
105
112
},
113
+ child: Text (AppLocalizations .of (context).save),
106
114
),
107
115
],
108
116
),
0 commit comments