Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: A feedback form for the prices page #5442

Merged
merged 2 commits into from
Jun 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class UserPreferences extends ChangeNotifier {
static const String _TAG_DEV_MODE = 'devMode';
static const String _TAG_USER_TRACKING = 'user_tracking';
static const String _TAG_CRASH_REPORTS = 'crash_reports';
static const String _TAG_PRICES_FEEDBACK_FORM = 'prices_feedback_form';
static const String _TAG_EXCLUDED_ATTRIBUTE_IDS = 'excluded_attributes';
static const String _TAG_USER_GROUP = '_user_group';
static const String _TAG_UNIQUE_RANDOM = '_unique_random';
Expand Down Expand Up @@ -203,6 +204,14 @@ class UserPreferences extends ChangeNotifier {
bool get crashReports =>
_sharedPreferences.getBool(_TAG_CRASH_REPORTS) ?? false;

Future<void> markPricesFeedbackFormAsCompleted() async {
await _sharedPreferences.setBool(_TAG_PRICES_FEEDBACK_FORM, false);
notifyListeners();
}

bool get shouldShowPricesFeedbackForm =>
_sharedPreferences.getBool(_TAG_PRICES_FEEDBACK_FORM) ?? true;

String get currentTheme =>
_sharedPreferences.getString(_TAG_CURRENT_THEME_MODE) ??
THEME_SYSTEM_DEFAULT;
Expand Down
4 changes: 4 additions & 0 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2952,5 +2952,9 @@
"preview_badge": "Preview",
"@preview_badge": {
"description": "Badge to indicate that the product is in preview mode (Be careful with this translation)"
},
"prices_feedback_form": "Click here to send us your feedback about this new feature!",
"@prices_feedback_form": {
"description": "A button to send feedback about the prices feature"
}
}
10 changes: 5 additions & 5 deletions packages/smooth_app/lib/pages/prices/prices_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ class PricesCard extends StatelessWidget {
horizontal: MEDIUM_SPACE,
vertical: VERY_SMALL_SPACE,
),
child: const Row(
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'Preview',
style: TextStyle(
appLocalizations.preview_badge,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
SizedBox(width: SMALL_SPACE),
Lab(
const SizedBox(width: SMALL_SPACE),
const Lab(
color: Colors.white,
size: 13.0,
),
Expand Down
99 changes: 99 additions & 0 deletions packages/smooth_app/lib/pages/prices/prices_page.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
import 'package:smooth_app/data_models/preferences/user_preferences.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_back_button.dart';
import 'package:smooth_app/helpers/launch_url_helper.dart';
import 'package:smooth_app/helpers/provider_helper.dart';
import 'package:smooth_app/pages/prices/get_prices_model.dart';
import 'package:smooth_app/pages/prices/product_prices_list.dart';
import 'package:smooth_app/resources/app_icons.dart';
import 'package:smooth_app/themes/smooth_theme_colors.dart';
import 'package:smooth_app/widgets/smooth_app_bar.dart';
import 'package:smooth_app/widgets/smooth_scaffold.dart';

Expand Down Expand Up @@ -48,6 +55,98 @@ class PricesPage extends StatelessWidget {
label: Text(appLocalizations.prices_add_a_price),
icon: const Icon(Icons.add),
),
bottomNavigationBar: ConsumerFilter<UserPreferences>(
buildWhen:
(UserPreferences? previousValue, UserPreferences currentValue) =>
previousValue?.shouldShowPricesFeedbackForm !=
currentValue.shouldShowPricesFeedbackForm,
builder: (
final BuildContext context,
final UserPreferences userPreferences,
_,
) {
/*if (!userPreferences.shouldShowPricesFeedbackForm) {
return EMPTY_WIDGET;
}*/

return const _PricesFeedbackForm();
},
),
);
}
}

class _PricesFeedbackForm extends StatelessWidget {
const _PricesFeedbackForm();

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context);
final SmoothColorsThemeExtension? themeExtension =
Theme.of(context).extension<SmoothColorsThemeExtension>();

return Ink(
width: double.infinity,
height: kBottomNavigationBarHeight,
color: themeExtension!.primaryBlack,
child: IconTheme(
data: const IconThemeData(color: Colors.white),
child: InkWell(
onTap: () async {
LaunchUrlHelper.launchURL(
'https://forms.gle/Vmh9SR3HhPpjMnVF7',
);
context.read<UserPreferences>().markPricesFeedbackFormAsCompleted();
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: MEDIUM_SPACE,
vertical: SMALL_SPACE,
),
child: Row(
children: <Widget>[
ExcludeSemantics(
child: Container(
decoration: BoxDecoration(
color: themeExtension.secondaryNormal,
shape: BoxShape.circle,
),
child: const AspectRatio(
aspectRatio: 1.0,
child: Lab(
color: Colors.white,
size: 13.0,
),
),
),
),
const SizedBox(width: SMALL_SPACE),
Expanded(
child: AutoSizeText(
appLocalizations.prices_feedback_form,
maxLines: 2,
style: const TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white,
),
),
),
const SizedBox(width: SMALL_SPACE),
InkWell(
customBorder: const CircleBorder(),
onTap: () => context
.read<UserPreferences>()
.markPricesFeedbackFormAsCompleted(),
child: const AspectRatio(
aspectRatio: 1.0,
child: CloseButtonIcon(),
),
)
],
),
),
),
),
);
}
}