diff --git a/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart b/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart index 7f6c09cf39e..483b7e3a37f 100644 --- a/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart +++ b/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart @@ -402,7 +402,13 @@ class _CountrySelectorBottomBar extends StatelessWidget { return EMPTY_WIDGET; } + final SmoothColorsThemeExtension? colors = + Theme.of(context).extension(); + return SmoothButtonsBar2( + animate: true, + backgroundColor: + context.darkTheme() ? colors!.primaryDark : colors!.primaryMedium, positiveButton: SmoothActionButton2( text: AppLocalizations.of(context).validate, icon: const icons.Arrow.right(), diff --git a/packages/smooth_app/lib/pages/product/add_basic_details_page.dart b/packages/smooth_app/lib/pages/product/add_basic_details_page.dart index 372a0ab101b..96d2bf307b0 100644 --- a/packages/smooth_app/lib/pages/product/add_basic_details_page.dart +++ b/packages/smooth_app/lib/pages/product/add_basic_details_page.dart @@ -241,7 +241,7 @@ class _AddBasicDetailsPageState extends State { child: Card(child: OwnerFieldInfo()), ), // in order to be able to scroll suggestions - SizedBox(height: MediaQuery.sizeOf(context).height), + const SizedBox(height: 150), ], ), ), diff --git a/packages/smooth_app/lib/pages/product/add_new_product_page.dart b/packages/smooth_app/lib/pages/product/add_new_product_page.dart index b5382d722a2..3a6491a32c4 100644 --- a/packages/smooth_app/lib/pages/product/add_new_product_page.dart +++ b/packages/smooth_app/lib/pages/product/add_new_product_page.dart @@ -27,6 +27,7 @@ import 'package:smooth_app/pages/product/product_image_swipeable_view.dart'; import 'package:smooth_app/pages/product/simple_input_page_helpers.dart'; import 'package:smooth_app/query/product_query.dart'; import 'package:smooth_app/widgets/smooth_scaffold.dart'; +import 'package:smooth_app/widgets/v2/smooth_buttons_bar.dart'; import 'package:smooth_app/widgets/will_pop_scope.dart'; /// "Create a product we couldn't find on the server" page. @@ -95,6 +96,7 @@ class _AddNewProductPageState extends State (widget.displayPictures ? 1 : 0); double get _progress => (_pageNumber + 1) / _totalPages; + bool get _isLastPage => (_pageNumber + 1) == _totalPages; ProductType? _inputProductType; late ColorScheme _colorScheme; @@ -272,14 +274,7 @@ class _AddNewProductPageState extends State ], ), ), - Card( - margin: EdgeInsets.zero, - elevation: 15.0, - child: SizedBox( - height: MediaQuery.sizeOf(context).height * 0.1, - child: _getButtons(), - ), - ) + _getButtons(), ], ), ), @@ -351,31 +346,56 @@ class _AddNewProductPageState extends State Widget _getButtons() { final AppLocalizations appLocalizations = AppLocalizations.of(context); - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ElevatedButton( - style: ElevatedButton.styleFrom( - minimumSize: Size(MediaQuery.sizeOf(context).width * 0.35, 40.0), - backgroundColor: _colorScheme.secondary, - shape: const RoundedRectangleBorder( - borderRadius: ROUNDED_BORDER_RADIUS, - ), - ), - onPressed: () async { - if (_pageNumber == 0) { - Navigator.of(context).maybePop(); - return; - } - if (widget.displayProductType && _pageNumber == 1) { + + return SmoothButtonsBar2( + negativeButton: SmoothActionButton2( + text: _pageNumber >= 1 + ? appLocalizations.previous_label + : appLocalizations.cancel, + onPressed: () async { + if (_pageNumber == 0) { + Navigator.of(context).maybePop(); + return; + } + if (widget.displayProductType && _pageNumber == 1) { + return showDialog( + context: context, + builder: (final BuildContext context) => SmoothAlertDialog( + title: appLocalizations.product_type_selection_title, + body: Text( + appLocalizations.product_type_selection_already( + upToDateProduct.productType!.getLabel(appLocalizations), + ), + ), + positiveAction: SmoothActionButton( + text: appLocalizations.okay, + onPressed: () => Navigator.of(context).pop(), + ), + ), + ); + } + _pageController.previousPage( + duration: SmoothAnimationsDuration.short, + curve: Curves.easeOut, + ); + }, + ), + positiveButton: SmoothActionButton2( + text: + _isLastPage ? appLocalizations.finish : appLocalizations.next_label, + onPressed: () async { + if (_isLastPage) { + Navigator.of(context).pop(); + return; + } + if (widget.displayProductType && _pageNumber == 0) { + if (_inputProductType == null) { return showDialog( context: context, builder: (final BuildContext context) => SmoothAlertDialog( title: appLocalizations.product_type_selection_title, body: Text( - appLocalizations.product_type_selection_already( - upToDateProduct.productType!.getLabel(appLocalizations), - ), + appLocalizations.product_type_selection_empty, ), positiveAction: SmoothActionButton( text: appLocalizations.okay, @@ -384,74 +404,19 @@ class _AddNewProductPageState extends State ), ); } - _pageController.previousPage( - duration: SmoothAnimationsDuration.short, - curve: Curves.easeOut, + await BackgroundTaskDetails.addTask( + Product(barcode: barcode)..productType = _inputProductType, + context: context, + stamp: BackgroundTaskDetailsStamp.productType, + productType: _inputProductType, ); - }, - child: Text( - _pageNumber >= 1 - ? appLocalizations.previous_label - : appLocalizations.cancel, - style: const TextStyle( - color: Colors.black, - fontSize: 20.0, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(width: BALANCED_SPACE), - ElevatedButton( - style: ElevatedButton.styleFrom( - minimumSize: Size(MediaQuery.sizeOf(context).width * 0.35, 40.0), - backgroundColor: DARK_BROWN_COLOR, - shape: const RoundedRectangleBorder( - borderRadius: ROUNDED_BORDER_RADIUS, - ), - ), - onPressed: () async { - if (_isLastPage) { - Navigator.of(context).pop(); - return; - } - if (widget.displayProductType && _pageNumber == 0) { - if (_inputProductType == null) { - return showDialog( - context: context, - builder: (final BuildContext context) => SmoothAlertDialog( - title: appLocalizations.product_type_selection_title, - body: Text( - appLocalizations.product_type_selection_empty, - ), - positiveAction: SmoothActionButton( - text: appLocalizations.okay, - onPressed: () => Navigator.of(context).pop(), - ), - ), - ); - } - await BackgroundTaskDetails.addTask( - Product(barcode: barcode)..productType = _inputProductType, - context: context, - stamp: BackgroundTaskDetailsStamp.productType, - productType: _inputProductType, - ); - } - _pageController.nextPage( - duration: SmoothAnimationsDuration.short, - curve: Curves.easeOut, - ); - }, - child: Text( - _isLastPage ? appLocalizations.finish : appLocalizations.next_label, - style: const TextStyle( - color: Colors.white, - fontSize: 20.0, - fontWeight: FontWeight.bold, - ), - ), - ) - ], + } + _pageController.nextPage( + duration: SmoothAnimationsDuration.short, + curve: Curves.easeOut, + ); + }, + ), ); } diff --git a/packages/smooth_app/lib/pages/product/common/product_buttons.dart b/packages/smooth_app/lib/pages/product/common/product_buttons.dart index 1007397d802..45e98663b4a 100644 --- a/packages/smooth_app/lib/pages/product/common/product_buttons.dart +++ b/packages/smooth_app/lib/pages/product/common/product_buttons.dart @@ -1,7 +1,6 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.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/widgets/v2/smooth_buttons_bar.dart'; /// A button bar containing two actions : Save and Cancel /// To ensure a fully working scroll, please set the [fixKeyboard] attribute in @@ -20,18 +19,14 @@ class ProductBottomButtonsBar extends StatelessWidget { Widget build(BuildContext context) { final AppLocalizations appLocalizations = AppLocalizations.of(context); - return SafeArea( - child: SmoothActionButtonsBar( - axis: Axis.horizontal, - padding: const EdgeInsets.symmetric(horizontal: LARGE_SPACE), - positiveAction: SmoothActionButton( - text: appLocalizations.save, - onPressed: onSave, - ), - negativeAction: SmoothActionButton( - text: appLocalizations.cancel, - onPressed: onCancel, - ), + return SmoothButtonsBar2( + positiveButton: SmoothActionButton2( + text: appLocalizations.save, + onPressed: onSave, + ), + negativeButton: SmoothActionButton2( + text: appLocalizations.cancel, + onPressed: onCancel, ), ); } diff --git a/packages/smooth_app/lib/pages/product/edit_ocr/edit_ocr_page.dart b/packages/smooth_app/lib/pages/product/edit_ocr/edit_ocr_page.dart index a01d40e418e..ed1b03e4351 100644 --- a/packages/smooth_app/lib/pages/product/edit_ocr/edit_ocr_page.dart +++ b/packages/smooth_app/lib/pages/product/edit_ocr/edit_ocr_page.dart @@ -28,6 +28,7 @@ import 'package:smooth_app/pages/product/product_image_button.dart'; import 'package:smooth_app/themes/smooth_theme_colors.dart'; import 'package:smooth_app/themes/theme_provider.dart'; import 'package:smooth_app/widgets/smooth_scaffold.dart'; +import 'package:smooth_app/widgets/v2/smooth_buttons_bar.dart'; part 'edit_ocr_main_action.dart'; @@ -397,13 +398,8 @@ class _EditOcrPageState extends State with UpToDateMixin { ), ), ), - SmoothActionButtonsBar( - axis: Axis.horizontal, - negativeAction: SmoothActionButton( - text: appLocalizations.cancel, - onPressed: () => Navigator.pop(context), - ), - positiveAction: SmoothActionButton( + SmoothButtonsBar2( + positiveButton: SmoothActionButton2( text: appLocalizations.save, onPressed: () async { await _updateText(); @@ -413,8 +409,11 @@ class _EditOcrPageState extends State with UpToDateMixin { Navigator.pop(context); }, ), + negativeButton: SmoothActionButton2( + text: appLocalizations.cancel, + onPressed: () => Navigator.pop(context), + ), ), - SizedBox(height: MediaQuery.paddingOf(context).bottom), ], ), ); diff --git a/packages/smooth_app/lib/pages/product/nutrition_page_loaded.dart b/packages/smooth_app/lib/pages/product/nutrition_page_loaded.dart index 2130c21b8e5..d4db8a5c69d 100644 --- a/packages/smooth_app/lib/pages/product/nutrition_page_loaded.dart +++ b/packages/smooth_app/lib/pages/product/nutrition_page_loaded.dart @@ -208,15 +208,19 @@ class _NutritionPageLoadedState extends State product: upToDateProduct, ), body: Padding( - padding: const EdgeInsets.symmetric( + padding: const EdgeInsetsDirectional.symmetric( horizontal: LARGE_SPACE, - vertical: SMALL_SPACE, ), child: Form( key: _formKey, child: Provider>.value( value: _focusNodes, - child: ListView(children: children), + child: ListView( + padding: const EdgeInsetsDirectional.symmetric( + vertical: SMALL_SPACE, + ), + children: children, + ), ), ), ), diff --git a/packages/smooth_app/lib/pages/product/simple_input_page.dart b/packages/smooth_app/lib/pages/product/simple_input_page.dart index 22f05b03e81..1ed7108e517 100644 --- a/packages/smooth_app/lib/pages/product/simple_input_page.dart +++ b/packages/smooth_app/lib/pages/product/simple_input_page.dart @@ -14,6 +14,8 @@ import 'package:smooth_app/pages/product/may_exit_page_helper.dart'; import 'package:smooth_app/pages/product/owner_field_info.dart'; import 'package:smooth_app/pages/product/simple_input_page_helpers.dart'; import 'package:smooth_app/pages/product/simple_input_widget.dart'; +import 'package:smooth_app/themes/smooth_theme_colors.dart'; +import 'package:smooth_app/themes/theme_provider.dart'; import 'package:smooth_app/widgets/smooth_scaffold.dart'; import 'package:smooth_app/widgets/will_pop_scope.dart'; @@ -111,8 +113,17 @@ class _SimpleInputPageState extends State { title: titles.join(', '), product: widget.product, ), + backgroundColor: context.lightTheme() + ? Theme.of(context) + .extension()! + .primaryLight + : null, body: Padding( - padding: const EdgeInsets.all(SMALL_SPACE), + padding: const EdgeInsetsDirectional.only( + top: SMALL_SPACE, + start: SMALL_SPACE, + end: SMALL_SPACE, + ), child: Scrollbar( child: ListView(children: simpleInputs), ), diff --git a/packages/smooth_app/lib/widgets/v2/smooth_buttons_bar.dart b/packages/smooth_app/lib/widgets/v2/smooth_buttons_bar.dart index fb633d808b6..6539da51ca9 100644 --- a/packages/smooth_app/lib/widgets/v2/smooth_buttons_bar.dart +++ b/packages/smooth_app/lib/widgets/v2/smooth_buttons_bar.dart @@ -11,11 +11,15 @@ class SmoothButtonsBar2 extends StatefulWidget { const SmoothButtonsBar2({ required this.positiveButton, this.negativeButton, + this.backgroundColor, + this.animate = false, super.key, }); final SmoothActionButton2 positiveButton; final SmoothActionButton2? negativeButton; + final Color? backgroundColor; + final bool animate; @override State createState() => _SmoothButtonsBar2State(); @@ -29,7 +33,7 @@ class _SmoothButtonsBar2State extends State void initState() { super.initState(); _controller = AnimationController( - duration: SmoothAnimationsDuration.brief, + duration: widget.animate ? SmoothAnimationsDuration.brief : Duration.zero, vsync: this, )..addListener(() => setState(() {})); @@ -86,13 +90,13 @@ class _SmoothButtonsBar2State extends State ), width: double.infinity, decoration: BoxDecoration( - color: - context.darkTheme() ? colors!.primaryDark : colors!.primaryMedium, - boxShadow: [ + color: widget.backgroundColor ?? + (context.lightTheme() ? Colors.white : colors!.primaryDark), + boxShadow: const [ BoxShadow( - color: context.darkTheme() ? Colors.white10 : Colors.black12, + color: Colors.black12, blurRadius: 6.0, - offset: const Offset(0.0, -4.0), + offset: Offset(0.0, -4.0), ), ], ), @@ -146,10 +150,49 @@ class _SmoothPositiveButton2 extends StatelessWidget { final SmoothColorsThemeExtension colors = Theme.of(context).extension()!; + return _SmoothBaseButton2( + data: data, + backgroundColor: colors.primaryBlack, + foregroundColor: Colors.white, + ); + } +} + +class _SmoothNegativeButton2 extends StatelessWidget { + const _SmoothNegativeButton2({required this.data}); + + final SmoothActionButton2 data; + + @override + Widget build(BuildContext context) { + final SmoothColorsThemeExtension colors = + Theme.of(context).extension()!; + + return _SmoothBaseButton2( + data: data, + backgroundColor: colors.primaryMedium, + foregroundColor: colors.primaryDark, + ); + } +} + +class _SmoothBaseButton2 extends StatelessWidget { + const _SmoothBaseButton2({ + required this.data, + required this.backgroundColor, + required this.foregroundColor, + }); + + final SmoothActionButton2 data; + final Color backgroundColor; + final Color foregroundColor; + + @override + Widget build(BuildContext context) { return TextButton( style: TextButton.styleFrom( - backgroundColor: colors.primaryBlack, - foregroundColor: Colors.white, + backgroundColor: backgroundColor, + foregroundColor: foregroundColor, shape: const RoundedRectangleBorder( borderRadius: CIRCULAR_BORDER_RADIUS, ), @@ -189,15 +232,3 @@ class _SmoothPositiveButton2 extends StatelessWidget { ); } } - -// TODO(g123k): Not implemented -class _SmoothNegativeButton2 extends StatelessWidget { - const _SmoothNegativeButton2({required this.data}); - - final SmoothActionButton2 data; - - @override - Widget build(BuildContext context) { - throw Exception('Not implemented!'); - } -} diff --git a/packages/smooth_app/macos/Podfile.lock b/packages/smooth_app/macos/Podfile.lock index fd1b493991f..a42ab3d778a 100644 --- a/packages/smooth_app/macos/Podfile.lock +++ b/packages/smooth_app/macos/Podfile.lock @@ -125,7 +125,7 @@ SPEC CHECKSUMS: sentry_flutter: 0eb93e5279eb41e2392212afe1ccd2fecb4f8cbe share_plus: 1fa619de8392a4398bfaf176d441853922614e89 shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 - sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13 + sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 webview_flutter_wkwebview: 0982481e3d9c78fd5c6f62a002fcd24fc791f1e4