Skip to content

Commit

Permalink
feat: added feedback form links (#3487)
Browse files Browse the repository at this point in the history
* added feedback form links

* formated code

* localization

* feedback form link function

* removed unwanted imports

* new class file for userfeedbacklink

* fix: Imports

Co-authored-by: Marvin Möltgen <39344769+M123-dev@users.noreply.github.com>
  • Loading branch information
Omegaviv and M123-dev authored Jan 14, 2023
1 parent 8c2dbc0 commit c607be9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
22 changes: 22 additions & 0 deletions packages/smooth_app/lib/helpers/user_feedback_helper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:smooth_app/query/product_query.dart';

// ignore: avoid_classes_with_only_static_members
class UserFeedbackHelper {
static String getFeedbackFormLink() {
final String languageCode = ProductQuery.getLanguage().code;
if (languageCode == 'en') {
return 'https://forms.gle/AuNZG6fXyAPqN5tL7';
} else if (languageCode == 'de') {
return 'https://forms.gle/vCurhD2Y3ewS1YPv5';
} else if (languageCode == 'es') {
return 'https://forms.gle/CSMmuzR8i4LJBjbM9';
} else if (languageCode == 'fr') {
return 'https://forms.gle/cTR4wqGmW7pGUiaBA';
} else if (languageCode == 'it') {
return 'https://forms.gle/9HcCLFznym1ByQgB6';
} else {
return 'https://forms.gle/AuNZG6fXyAPqN5tL7';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/generic_lib/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_app/helpers/app_helper.dart';
import 'package:smooth_app/helpers/launch_url_helper.dart';
import 'package:smooth_app/helpers/user_feedback_helper.dart';
import 'package:smooth_app/main.dart';
import 'package:smooth_app/pages/preferences/abstract_user_preferences.dart';
import 'package:smooth_app/pages/preferences/user_preferences_list_tile.dart';
Expand Down Expand Up @@ -63,6 +64,11 @@ class UserPreferencesFaq extends AbstractUserPreferences {
leading: Icons.volunteer_activism,
url: 'https://world.openfoodfacts.org/contribute',
),
_getListTile(
title: appLocalizations.feed_back,
leading: Icons.feedback_sharp,
url: UserFeedbackHelper.getFeedbackFormLink(),
),
_getListTile(
title: appLocalizations.about_this_app,
leading: Icons.info,
Expand Down
39 changes: 6 additions & 33 deletions packages/smooth_app/lib/pages/user_management/login_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_email_sender/flutter_email_sender.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:matomo_tracker/matomo_tracker.dart';
Expand All @@ -14,6 +12,8 @@ import 'package:smooth_app/generic_lib/widgets/smooth_card.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_text_form_field.dart';
import 'package:smooth_app/helpers/analytics_helper.dart';
import 'package:smooth_app/helpers/app_helper.dart';
import 'package:smooth_app/helpers/launch_url_helper.dart';
import 'package:smooth_app/helpers/user_feedback_helper.dart';
import 'package:smooth_app/pages/user_management/forgot_password_page.dart';
import 'package:smooth_app/pages/user_management/sign_up_page.dart';
import 'package:smooth_app/services/smooth_services.dart';
Expand Down Expand Up @@ -381,37 +381,10 @@ class _LoginPageState extends State<LoginPage> with TraceableClientMixin {
positiveAction: SmoothActionButton(
text: appLocalizations.okay,
onPressed: () async {
// TODO(omegaviv): implement feedback form and link here,https://github.com/openfoodfacts/smooth-app/issues/3419
// currently asking user to manually write an email
final Email email = Email(
body: '',
subject: appLocalizations.feed_back,
recipients: <String>['contact@openfoodfacts.org'],
);

try {
await FlutterEmailSender.send(email);
} on PlatformException catch (e) {
if (e.code == 'not_available') {
// No email client installed on the device
showDialog<void>(
context: context,
builder: (_) => SmoothAlertDialog(
title: appLocalizations
.no_email_client_available_dialog_title,
body: Text(appLocalizations
.no_email_client_available_dialog_content),
positiveAction: SmoothActionButton(
onPressed: () {
Navigator.of(context).pop();
Navigator.of(context).pop();
},
text: appLocalizations.okay,
),
),
);
}
}
final String formLink =
UserFeedbackHelper.getFeedbackFormLink();
LaunchUrlHelper.launchURL(formLink, false);
Navigator.of(context).pop();
},
),
negativeAction: SmoothActionButton(
Expand Down

0 comments on commit c607be9

Please sign in to comment.