From ff8858e27d561b368a31a94d194c998d82049629 Mon Sep 17 00:00:00 2001 From: Dannylo Dangel Date: Mon, 18 Oct 2021 08:27:01 -0300 Subject: [PATCH] fix: SmoothSimpleButton reactive to schema #591 (#624) * fix: SmoothSimpleButton reactive to schema #591 * chore: remove important flag * fix: remove important flag calls on smooth buttoncalls * fix: remove important flag call * Revert "chore: remove important flag" This reverts commit 37fa220c5c9fc0fdca95be65d2db503a66512bf5. * fix: review changes Co-authored-by: dannylo-gaivota <80546050+dannylo-gaivota@users.noreply.github.com> --- .../product/common/product_dialog_helper.dart | 4 +- .../common/product_list_dialog_helper.dart | 44 +++++++------------ .../lib/buttons/smooth_simple_button.dart | 42 ++++++++---------- 3 files changed, 37 insertions(+), 53 deletions(-) diff --git a/packages/smooth_app/lib/pages/product/common/product_dialog_helper.dart b/packages/smooth_app/lib/pages/product/common/product_dialog_helper.dart index 05789bf1781..03304bb510d 100644 --- a/packages/smooth_app/lib/pages/product/common/product_dialog_helper.dart +++ b/packages/smooth_app/lib/pages/product/common/product_dialog_helper.dart @@ -74,7 +74,6 @@ class ProductDialogHelper { actions: [ SmoothSimpleButton( text: AppLocalizations.of(context)!.stop, - important: false, onPressed: () => _popSearchingDialog(null), ), ], @@ -93,12 +92,11 @@ class ProductDialogHelper { actions: [ SmoothSimpleButton( text: AppLocalizations.of(context)!.close, - important: false, onPressed: () => Navigator.pop(context), ), SmoothSimpleButton( text: AppLocalizations.of(context)!.contribute, - important: true, + onPressed: () => Navigator.pop( context), // TODO(monsieurtanuki): to be implemented ), diff --git a/packages/smooth_app/lib/pages/product/common/product_list_dialog_helper.dart b/packages/smooth_app/lib/pages/product/common/product_list_dialog_helper.dart index a439bb3ad5d..59ab4ea6c78 100644 --- a/packages/smooth_app/lib/pages/product/common/product_list_dialog_helper.dart +++ b/packages/smooth_app/lib/pages/product/common/product_list_dialog_helper.dart @@ -32,12 +32,10 @@ class ProductListDialogHelper { actions: [ SmoothSimpleButton( text: AppLocalizations.of(context)!.no, - important: false, onPressed: () => Navigator.pop(context, false), ), SmoothSimpleButton( text: AppLocalizations.of(context)!.yes, - important: true, onPressed: () async { await daoProductList.delete(productList); Navigator.pop(context, true); @@ -94,10 +92,8 @@ class ProductListDialogHelper { ), actions: [ SmoothSimpleButton( - text: appLocalizations.cancel, - onPressed: () => Navigator.pop(context, null), - important: false, - ), + text: appLocalizations.cancel, + onPressed: () => Navigator.pop(context, null)), SmoothSimpleButton( text: appLocalizations.okay, onPressed: () async { @@ -108,7 +104,6 @@ class ProductListDialogHelper { await daoProductList.put(newProductList!); Navigator.pop(context, newProductList); }, - important: true, ), ], ), @@ -166,26 +161,22 @@ class ProductListDialogHelper { ), actions: [ SmoothSimpleButton( - text: appLocalizations.cancel, - onPressed: () => Navigator.pop(context, null), - important: false, - ), + text: appLocalizations.cancel, + onPressed: () => Navigator.pop(context, null)), SmoothSimpleButton( - text: AppLocalizations.of(context)!.okay, - onPressed: () async { - if (!formKey.currentState!.validate()) { - return; - } - if (!await daoProductList.rename( - productList, newProductList!.parameters)) { - // TODO(monsieurtanuki): unexpected, but do something! - return; - } - await daoProductList.get(newProductList!); - Navigator.pop(context, newProductList); - }, - important: true, - ), + text: AppLocalizations.of(context)!.okay, + onPressed: () async { + if (!formKey.currentState!.validate()) { + return; + } + if (!await daoProductList.rename( + productList, newProductList!.parameters)) { + // TODO(monsieurtanuki): unexpected, but do something! + return; + } + await daoProductList.get(newProductList!); + Navigator.pop(context, newProductList); + }), ], ), ); @@ -239,7 +230,6 @@ class ProductListDialogHelper { SmoothSimpleButton( text: appLocalizations.cancel, onPressed: () => Navigator.pop(context, false), - important: false, ), ], ), diff --git a/packages/smooth_ui_library/lib/buttons/smooth_simple_button.dart b/packages/smooth_ui_library/lib/buttons/smooth_simple_button.dart index 19957297a03..f81849ff9a6 100644 --- a/packages/smooth_ui_library/lib/buttons/smooth_simple_button.dart +++ b/packages/smooth_ui_library/lib/buttons/smooth_simple_button.dart @@ -6,36 +6,32 @@ class SmoothSimpleButton extends StatelessWidget { required this.onPressed, this.minWidth = 15, this.height = 20, - this.important = true, }); final String text; final VoidCallback onPressed; final double minWidth; final double height; - final bool important; @override - Widget build(BuildContext context) => MaterialButton( - color: important - ? Theme.of(context).colorScheme.secondary - : Theme.of(context).colorScheme.onSecondary, - child: Padding( - padding: const EdgeInsets.all(10), - child: Text( - text, - style: Theme.of(context).textTheme.bodyText2!.copyWith( - color: important - ? Theme.of(context).colorScheme.onSecondary - : Theme.of(context).colorScheme.secondary, - ), - ), + Widget build(BuildContext context) { + final ThemeData themeData = Theme.of(context); + return MaterialButton( + color: themeData.colorScheme.primary, + child: Padding( + padding: const EdgeInsets.all(10), + child: Text( + text, + style: themeData.textTheme.bodyText2! + .copyWith(color: themeData.colorScheme.onPrimary), ), - height: height, - minWidth: minWidth, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(15.0)), - ), - onPressed: () => onPressed(), - ); + ), + height: height, + minWidth: minWidth, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(15.0)), + ), + onPressed: () => onPressed(), + ); + } }