Skip to content

Commit

Permalink
fix: #1537 - moved the "slack" and "email" contact options (#1546)
Browse files Browse the repository at this point in the history
Impacted files:
* `smooth_main_button.dart`: added a `TODO` about probable deleting of this class.
* `social_handle_view.dart`: moved there "slack" and "email" contact options; refactored
* `user_preferences_settings.dart`: removed the "support" (slack or email) button
  • Loading branch information
monsieurtanuki authored Apr 11, 2022
1 parent e23117d commit 47c53f7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';

// TODO(monsieurtanuki): probably useless now, [SmoothActionButton] should be enough
class SmoothMainButton extends StatelessWidget {
const SmoothMainButton({
required this.text,
Expand Down
46 changes: 0 additions & 46 deletions packages/smooth_app/lib/pages/user_preferences_settings.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import 'dart:io' show Platform;

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:mailto/mailto.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:smooth_app/data_models/user_preferences.dart';
import 'package:smooth_app/generic_lib/buttons/smooth_action_button.dart';
import 'package:smooth_app/generic_lib/buttons/smooth_main_button.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/generic_lib/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_list_tile.dart';
Expand All @@ -18,7 +14,6 @@ import 'package:smooth_app/themes/theme_provider.dart';
import 'package:smooth_app/views/bottom_sheet_views/faq_handle_view.dart';
import 'package:smooth_app/views/bottom_sheet_views/social_handle_view.dart';
import 'package:smooth_app/views/bottom_sheet_views/user_contribution_view.dart';
import 'package:url_launcher/url_launcher.dart';

/// Collapsed/expanded display of settings for the preferences page.
class UserPreferencesSettings extends AbstractUserPreferences {
Expand Down Expand Up @@ -132,47 +127,6 @@ class UserPreferencesSettings extends AbstractUserPreferences {
builder: (BuildContext context) => UserContributionView(),
),
),
SmoothListTile(
text: appLocalizations.support,
onPressed: () {
showDialog<void>(
context: context,
builder: (BuildContext context) => SmoothAlertDialog.advanced(
body: Column(
children: <Widget>[
SmoothMainButton(
important: false,
text: appLocalizations.support_join_slack,
onPressed: () {
LaunchUrlHelper.launchURL(
'https://slack.openfoodfacts.org/',
false,
);
},
),
const SizedBox(height: 20),
SmoothMainButton(
important: false,
text: appLocalizations.support_via_email,
onPressed: () async {
final PackageInfo packageInfo =
await PackageInfo.fromPlatform();
// TODO(M123): Change subject name when we have a different app name
final Mailto mailtoLink = Mailto(
to: <String>['contact@openfoodfacts.org'],
subject: 'Smoothie help',
body:
'Version:${packageInfo.version}+${packageInfo.buildNumber} running on ${Platform.operatingSystem}(${Platform.operatingSystemVersion})',
);
await launch('$mailtoLink');
},
),
],
),
),
);
},
),
SmoothListTile(
text: appLocalizations.about_this_app,
onPressed: () async {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,67 @@
import 'dart:io' show Platform;

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:mailto/mailto.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_list_tile.dart';
import 'package:smooth_app/helpers/launch_url_helper.dart';
import 'package:smooth_app/widgets/modal_bottomsheet_header.dart';
import 'package:url_launcher/url_launcher.dart';

class SocialHandleView extends StatelessWidget {
static const Icon _icon = Icon(Icons.open_in_new);

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
return Material(
child: SizedBox(
height: MediaQuery.of(context).size.height * 0.8,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: <Widget>[
ModalBottomSheetHeader(
title: AppLocalizations.of(context)!.connect_with_us),
// Instagram
ModalBottomSheetHeader(title: appLocalizations.connect_with_us),
SmoothListTile(
text: AppLocalizations.of(context)!.instagram,
leadingWidget: const Icon(Icons.open_in_new),
text: appLocalizations.instagram,
leadingWidget: _icon,
onPressed: () => _launchUrl(
context, 'https://instagram.com/open.food.facts')),

//Twitter
SmoothListTile(
text: AppLocalizations.of(context)!.twitter,
leadingWidget: const Icon(Icons.open_in_new),
text: appLocalizations.twitter,
leadingWidget: _icon,
onPressed: () =>
_launchUrl(context, 'https://www.twitter.com/openfoodfacts'),
),

//Blog
SmoothListTile(
text: AppLocalizations.of(context)!.blog,
leadingWidget: const Icon(Icons.open_in_new),
text: appLocalizations.blog,
leadingWidget: _icon,
onPressed: () =>
_launchUrl(context, 'https://en.blog.openfoodfacts.org'),
),
SmoothListTile(
text: appLocalizations.support_join_slack,
leadingWidget: _icon,
onPressed: () =>
_launchUrl(context, 'https://slack.openfoodfacts.org/'),
),
SmoothListTile(
text: appLocalizations.support_via_email,
leadingWidget: _icon,
onPressed: () async {
final PackageInfo packageInfo =
await PackageInfo.fromPlatform();
// TODO(M123): Change subject name when we have a different app name
final Mailto mailtoLink = Mailto(
to: <String>['contact@openfoodfacts.org'],
subject: 'Smoothie help', // TODO(monsieurtanuki): localize
body:
'Version:${packageInfo.version}+${packageInfo.buildNumber} running on ${Platform.operatingSystem}(${Platform.operatingSystemVersion})',
);
await launch('$mailtoLink');
},
),
],
),
),
Expand Down

0 comments on commit 47c53f7

Please sign in to comment.