Skip to content

Commit

Permalink
chore: Moving email and newsletter up in contact page (#5111)
Browse files Browse the repository at this point in the history
Co-authored-by: Gabriel Moraes <[email protected]>
  • Loading branch information
gmmoraes and Gabriel Moraes authored Mar 10, 2024
1 parent f1d0992 commit 44913af
Showing 1 changed file with 43 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,49 @@ class UserPreferencesConnect extends AbstractUserPreferences {

@override
List<UserPreferencesItem> getChildren() => <UserPreferencesItem>[
_getListTile(
title: appLocalizations.contact_title_newsletter,
url: 'https://link.openfoodfacts.org/newsletter-en',
leadingIconData: CupertinoIcons.news_solid,
),
_getListTile(
title: appLocalizations.support_via_email,
leadingIconData: Icons.drafts,
onTap: () async {
final bool? includeLogs = await showDialog<bool>(
context: context,
builder: (BuildContext context) {
return SmoothAlertDialog(
title: appLocalizations
.support_via_email_include_logs_dialog_title,
body: Text(
appLocalizations
.support_via_email_include_logs_dialog_body,
),
close: true,
positiveAction: SmoothActionButton(
text: appLocalizations.yes,
onPressed: () => Navigator.of(context).pop(true)),
negativeAction: SmoothActionButton(
text: appLocalizations.no,
onPressed: () => Navigator.of(context).pop(false)),
);
});

if (includeLogs == null) {
return;
}

await _sendEmail(
body: await _emailBody,
subject:
'${appLocalizations.help_with_openfoodfacts} (Help with Open Food Facts)',
recipient: '[email protected]',
attachmentPaths: includeLogs == true ? Logs.logFilesPaths : null,
);
},
),
_getDivider(),
_getListTile(
title: appLocalizations.instagram,
url: appLocalizations.instagram_link,
Expand Down Expand Up @@ -126,49 +169,6 @@ class UserPreferencesConnect extends AbstractUserPreferences {
: '[email protected]',
),
),
_getDivider(),
_getListTile(
title: appLocalizations.contact_title_newsletter,
url: 'https://link.openfoodfacts.org/newsletter-en',
leadingIconData: CupertinoIcons.news_solid,
),
_getListTile(
title: appLocalizations.support_via_email,
leadingIconData: Icons.drafts,
onTap: () async {
final bool? includeLogs = await showDialog<bool>(
context: context,
builder: (BuildContext context) {
return SmoothAlertDialog(
title: appLocalizations
.support_via_email_include_logs_dialog_title,
body: Text(
appLocalizations
.support_via_email_include_logs_dialog_body,
),
close: true,
positiveAction: SmoothActionButton(
text: appLocalizations.yes,
onPressed: () => Navigator.of(context).pop(true)),
negativeAction: SmoothActionButton(
text: appLocalizations.no,
onPressed: () => Navigator.of(context).pop(false)),
);
});

if (includeLogs == null) {
return;
}

await _sendEmail(
body: await _emailBody,
subject:
'${appLocalizations.help_with_openfoodfacts} (Help with Open Food Facts)',
recipient: '[email protected]',
attachmentPaths: includeLogs == true ? Logs.logFilesPaths : null,
);
},
),
];

Future<String> get _emailBody async {
Expand Down

0 comments on commit 44913af

Please sign in to comment.