Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Aman Negi - <https://github.com/AmanNegi>
- Sandi Milohanic - <https://github.com/sandimilohanic>
- Miroslav Mazel - <https://gitlab.com/12people>
- Tejas Bir Singh - <https://github.com/tejasbirsingh>

## Translators

Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
66 changes: 37 additions & 29 deletions lib/widgets/user/forms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<UserProvider>().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) {
Expand All @@ -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<UserProvider>().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();
Expand All @@ -103,6 +110,7 @@ class UserProfileForm extends StatelessWidget {
SnackBar(content: Text(AppLocalizations.of(context).successfullySaved)),
);
},
child: Text(AppLocalizations.of(context).save),
),
],
),
Expand Down