diff --git a/AUTHORS.md b/AUTHORS.md index a14238764..7efdf9e70 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -19,6 +19,7 @@ - Aman Negi - - Sandi Milohanic - - Miroslav Mazel - +- Tejas Bir Singh - ## Translators diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index f0fd2187c..7a6a010da 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -241,6 +241,8 @@ }, "save": "Save", "@save": {}, + "verify": "Verify", + "@verify": {}, "addSet": "Add set", "@addSet": { "description": "Label for the button that adds a set (to a workout day)" diff --git a/lib/widgets/user/forms.dart b/lib/widgets/user/forms.dart index 39fb80a74..14e1f28bc 100644 --- a/lib/widgets/user/forms.dart +++ b/lib/widgets/user/forms.dart @@ -22,6 +22,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; import 'package:wger/models/user/profile.dart'; import 'package:wger/providers/user.dart'; +import 'package:wger/theme/theme.dart'; class UserProfileForm extends StatelessWidget { late final Profile _profile; @@ -40,39 +41,23 @@ class UserProfileForm extends StatelessWidget { child: Column( children: [ ListTile( + leading: const Icon(Icons.person, color: wgerPrimaryColor), title: Text(AppLocalizations.of(context).username), subtitle: Text(_profile.username), ), ListTile( - title: Text( - _profile.emailVerified - ? AppLocalizations.of(context).verifiedEmail - : AppLocalizations.of(context).unVerifiedEmail, - ), - subtitle: Text(AppLocalizations.of(context).verifiedEmailReason), - trailing: _profile.emailVerified - ? const Icon(Icons.mark_email_read, color: Colors.green) - : const Icon(Icons.forward_to_inbox), - onTap: () async { - // Email is already verified - if (_profile.emailVerified) { - return; - } - - // Verify - await context.read().verifyEmail(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - AppLocalizations.of(context).verifiedEmailInfo(_profile.email), - ), - ), - ); - }, - ), - ListTile( + leading: const Icon(Icons.email_rounded, color: wgerPrimaryColor), title: TextFormField( - decoration: InputDecoration(labelText: AppLocalizations.of(context).email), + decoration: InputDecoration( + labelText: _profile.emailVerified + ? AppLocalizations.of(context).verifiedEmail + : AppLocalizations.of(context).unVerifiedEmail, + suffixIcon: _profile.emailVerified + ? const Icon( + Icons.check_circle, + color: Colors.green, + ) + : null), controller: emailController, keyboardType: TextInputType.emailAddress, onSaved: (newValue) { @@ -86,8 +71,30 @@ class UserProfileForm extends StatelessWidget { }, ), ), + if (!_profile.emailVerified) + OutlinedButton( + onPressed: () async { + // Email is already verified + if (_profile.emailVerified) { + return; + } + + // Verify + await context.read().verifyEmail(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + AppLocalizations.of(context).verifiedEmailInfo(_profile.email), + ), + ), + ); + }, + child: Text(AppLocalizations.of(context).verify), + ), ElevatedButton( - child: Text(AppLocalizations.of(context).save), + style: ElevatedButton.styleFrom( + backgroundColor: wgerPrimaryButtonColor, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50))), onPressed: () async { // Validate and save the current values to the weightEntry final isValid = _form.currentState!.validate(); @@ -103,6 +110,7 @@ class UserProfileForm extends StatelessWidget { SnackBar(content: Text(AppLocalizations.of(context).successfullySaved)), ); }, + child: Text(AppLocalizations.of(context).save), ), ], ),