Skip to content

Commit

Permalink
feat: Convert Privacy warning to bottom sheet (#6213)
Browse files Browse the repository at this point in the history
* Feat: Convert Privacy warning to bottom sheet

* Modify: Change to Okay/ Reject button

* Update: Design as per reuirement

* Fix: Arb file formatting

* Fix: Code Formatting on arb Files

* Fix: code formatting on arb file

* fix: rename warning_message

* Fix: update sync message in bottomsheet with localization

* Fix: Mege conflict
  • Loading branch information
Afroz-Shaikh authored Jan 20, 2025
1 parent 0e45c57 commit dfdda4e
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 15 deletions.
9 changes: 8 additions & 1 deletion packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2233,8 +2233,15 @@
"prices_proof_mandatory": "You need to select a proof!",
"prices_add_validation_error": "Validation error",
"prices_privacy_warning_title": "Privacy warning",
"prices_privacy_warning_message": "Prices will be public, along with the store they refer to.\nThat might allow people who know about your Open Food Facts pseudonym to:\n* infer in which area you live\n* know what you are buying\nIf you are uneasy with that, please change your pseudonym, or create a new Open Food Facts account and log into the app with it.",
"prices_unknown_product": "Unknown product",
"prices_privacy_warning_title": "Privacy warning",
"prices_unknown_product": "Unknown product",
"prices_privacy_warning_main_message": "Prices **will be public**, along with the store they refer to.\n\nThat might allow people who know about your Open Food Facts pseudonym to:\n",
"prices_privacy_warning_message_bullet_1": "Infer in which area you live",
"prices_privacy_warning_message_bullet_2": "Know what you are buying",
"prices_privacy_warning_sub_message": "If you are uneasy with that, please change your pseudonym, or create a new Open Food Facts account and log into the app with it.",
"i_refuse": "I refuse",
"i_accept": "I accept",
"prices_currency_change_proposal_title": "Change the currency?",
"prices_currency_change_proposal_message": "Your current currency is **{currency}**. Would you like to change it to **{newCurrency}**?",
"@prices_currency_change_proposal_message": {
Expand Down
95 changes: 81 additions & 14 deletions packages/smooth_app/lib/pages/prices/product_price_add_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:smooth_app/pages/prices/price_model.dart';
import 'package:smooth_app/pages/prices/price_proof_card.dart';
import 'package:smooth_app/pages/product/common/product_refresher.dart';
import 'package:smooth_app/pages/product/may_exit_page_helper.dart';
import 'package:smooth_app/resources/app_icons.dart' as app_icons;
import 'package:smooth_app/themes/smooth_theme.dart';
import 'package:smooth_app/themes/smooth_theme_colors.dart';
import 'package:smooth_app/themes/theme_provider.dart';
Expand Down Expand Up @@ -236,23 +237,89 @@ class _ProductPriceAddPageState extends State<ProductPriceAddPage>

Future<bool?> _doesAcceptWarning({required final bool justInfo}) async {
final AppLocalizations appLocalizations = AppLocalizations.of(context);
return showDialog<bool>(
const Color color = Color(0xFFB81D1D);
final SmoothColorsThemeExtension extension =
context.extension<SmoothColorsThemeExtension>();
return showSmoothListOfChoicesModalSheet<bool>(
safeArea: true,
context: context,
builder: (final BuildContext context) => SmoothAlertDialog(
title: appLocalizations.prices_privacy_warning_title,
actionsAxis: Axis.vertical,
body: Text(appLocalizations.prices_privacy_warning_message),
positiveAction: SmoothActionButton(
text: appLocalizations.okay,
onPressed: () => Navigator.of(context).pop(true),
headerBackgroundColor: color,
header: Padding(
padding: const EdgeInsetsDirectional.symmetric(
horizontal: LARGE_SPACE,
vertical: MEDIUM_SPACE,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
TextWithBoldParts(
text: appLocalizations.prices_privacy_warning_main_message,
textStyle: Theme.of(context).textTheme.bodyLarge?.copyWith(
fontWeight: FontWeight.w600,
),
),
_buildBulletPoint(
appLocalizations.prices_privacy_warning_message_bullet_1,
context,
),
const SizedBox(height: MEDIUM_SPACE),
_buildBulletPoint(
appLocalizations.prices_privacy_warning_message_bullet_2,
context,
),
const SizedBox(height: MEDIUM_SPACE),
Text(
appLocalizations.prices_privacy_warning_sub_message,
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
fontWeight: FontWeight.w600,
),
),
],
),
negativeAction: justInfo
? null
: SmoothActionButton(
text: appLocalizations.cancel,
onPressed: () => Navigator.of(context).pop(),
),
),
labels: <String>[
appLocalizations.i_accept,
appLocalizations.i_refuse,
],
values: <bool>[
true,
false,
],
prefixIcons: <Widget>[
Icon(Icons.check_circle_rounded, color: extension.success),
Icon(Icons.cancel_rounded, color: extension.error),
],
title: appLocalizations.prices_privacy_warning_title,
);
}

Widget _buildBulletPoint(String text, BuildContext context) {
const double defaultIconSize = 7.0;
const double radius = 10.0;
final SmoothColorsThemeExtension extension =
context.extension<SmoothColorsThemeExtension>();
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(width: MEDIUM_SPACE),
CircleAvatar(
radius: radius,
backgroundColor: extension.greyLight,
child: const app_icons.Arrow.right(
color: Colors.white,
size: defaultIconSize,
),
),
const SizedBox(width: SMALL_SPACE),
Expanded(
child: Text(
text,
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
fontWeight: FontWeight.w600,
),
),
),
],
);
}

Expand Down

0 comments on commit dfdda4e

Please sign in to comment.