public profile toggle sets user DOB (#1318)
This commit is contained in:
parent
129c5a5a7a
commit
6491042d59
1 changed files with 15 additions and 2 deletions
|
|
@ -34,7 +34,16 @@ class SettingsLearningController extends State<SettingsLearning> {
|
|||
setPublicProfile(bool isPublic) {
|
||||
pangeaController.userController.updateProfile(
|
||||
(profile) {
|
||||
profile.userSettings.publicProfile = isPublic;
|
||||
// set user DOB to younger that 18 if private and older than 18 if public
|
||||
if (isPublic) {
|
||||
profile.userSettings.dateOfBirth = DateTime.now().subtract(
|
||||
const Duration(days: 18 * 365),
|
||||
);
|
||||
} else {
|
||||
profile.userSettings.dateOfBirth = DateTime.now().subtract(
|
||||
const Duration(days: 17 * 365),
|
||||
);
|
||||
}
|
||||
return profile;
|
||||
},
|
||||
);
|
||||
|
|
@ -91,7 +100,11 @@ class SettingsLearningController extends State<SettingsLearning> {
|
|||
}
|
||||
|
||||
bool get publicProfile =>
|
||||
pangeaController.userController.profile.userSettings.publicProfile;
|
||||
pangeaController.userController.profile.userSettings.dateOfBirth
|
||||
?.isBefore(
|
||||
DateTime.now().subtract(const Duration(days: 18 * 365)),
|
||||
) ??
|
||||
false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue