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: Allow to reorder the action bar #5826

Merged
merged 10 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
Binary file modified packages/smooth_app/assets/fonts/SmoothIcons.ttf
Binary file not shown.
10 changes: 4 additions & 6 deletions packages/smooth_app/assets/fonts/icons/compare.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 28 additions & 28 deletions packages/smooth_app/assets/fonts/icons/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,6 @@
"circled_arrow"
]
},
{
"uid": "03120423fe19213c646bbe1ce9779fb7",
"css": "compare",
"code": 59403,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M46 0C29.7-0.2 14.4 8.4 6.2 22.6-2.1 36.7-2.1 54.2 6.2 68.4 14.4 82.6 29.7 91.2 46 90.9L500 90.9 500 363.7C450.4 363.7 409.2 404.9 409.2 454.6L409.2 545.5 46 545.5C29.7 545.2 14.4 553.9 6.2 568-2.1 582.2-2.1 599.7 6.2 613.8 14.4 628 29.7 636.6 46 636.4L409.2 636.4 409.2 909.1C409.2 958.8 450.4 1000 500 1000L954 1000C970.3 1000.2 985.6 991.6 993.8 977.5 1002.1 963.3 1002.1 945.8 993.8 931.6 985.6 917.5 970.3 908.9 954 909.1L500 909.1 500 598.6C500.8 593.7 500.8 588.6 500 583.7L500 454.6 537.8 454.6C542.7 455.4 547.7 455.4 552.6 454.6L954 454.6C970.3 454.8 985.6 446.2 993.8 432 1002.1 417.9 1002.1 400.4 993.8 386.2 985.6 372 970.3 363.4 954 363.7L590.8 363.7 590.8 90.9C590.8 41.3 549.6 0 500 0L46 0ZM243.3 166.7L243.3 277.8 49.2 277.8C31.7 277.5 15.4 288 6.6 305.3-2.2 322.7-2.2 344.1 6.6 361.4 15.4 378.7 31.7 389.2 49.2 388.9L243.3 388.9 243.3 500 388.9 333.4 243.3 166.7ZM756.7 500L611.1 666.7 756.7 833.4 756.7 722.2 950.8 722.2C968.3 722.5 984.6 712 993.4 694.7 1002.2 677.4 1002.2 656 993.4 638.7 984.6 621.4 968.3 610.8 950.8 611.1L756.7 611.1 756.7 500Z",
"width": 1000
},
"search": [
"compare"
]
},
{
"uid": "253452e79f11530813499c918f41c26d",
"css": "countries",
Expand Down Expand Up @@ -1202,20 +1188,6 @@
"country"
]
},
{
"uid": "3ce590f4efc2e583af54473012e125bf",
"css": "hamburger_menu",
"code": 59484,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M286.7 366.7C279.6 366.6 272.9 370.3 269.4 376.4 265.8 382.6 265.8 390.2 269.4 396.3 272.9 402.5 279.6 406.2 286.7 406.1L681 406.1C688.1 406.2 694.7 402.5 698.3 396.3 701.8 390.2 701.8 382.6 698.3 376.4 694.7 370.3 688.1 366.6 681 366.7L286.7 366.7ZM286.7 465.2C279.6 465.1 272.9 468.9 269.4 475 265.8 481.2 265.8 488.8 269.4 494.9 272.9 501 279.6 504.8 286.7 504.7L681 504.7C688.1 504.8 694.7 501 698.3 494.9 701.8 488.8 701.8 481.2 698.3 475 694.7 468.9 688.1 465.1 681 465.2L286.7 465.2ZM286.7 563.8C279.6 563.7 272.9 567.4 269.4 573.6 265.8 579.7 265.8 587.3 269.4 593.5 272.9 599.6 279.6 603.3 286.7 603.2L681 603.2C688.1 603.3 694.7 599.6 698.3 593.5 701.8 587.3 701.8 579.7 698.3 573.6 694.7 567.4 688.1 563.7 681 563.8L286.7 563.8Z",
"width": 1000
},
"search": [
"hamburger_menu"
]
},
{
"uid": "5cf1541a6d6b001cecc06fbc4c40d560",
"css": "password",
Expand Down Expand Up @@ -1397,6 +1369,34 @@
"search": [
"personalization_alt"
]
},
{
"uid": "bba212cc007d630ef96ebd20ff7b0378",
"css": "compare",
"code": 59403,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M55.6 0C24.9 0 0 24.9 0 55.6L0 722.2C0 752.9 24.9 777.8 55.6 777.8L388.9 777.8 388.9 888.9C388.9 950.3 438.6 1000 500 1000L944.4 1000C975.1 1000 1000 975.1 1000 944.4 1000 913.8 975.1 888.9 944.4 888.9L500 888.9 500 777.8C561.4 777.8 611.1 728.1 611.1 666.7L611.1 333.3 944.4 333.3C975.1 333.3 1000 308.4 1000 277.8 1000 247.1 975.1 222.2 944.4 222.2L611.1 222.2 611.1 111.1C611.1 49.7 561.4 0 500 0L55.6 0ZM306.9 247.3C311.6 248.1 316.2 250.3 320.1 254.2L437.2 371.4C442 376.3 444.4 382.6 444.4 388.9 444.4 395.2 442 401.5 437.2 406.4L320.1 523.5C304.5 539.2 277.8 528 277.8 506L277.8 444.4 166.7 444.4C136 444.4 111.1 419.6 111.1 388.9 111.1 358.2 136 333.3 166.7 333.3L277.8 333.3 277.8 271.8C277.8 255.3 292.8 244.8 306.9 247.3ZM804.3 469.5C799.6 470.3 794.9 472.6 791 476.5L673.9 593.5C664.3 603.2 664.3 618.9 673.9 628.6L791 745.8C806.6 761.4 833.3 750.3 833.3 728.2L833.3 666.7 944.4 666.7C964.5 667 983.1 656.4 993.2 639.1 1003.3 621.8 1003.3 600.4 993.2 583.1 983.1 565.8 964.5 555.3 944.4 555.6L833.3 555.6 833.3 493.9C833.3 477.4 818.3 467.1 804.3 469.5Z",
"width": 1000
},
"search": [
"compare"
]
},
{
"uid": "e8a0f936151ac9d599ffe68e9761482f",
"css": "hamburger_menu",
"code": 59444,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M46 684.7C29.7 684.5 14.4 693.1 6.2 707.2-2.1 721.4-2.1 738.9 6.2 753 14.4 767.2 29.7 775.8 46 775.5L954 775.5C970.3 775.8 985.6 767.2 993.8 753 1002.1 738.9 1002.1 721.4 993.8 707.2 985.6 693.1 970.3 684.5 954 684.7L46 684.7ZM46 457.8C29.7 457.5 14.4 466.1 6.2 480.3-2.1 494.4-2.1 511.9 6.2 526 14.4 540.2 29.7 548.8 46 548.5L954 548.5C970.3 548.8 985.6 540.2 993.8 526 1002.1 511.9 1002.1 494.4 993.8 480.3 985.6 466.1 970.3 457.5 954 457.8L46 457.8ZM46 230.8C29.7 230.5 14.4 239.1 6.2 253.3-2.1 267.4-2.1 284.9 6.2 299.1 14.4 313.2 29.7 321.8 46 321.6L954 321.6C970.3 321.8 985.6 313.2 993.8 299.1 1002.1 284.9 1002.1 267.4 993.8 253.3 985.6 239.1 970.3 230.5 954 230.8L46 230.8Z",
"width": 1000
},
"search": [
"hamburger_menu"
]
}
]
}
4 changes: 2 additions & 2 deletions packages/smooth_app/assets/fonts/icons/hamburger_menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/assets/fonts/icons/icons.sketch
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/smooth_app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ SPEC CHECKSUMS:
sentry_flutter: 0eb93e5279eb41e2392212afe1ccd2fecb4f8cbe
share_plus: 8b6f8b3447e494cca5317c8c3073de39b3600d1f
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13
sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
webview_flutter_wkwebview: 0982481e3d9c78fd5c6f62a002fcd24fc791f1e4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:smooth_app/data_models/product_preferences.dart';
import 'package:smooth_app/pages/onboarding/onboarding_flow_navigator.dart';
import 'package:smooth_app/pages/preferences/user_preferences_dev_mode.dart';
import 'package:smooth_app/pages/product/product_page/footer/new_product_footer.dart';
import 'package:smooth_app/themes/color_schemes.dart';
import 'package:smooth_app/themes/theme_provider.dart';

Expand Down Expand Up @@ -87,6 +88,7 @@ class UserPreferences extends ChangeNotifier {
static const String _TAG_UNIQUE_RANDOM = '_unique_random';
static const String _TAG_LAZY_COUNT_PREFIX = '_lazy_count_prefix';
static const String _TAG_LATEST_PRODUCT_TYPE = '_latest_product_type';
static const String _TAG_PRODUCT_PAGE_ACTIONS = '_product_page_actions';

/// Camera preferences

Expand Down Expand Up @@ -485,4 +487,30 @@ class UserPreferences extends ChangeNotifier {
value.offTag,
),
);

List<ProductFooterActionBar> get productPageActions {
final List<String>? actions =
_sharedPreferences.getStringList(_TAG_PRODUCT_PAGE_ACTIONS);

if (actions == null) {
return ProductFooterActionBar.defaultOrder();
}

return actions
.map((String action) => ProductFooterActionBar.fromKey(action))
.toList(growable: false);
}

Future<void> setProductPageActions(
final Iterable<ProductFooterActionBar> value,
) async {
assert(!value.contains(ProductFooterActionBar.settings));
await _sharedPreferences.setStringList(
_TAG_PRODUCT_PAGE_ACTIONS,
value
.map((ProductFooterActionBar action) => action.key)
.toList(growable: false),
);
notifyListeners();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,36 @@ import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:smooth_app/generic_lib/bottom_sheets/smooth_draggable_bottom_sheet_route.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/helpers/haptic_feedback_helper.dart';
import 'package:smooth_app/resources/app_icons.dart' as icons;
import 'package:smooth_app/themes/smooth_theme_colors.dart';

Future<T?> showSmoothModalSheet<T>({
required BuildContext context,
required WidgetBuilder builder,
double? minHeight,
double? maxHeight,
}) {
BoxConstraints? constraints;

// We can't provide a null value to a [BoxConstraints] constructor
if (minHeight != null && maxHeight != null) {
constraints = BoxConstraints(
minHeight: minHeight,
maxHeight: maxHeight,
);
} else if (minHeight != null) {
constraints = BoxConstraints(
minHeight: minHeight,
);
} else if (maxHeight != null) {
constraints = BoxConstraints(
maxHeight: maxHeight,
);
}

return showModalBottomSheet<T>(
constraints:
minHeight != null ? BoxConstraints(minHeight: minHeight) : null,
constraints: constraints,
isScrollControlled: minHeight != null,
context: context,
shape: const RoundedRectangleBorder(
Expand Down Expand Up @@ -54,11 +73,16 @@ class SmoothModalSheet extends StatelessWidget {
SmoothModalSheet({
required String title,
required this.body,
bool prefixIndicator = false,
bool closeButton = true,
this.bodyPadding,
this.expandBody = false,
double? closeButtonSemanticsOrder,
}) : header = SmoothModalSheetHeader(
title: title,
prefix: prefixIndicator
? const SmoothModalSheetHeaderPrefixIndicator()
: null,
suffix: closeButton
? SmoothModalSheetHeaderCloseButton(
semanticsOrder: closeButtonSemanticsOrder,
Expand All @@ -69,25 +93,33 @@ class SmoothModalSheet extends StatelessWidget {
final SmoothModalSheetHeader header;
final Widget body;
final EdgeInsetsGeometry? bodyPadding;
final bool expandBody;

@override
Widget build(BuildContext context) {
Widget bodyChild = Padding(
padding: bodyPadding ?? const EdgeInsets.all(MEDIUM_SPACE),
child: body,
);

if (expandBody) {
bodyChild = Expanded(child: bodyChild);
}

return ClipRRect(
borderRadius: const BorderRadius.vertical(top: ROUNDED_RADIUS),
child: DecoratedBox(
decoration: const BoxDecoration(
borderRadius: BorderRadius.vertical(top: ROUNDED_RADIUS),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
header,
Padding(
padding: bodyPadding ?? const EdgeInsets.all(MEDIUM_SPACE),
child: body,
),
],
)),
decoration: const BoxDecoration(
borderRadius: BorderRadius.vertical(top: ROUNDED_RADIUS),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
header,
bodyChild,
],
),
),
);
}

Expand Down Expand Up @@ -320,7 +352,10 @@ class SmoothModalSheetHeaderCloseButton extends StatelessWidget
message: MaterialLocalizations.of(context).closeButtonTooltip,
enableFeedback: true,
child: InkWell(
onTap: () => Navigator.of(context).pop(),
onTap: () {
SmoothHapticFeedback.click();
Navigator.of(context).pop();
},
customBorder: const CircleBorder(),
child: icon,
),
Expand Down
7 changes: 4 additions & 3 deletions packages/smooth_app/lib/helpers/haptic_feedback_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ class SmoothHapticFeedback {
}

await HapticFeedback.heavyImpact();
return Future<void>.delayed(const Duration(milliseconds: 50), () {
HapticFeedback.heavyImpact();
});
await Future<void>.delayed(const Duration(milliseconds: 150));
await HapticFeedback.heavyImpact();
await Future<void>.delayed(const Duration(milliseconds: 150));
return HapticFeedback.heavyImpact();
}

static Future<bool> _areHapticFeedbackEnabled() async {
Expand Down
Loading
Loading