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

fix: bug "Smooth Simple Button" in "SmoothAlertDialogue". issue #993 #994

Merged
Merged
Show file tree
Hide file tree
Changes from 14 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 @@ -6,7 +6,7 @@ import 'package:smooth_app/database/barcode_product_query.dart';
import 'package:smooth_app/database/dao_product.dart';
import 'package:smooth_app/database/local_database.dart';
import 'package:smooth_app/widgets/loading_dialog.dart';
import 'package:smooth_ui_library/buttons/smooth_simple_button.dart';
import 'package:smooth_ui_library/buttons/smooth_action_button.dart';
import 'package:smooth_ui_library/dialogs/smooth_alert_dialog.dart';

/// Dialog helper for product barcode search
Expand Down Expand Up @@ -53,12 +53,12 @@ class ProductDialogHelper {
? AppLocalizations.of(context)!.could_not_refresh
: '${AppLocalizations.of(context)!.no_product_found}: $barcode',
),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
text: AppLocalizations.of(context)!.close,
onPressed: () => Navigator.pop(context),
),
SmoothSimpleButton(
SmoothActionButton(
text: AppLocalizations.of(context)!.contribute,

onPressed: () => Navigator.pop(
Expand All @@ -79,8 +79,8 @@ class ProductDialogHelper {
builder: (BuildContext context) => SmoothAlertDialog(
close: false,
body: getErrorMessage(message),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
text: AppLocalizations.of(context)!.close,
onPressed: () => Navigator.pop(context),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:smooth_app/data_models/product_list.dart';
import 'package:smooth_app/database/dao_product_list.dart';
import 'package:smooth_ui_library/buttons/smooth_simple_button.dart';
import 'package:smooth_ui_library/buttons/smooth_action_button.dart';
import 'package:smooth_ui_library/dialogs/smooth_alert_dialog.dart';

class ProductListDialogHelper {
Expand All @@ -28,12 +28,12 @@ class ProductListDialogHelper {
builder: (BuildContext context) => SmoothAlertDialog(
close: false,
body: Text(AppLocalizations.of(context)!.really_clear),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
text: AppLocalizations.of(context)!.no,
onPressed: () => Navigator.pop(context, false),
),
SmoothSimpleButton(
SmoothActionButton(
text: AppLocalizations.of(context)!.yes,
onPressed: () async {
await daoProductList.clear(productList);
Expand Down
10 changes: 5 additions & 5 deletions packages/smooth_app/lib/pages/product/nutrition_page_loaded.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:openfoodfacts/utils/UnitHelper.dart';
import 'package:smooth_app/database/product_query.dart';
import 'package:smooth_app/widgets/loading_dialog.dart';
import 'package:smooth_ui_library/buttons/smooth_simple_button.dart';
import 'package:smooth_ui_library/buttons/smoot_action_button.dart';
teolemon marked this conversation as resolved.
Show resolved Hide resolved
import 'package:smooth_ui_library/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_ui_library/util/ui_helpers.dart';

Expand Down Expand Up @@ -501,8 +501,8 @@ class _NutritionPageLoadedState extends State<NutritionPageLoaded> {
leading: const Icon(Icons.error),
title: Text(status.error!),
),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
text: AppLocalizations.of(context)!.okay,
onPressed: () => Navigator.of(context).pop(),
),
Expand All @@ -515,8 +515,8 @@ class _NutritionPageLoadedState extends State<NutritionPageLoaded> {
context: context,
builder: (BuildContext context) => SmoothAlertDialog(
body: Text(AppLocalizations.of(context)!.nutrition_page_update_done),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
text: AppLocalizations.of(context)!.okay,
onPressed: () => Navigator.of(context).pop()),
],
Expand Down
10 changes: 5 additions & 5 deletions packages/smooth_app/lib/pages/user_management/sign_up_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:smooth_app/helpers/user_management_helper.dart';
import 'package:smooth_app/widgets/loading_dialog.dart';
import 'package:smooth_ui_library/buttons/smooth_simple_button.dart';
import 'package:smooth_ui_library/buttons/smooth_action_button.dart';
import 'package:smooth_ui_library/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_ui_library/widgets/smooth_text_form_field.dart';
import 'package:url_launcher/url_launcher.dart';
Expand Down Expand Up @@ -300,8 +300,8 @@ class _SignUpPageState extends State<SignUpPage> {
leading: const Icon(Icons.error),
title: Text(status.error!),
),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
text: AppLocalizations.of(context)!.okay,
onPressed: () => Navigator.of(context).pop(),
),
Expand All @@ -315,8 +315,8 @@ class _SignUpPageState extends State<SignUpPage> {
context: context,
builder: (BuildContext context) => SmoothAlertDialog(
body: Text(AppLocalizations.of(context)!.sign_up_page_action_ok),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
text: AppLocalizations.of(context)!.okay,
onPressed: () => Navigator.of(context).pop()),
],
Expand Down
8 changes: 4 additions & 4 deletions packages/smooth_app/lib/pages/user_preferences_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:smooth_app/helpers/user_management_helper.dart';
import 'package:smooth_app/pages/abstract_user_preferences.dart';
import 'package:smooth_app/pages/onboarding/country_selector.dart';
import 'package:smooth_app/pages/user_management/login_page.dart';
import 'package:smooth_ui_library/buttons/smooth_simple_button.dart';
import 'package:smooth_ui_library/buttons/smooth_action_button.dart';
import 'package:smooth_ui_library/dialogs/smooth_alert_dialog.dart';

/// Collapsed/expanded display of profile for the preferences page.
Expand Down Expand Up @@ -165,16 +165,16 @@ class UserPreferencesProfile extends AbstractUserPreferences {
body: Text(
localizations.sign_out_confirmation,
),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
text: localizations.yes,
onPressed: () async {
UserManagementHelper.logout();
Navigator.pop(context);
setState(() {});
},
),
SmoothSimpleButton(
SmoothActionButton(
text: localizations.no,
onPressed: () {
Navigator.pop(context);
Expand Down
8 changes: 4 additions & 4 deletions packages/smooth_app/lib/pages/user_preferences_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'package:smooth_app/pages/abstract_user_preferences.dart';
import 'package:smooth_app/themes/smooth_theme.dart';
import 'package:smooth_app/themes/theme_provider.dart';
import 'package:smooth_app/views/bottom_sheet_views/user_contribution_view.dart';
import 'package:smooth_ui_library/buttons/smooth_action_button.dart';
import 'package:smooth_ui_library/buttons/smooth_main_button.dart';
import 'package:smooth_ui_library/buttons/smooth_simple_button.dart';
import 'package:smooth_ui_library/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_ui_library/widgets/smooth_list_tile.dart';
import 'package:smooth_ui_library/widgets/smooth_toggle.dart';
Expand Down Expand Up @@ -192,8 +192,8 @@ class UserPreferencesSettings extends AbstractUserPreferences {
)
],
),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
onPressed: () async {
showLicensePage(
context: context,
Expand All @@ -208,7 +208,7 @@ class UserPreferencesSettings extends AbstractUserPreferences {
text: appLocalizations.licenses,
minWidth: 100,
),
SmoothSimpleButton(
SmoothActionButton(
onPressed: () =>
Navigator.of(context, rootNavigator: true).pop(),
text: appLocalizations.okay,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:http/http.dart' as http;
import 'package:smooth_app/data_models/github_contributors_model.dart';
import 'package:smooth_app/helpers/launch_url_helper.dart';
import 'package:smooth_ui_library/buttons/smooth_simple_button.dart';
import 'package:smooth_ui_library/buttons/smooth_action_button.dart';
import 'package:smooth_ui_library/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_ui_library/widgets/smooth_list_tile.dart';

Expand Down Expand Up @@ -113,8 +113,8 @@ class UserContributionView extends StatelessWidget {
),
],
),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
onPressed: () {
Navigator.of(context, rootNavigator: true).pop('dialog');
},
Expand Down Expand Up @@ -174,8 +174,8 @@ class UserContributionView extends StatelessWidget {
)
],
),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
onPressed: () => Navigator.pop(context),
text: AppLocalizations.of(context)!.okay,
minWidth: 100,
Expand All @@ -202,8 +202,8 @@ class UserContributionView extends StatelessWidget {
),
],
),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
onPressed: () => LaunchUrlHelper.launchURL(
'https://translate.openfoodfacts.org/', false),
text:
Expand Down Expand Up @@ -272,8 +272,8 @@ class UserContributionView extends StatelessWidget {
return const CircularProgressIndicator();
},
),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
onPressed: () => LaunchUrlHelper.launchURL(
'https://github.com/openfoodfacts/smooth-app', false),
text: AppLocalizations.of(context)!.contribute,
Expand Down
6 changes: 3 additions & 3 deletions packages/smooth_app/lib/widgets/loading_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:smooth_ui_library/buttons/smooth_simple_button.dart';
import 'package:smooth_ui_library/buttons/smooth_action_button.dart';
import 'package:smooth_ui_library/dialogs/smooth_alert_dialog.dart';

/// Dialog with a stop button, while a future is running.
Expand Down Expand Up @@ -62,8 +62,8 @@ class LoadingDialog<T> {
leading: const CircularProgressIndicator(),
title: Text(title),
),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
actions: <SmoothActionButton>[
SmoothActionButton(
text: AppLocalizations.of(context)!.stop,
onPressed: () => _popDialog(context, null),
),
Expand Down
37 changes: 37 additions & 0 deletions packages/smooth_ui_library/lib/buttons/smooth_action_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';

class SmoothActionButton extends StatelessWidget {
const SmoothActionButton({
required this.text,
required this.onPressed,
this.minWidth = 15,
this.height = 20,
});

final String text;
final VoidCallback onPressed;
final double minWidth;
final double height;

@override
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(),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:smooth_ui_library/buttons/smooth_simple_button.dart';
import 'package:smooth_ui_library/buttons/smooth_action_button.dart';

///
/// Open by calling
Expand All @@ -25,7 +25,7 @@ class SmoothAlertDialog extends StatelessWidget {
final bool close;
final double? height;
final Widget body;
final List<SmoothSimpleButton>? actions;
final List<SmoothActionButton>? actions;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -118,6 +118,6 @@ class SmoothAlertDialog extends StatelessWidget {
/// final String title;
/// final bool close;
/// final Widget body;
/// final List<SmoothSimpleButton> actions;
/// final List<SmoothActionButton> actions;
/// final double height;
///