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

feat: Horizontal buttons for Dialogs #2626

Merged
merged 5 commits into from
Aug 18, 2022

Conversation

g123k
Copy link
Collaborator

@g123k g123k commented Jul 18, 2022

Fix issues introduced with #2587, but also:

  • Supports smaller screens by reducing the margins/paddings and uses by default a vertical axis for this kind of device
  • Add Tooltips for the contributors' grid (will improve accessibility)
  • Improved scrollbars / ClipRect
  • Fix an overflow for the empty user lists' screen

Will fix #2622

@g123k g123k self-assigned this Jul 18, 2022
@g123k
Copy link
Collaborator Author

g123k commented Jul 19, 2022

Implementing golden tests takes longer than expected, especially because I have to mock both SQLite and Hive.
Will Hive soon be removed?

@monsieurtanuki
Copy link
Contributor

I've never heard that hive should be removed, but why not.
It would be even safer to keep hive instead of SharedPreferences.

@g123k
Copy link
Collaborator Author

g123k commented Jul 20, 2022

Okay, I thought the integration of SQLite was to migrate everything.
In that case, I will split my PR : one for the dialogs and one for the tests.
Otherwise it will be a « bloubiboulga »

@monsieurtanuki
Copy link
Contributor

Okay, I thought the integration of SQLite was to migrate everything.

The main problem was with Products, that take a lot of space and memory.
No rush to migrate lists too, especially when there's the question "should we handle lists as SQL lists (one row per item) or with JSON (one row per list)".
Anyway, we won't migrate before the current PR is merged :)

In that case, I will split my PR : one for the dialogs and one for the tests.

Good.

Otherwise it will be a « bloubiboulga »

I've double-checked on Stackoverflow: there's a typo here, the correct name is Gloubi-boulga. Can only be found in France. Still waiting for its Nova score, help needed! (could be an easter egg)

@g123k
Copy link
Collaborator Author

g123k commented Jul 20, 2022

Actually everything was ready for this part of the PR.
So moving it to a non-draft/"published" state

@g123k g123k marked this pull request as ready for review July 20, 2022 22:20
@g123k g123k requested a review from a team as a code owner July 20, 2022 22:20
@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2022

Codecov Report

Merging #2626 (384adcc) into develop (2ea0da3) will decrease coverage by 1.58%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           develop   #2626      +/-   ##
==========================================
- Coverage     8.86%   7.27%   -1.59%     
==========================================
  Files          161     220      +59     
  Lines         6623   10680    +4057     
==========================================
+ Hits           587     777     +190     
- Misses        6036    9903    +3867     
Impacted Files Coverage Δ
...kages/smooth_app/lib/widgets/attribute_button.dart 0.00% <0.00%> (-92.00%) ⬇️
...s/smooth_app/lib/data_models/user_preferences.dart 8.73% <0.00%> (-23.57%) ⬇️
packages/smooth_app/lib/themes/smooth_theme.dart 60.00% <0.00%> (-22.98%) ⬇️
...p/lib/generic_lib/dialogs/smooth_alert_dialog.dart 15.70% <0.00%> (-18.51%) ⬇️
...mooth_app/lib/data_models/product_preferences.dart 21.68% <0.00%> (-9.75%) ⬇️
packages/smooth_app/lib/main.dart 14.65% <0.00%> (-3.24%) ⬇️
.../smooth_app/lib/pages/onboarding/welcome_page.dart 0.00% <0.00%> (-3.13%) ⬇️
.../smooth_app/lib/pages/onboarding/scan_example.dart 0.00% <0.00%> (-2.28%) ⬇️
...p/lib/pages/onboarding/consent_analytics_page.dart 0.00% <0.00%> (-1.57%) ⬇️
...ackages/smooth_app/lib/pages/scan/scan_header.dart 3.33% <0.00%> (-1.43%) ⬇️
... and 238 more

Help us with your feedback. Take ten seconds to tell us how you rate us.

@VaiTon VaiTon requested a review from monsieurtanuki August 1, 2022 20:11
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @g123k!
Looks OK, though I have several comments.
But my major concern is about screenshots: please take the time to share with us screenshots of the dialogs that provoked #2605 (in both small device and "not small" device mode).

@@ -280,8 +284,10 @@ class UserPreferencesContribute extends AbstractUserPreferences {
onPressed: () => LaunchUrlHelper.launchURL(
'https://github.com/openfoodfacts/smooth-app', false),
text: AppLocalizations.of(context).contribute,
minWidth: 200,
minWidth: 150,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit from nowhere. Something related to screenSize would be more responsive.

contributorsData as Map<String, dynamic>);
return Padding(
padding: const EdgeInsets.all(5.0),
return Wrap(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No scrolling needed here?

Comment on lines +36 to +40
bool isTabletDevice() {
return size.width <= _MAX_TABLET_WIDTH;
}

bool isLargeDevice() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names are a bit confusing: I would assume a tablet to be larger than a large (allegedly smartphone) device.
What about the Android style, something like x, xx, xxx?

}
}

extension MediaQueryResponsiveExtensions on MediaQueryData {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll never get used to that syntax :)

Besides, in that case I guess SmoothResponsive would be good enough; the added value of the extension doesn't look interesting.


/// Custom Widget to provide a responsive behavior.
/// [defaultDeviceBuilder] is mandatory and will be used if no value is provided
class SmoothResponsiveBuilder extends StatelessWidget {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm wrong but I haven't seen a single piece of code using it. If you don't use it now, please get rid of it: it adds complexity. Same remark for BuildContextResponsiveExtensions.

@@ -0,0 +1,91 @@
import 'package:flutter/widgets.dart';

class SmoothResponsive {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some /// comments wouldn't hurt.

@@ -219,6 +366,7 @@ class _SmoothActionElevatedButton extends StatelessWidget {
final ThemeData themeData = Theme.of(context);
return SmoothSimpleButton(
onPressed: buttonData.onPressed,
minWidth: buttonData.minWidth ?? 20.0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should probably be MINIMUM_TOUCH_SIZE at least.


return AlertDialog(
scrollable: true,
scrollable: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you're not lucky.

Comment on lines 48 to 53
static const EdgeInsets _contentPadding = EdgeInsets.only(
left: 24.0,
left: 22.0,
top: VERY_LARGE_SPACE,
right: 24.0,
bottom: 24.0,
right: 22.0,
bottom: 22.0,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about EdgeInsets.all(VERY_LARGE_SPACE)?

@teolemon
Copy link
Member

teolemon commented Aug 9, 2022

Ok, @g123k can I merge this one ?
typically #2758 is an example where this PR is going to improve things

@g123k
Copy link
Collaborator Author

g123k commented Aug 9, 2022

Ok, @g123k can I merge this one ? typically #2758 is an example where this PR is going to improve things

Let me first change @monsieurtanuki's suggestions.
(Sorry didn't see the notification about this PR before)

@teolemon
Copy link
Member

ok, really keen on merging this one, tbh, the miniature text is an eyesore

@teolemon teolemon added the P2 label Aug 16, 2022
@teolemon
Copy link
Member

ok @g123k @monsieurtanuki let's merge this one and create an issue for the small improvement ?

@teolemon
Copy link
Member

I'm merging, we'll do the explaning in the next PR that will actually change the dialogs. We'll have to create an issue listing all those places

@teolemon teolemon merged commit ddb8bea into openfoodfacts:develop Aug 18, 2022
@g123k
Copy link
Collaborator Author

g123k commented Aug 18, 2022

The next step is to list all dialogs where we want this feature.
Please comment #2805

@g123k g123k deleted the horizontal_buttons_2 branch September 2, 2022 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Dialogs: Allow horizontal buttons
5 participants