From b1005cebd88eeebec73d38f1c2950e7ad062f367 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Thu, 7 Nov 2024 14:41:57 +0100 Subject: [PATCH] feat: Some enhancements for the Bottom Sheet (#5803) * Enhance Smooth Bottom Sheet * Fix * Remove user_picture_source_select translation --- packages/smooth_app/ios/Podfile.lock | 2 +- .../bottom_sheets/smooth_bottom_sheet.dart | 60 ++++++++++++++----- packages/smooth_app/lib/l10n/app_en.arb | 6 +- .../user_preferences_image_source.dart | 4 +- .../preferences/user_preferences_widgets.dart | 11 +++- .../product_page/new_product_footer.dart | 8 +-- packages/smooth_app/macos/Podfile.lock | 6 +- packages/smooth_app/pubspec.lock | 4 +- 8 files changed, 65 insertions(+), 36 deletions(-) diff --git a/packages/smooth_app/ios/Podfile.lock b/packages/smooth_app/ios/Podfile.lock index ba40bf624b9..2f89895cc3a 100644 --- a/packages/smooth_app/ios/Podfile.lock +++ b/packages/smooth_app/ios/Podfile.lock @@ -310,4 +310,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: e840dd57ba2b03bcb6fdba293a27c5f82151a80a -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/packages/smooth_app/lib/generic_lib/bottom_sheets/smooth_bottom_sheet.dart b/packages/smooth_app/lib/generic_lib/bottom_sheets/smooth_bottom_sheet.dart index 07b86f0722c..80608dfec81 100644 --- a/packages/smooth_app/lib/generic_lib/bottom_sheets/smooth_bottom_sheet.dart +++ b/packages/smooth_app/lib/generic_lib/bottom_sheets/smooth_bottom_sheet.dart @@ -98,7 +98,7 @@ class SmoothModalSheetHeader extends StatelessWidget implements SizeWidget { this.backgroundColor, }); - static const double MIN_HEIGHT = 50.0; + static const double MIN_HEIGHT = 55.0; final String title; final SizeWidget? prefix; @@ -108,13 +108,15 @@ class SmoothModalSheetHeader extends StatelessWidget implements SizeWidget { @override Widget build(BuildContext context) { - final Color primaryColor = Theme.of(context).primaryColor; + final Color primaryColor = + Theme.of(context).extension()!.primaryDark; + final Color tintColor = foregroundColor ?? Colors.white; return IconTheme( - data: IconThemeData(color: foregroundColor), + data: IconThemeData(color: tintColor), child: Container( height: suffix is SmoothModalSheetHeaderButton ? double.infinity : null, - color: backgroundColor ?? primaryColor.withOpacity(0.2), + color: backgroundColor ?? primaryColor, constraints: const BoxConstraints(minHeight: MIN_HEIGHT), padding: EdgeInsetsDirectional.only( start: (prefix?.requiresPadding == true ? 0 : VERY_LARGE_SPACE), @@ -143,7 +145,7 @@ class SmoothModalSheetHeader extends StatelessWidget implements SizeWidget { style: Theme.of(context).textTheme.titleLarge?.copyWith( fontWeight: FontWeight.bold, fontSize: 18.0, - color: foregroundColor, + color: tintColor, ), ), ), @@ -266,29 +268,55 @@ class SmoothModalSheetHeaderCloseButton extends StatelessWidget const SmoothModalSheetHeaderCloseButton({ this.semanticsOrder, this.addPadding, + this.circled = true, }); final double? semanticsOrder; final bool? addPadding; + final bool circled; @override Widget build(BuildContext context) { + final Widget icon; + + if (circled == true) { + icon = Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: IconTheme.of(context).color ?? Colors.white, + width: 1.5, + ), + ), + margin: const EdgeInsets.all(VERY_SMALL_SPACE), + padding: const EdgeInsets.all(SMALL_SPACE), + child: const icons.Close( + size: 13.0, + ), + ); + } else { + icon = const Padding( + padding: EdgeInsets.all(MEDIUM_SPACE), + child: icons.Close( + size: 15.0, + ), + ); + } + return Semantics( value: MaterialLocalizations.of(context).closeButtonTooltip, button: true, excludeSemantics: true, sortKey: OrdinalSortKey(semanticsOrder ?? 2.0), - child: Tooltip( - message: MaterialLocalizations.of(context).closeButtonTooltip, - enableFeedback: true, - child: InkWell( - onTap: () => Navigator.of(context).pop(), - customBorder: const CircleBorder(), - child: const Padding( - padding: EdgeInsets.all(MEDIUM_SPACE), - child: icons.Close( - size: 15.0, - ), + child: Padding( + padding: const EdgeInsetsDirectional.only(end: SMALL_SPACE), + child: Tooltip( + message: MaterialLocalizations.of(context).closeButtonTooltip, + enableFeedback: true, + child: InkWell( + onTap: () => Navigator.of(context).pop(), + customBorder: const CircleBorder(), + child: icon, ), ), ), diff --git a/packages/smooth_app/lib/l10n/app_en.arb b/packages/smooth_app/lib/l10n/app_en.arb index 7daf6dde94b..6d6f024366e 100644 --- a/packages/smooth_app/lib/l10n/app_en.arb +++ b/packages/smooth_app/lib/l10n/app_en.arb @@ -2533,9 +2533,9 @@ "@user_picture_source_remember": { "description": "Checkbox label when select a picture source" }, - "user_picture_source_select": "Select each time", - "@user_picture_source_select": { - "description": "Choice of selecting the picture source each time" + "user_picture_source_ask": "Ask each time", + "@user_picture_source_ask": { + "description": "Choice of asking the picture source every time" }, "robotoff_continue": "Continue", "@robotoff_continue": { diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_image_source.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_image_source.dart index a2177e25eb8..bdfaf558127 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_image_source.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_image_source.dart @@ -15,7 +15,7 @@ class UserPreferencesImageSource extends StatelessWidget { return UserPreferencesItemSimple( labels: [ appLocalizations.choose_image_source_title, - appLocalizations.user_picture_source_select, + appLocalizations.user_picture_source_ask, appLocalizations.settings_app_camera, appLocalizations.gallery_source_label, ], @@ -35,7 +35,7 @@ class UserPreferencesImageSource extends StatelessWidget { (_) => const Icon(Icons.image), ], labels: [ - appLocalizations.user_picture_source_select, + appLocalizations.user_picture_source_ask, appLocalizations.settings_app_camera, appLocalizations.gallery_source_label, ], diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_widgets.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_widgets.dart index a5cdbdf33cd..37705b4fc43 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_widgets.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_widgets.dart @@ -6,6 +6,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/pages/preferences/user_preferences_item.dart'; import 'package:smooth_app/themes/smooth_theme_colors.dart'; +import 'package:smooth_app/themes/theme_provider.dart'; /// A dashed line class UserPreferencesListItemDivider extends StatelessWidget { @@ -443,7 +444,13 @@ class _ChoiceItem extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - final Color? selectedColor = selected ? theme.primaryColor : null; + final SmoothColorsThemeExtension extension = + theme.extension()!; + final Color? selectedColor = selected + ? context.lightTheme() + ? extension.primaryMedium + : extension.primaryDark + : null; return Semantics( value: label, @@ -451,7 +458,7 @@ class _ChoiceItem extends StatelessWidget { button: true, excludeSemantics: true, child: Ink( - color: selectedColor?.withOpacity(0.1) ?? Colors.transparent, + color: selectedColor ?? Colors.transparent, child: Column( children: [ ListTile( diff --git a/packages/smooth_app/lib/pages/product/product_page/new_product_footer.dart b/packages/smooth_app/lib/pages/product/product_page/new_product_footer.dart index 19f91e8ab18..388deabd097 100644 --- a/packages/smooth_app/lib/pages/product/product_page/new_product_footer.dart +++ b/packages/smooth_app/lib/pages/product/product_page/new_product_footer.dart @@ -118,19 +118,13 @@ class _ProductAddToListButton extends StatelessWidget { Future _editList(BuildContext context, Product product) async { final AppLocalizations appLocalizations = AppLocalizations.of(context); - final SmoothColorsThemeExtension? extension = - Theme.of(context).extension(); showSmoothDraggableModalSheet( context: context, header: SmoothModalSheetHeader( - backgroundColor: extension!.primaryDark, - foregroundColor: Colors.white, prefix: const SmoothModalSheetHeaderPrefixIndicator(), title: appLocalizations.user_list_title, - suffix: const SmoothModalSheetHeaderCloseButton( - addPadding: true, - ), + suffix: const SmoothModalSheetHeaderCloseButton(), ), bodyBuilder: (BuildContext context) => AddProductToListContainer( barcode: product.barcode!, diff --git a/packages/smooth_app/macos/Podfile.lock b/packages/smooth_app/macos/Podfile.lock index 4321f61a951..121461bdca5 100644 --- a/packages/smooth_app/macos/Podfile.lock +++ b/packages/smooth_app/macos/Podfile.lock @@ -117,13 +117,13 @@ SPEC CHECKSUMS: FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 in_app_review: a850789fad746e89bce03d4aeee8078b45a53fd0 mobile_scanner: 54ceceae0c8da2457e26a362a6be5c61154b1829 - package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c + package_info_plus: f5790acc797bf17c3e959e9d6cf162cc68ff7523 path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 ReachabilitySwift: 7f151ff156cea1481a8411701195ac6a984f4979 rive_common: cf5ab646aa576b2d742d0e2d528126fbf032c856 Sentry: f8374b5415bc38dfb5645941b3ae31230fbeae57 sentry_flutter: 0eb93e5279eb41e2392212afe1ccd2fecb4f8cbe - share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf + share_plus: fd717ef89a2801d3491e737630112b80c310640e shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13 url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 @@ -131,4 +131,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 0d3963a09fc94f580682bd88480486da345dc3f0 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/packages/smooth_app/pubspec.lock b/packages/smooth_app/pubspec.lock index 2835d86b890..6c77f8dcc52 100644 --- a/packages/smooth_app/pubspec.lock +++ b/packages/smooth_app/pubspec.lock @@ -696,10 +696,10 @@ packages: dependency: "direct main" description: name: flutter_svg - sha256: "1b7723a814d84fb65869ea7115cdb3ee7c3be5a27a755c1ec60e049f6b9fcbb2" + sha256: de82e6bf958cec7190fbc1c5298282c851228e35ae2b14e2b103e7f777818c64 url: "https://pub.dev" source: hosted - version: "2.0.11" + version: "2.0.13" flutter_test: dependency: "direct dev" description: flutter