From aceb256d376a854eb36f2214782461092b51a56a Mon Sep 17 00:00:00 2001 From: Shueh Chou Lu Date: Sun, 29 Oct 2023 08:48:22 +0800 Subject: [PATCH] fix: catalog more action reorder products --- .../scaffold/reorderable_scaffold.dart | 3 +- lib/constants/icons.dart | 2 +- lib/ui/menu/menu_page.dart | 2 +- lib/ui/menu/widgets/menu_catalog_list.dart | 31 +++++++++---------- lib/ui/menu/widgets/menu_product_list.dart | 6 ---- lib/ui/order_attr/order_attribute_page.dart | 2 +- .../widgets/order_attribute_list.dart | 28 +++++++---------- test/ui/menu/catalog_view_test.dart | 2 +- test/ui/menu/menu_page_test.dart | 2 +- .../order_attr/order_attribute_page_test.dart | 5 +-- 10 files changed, 35 insertions(+), 48 deletions(-) diff --git a/lib/components/scaffold/reorderable_scaffold.dart b/lib/components/scaffold/reorderable_scaffold.dart index b3bc3732..4488ffc2 100644 --- a/lib/components/scaffold/reorderable_scaffold.dart +++ b/lib/components/scaffold/reorderable_scaffold.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:possystem/components/style/hint_text.dart'; import 'package:possystem/components/style/pop_button.dart'; import 'package:possystem/constants/constant.dart'; -import 'package:possystem/constants/icons.dart'; import 'package:possystem/models/model.dart'; import 'package:possystem/translator.dart'; @@ -74,7 +73,7 @@ class _ReorderableScaffoldState title: Text(item.name), trailing: ReorderableDragStartListener( index: index, - child: const Icon(KIcons.reorder), + child: const Icon(Icons.reorder_sharp), ), ), ), diff --git a/lib/constants/icons.dart b/lib/constants/icons.dart index 4f27ab40..55e8bddb 100644 --- a/lib/constants/icons.dart +++ b/lib/constants/icons.dart @@ -4,7 +4,7 @@ class KIcons { static const add = Icons.add_sharp; static const cancel = Icons.cancel_sharp; static const delete = Icons.delete_sharp; - static const reorder = Icons.reorder_sharp; + static const reorder = Icons.switch_access_shortcut_sharp; static const modal = Icons.text_fields_sharp; static const image = Icons.image_sharp; diff --git a/lib/ui/menu/menu_page.dart b/lib/ui/menu/menu_page.dart index 0d676c47..54506aeb 100644 --- a/lib/ui/menu/menu_page.dart +++ b/lib/ui/menu/menu_page.dart @@ -63,7 +63,7 @@ class _MenuPageState extends State { pathParameters: {'id': selected!.id}, ); }, - icon: const Icon(Icons.compare_arrows_sharp), + icon: const Icon(KIcons.reorder), ), SearchBarWrapper( key: const Key('menu.search'), diff --git a/lib/ui/menu/widgets/menu_catalog_list.dart b/lib/ui/menu/widgets/menu_catalog_list.dart index 4fd59094..bdcf7d7a 100644 --- a/lib/ui/menu/widgets/menu_catalog_list.dart +++ b/lib/ui/menu/widgets/menu_catalog_list.dart @@ -28,28 +28,25 @@ class MenuCatalogList extends StatelessWidget { deleteValue: _Action.delete, tileBuilder: _tileBuilder, confirmContextBuilder: _confirmContextBuilder, - actionBuilder: _actionBuilder, + actionBuilder: (Catalog catalog) => >[ + BottomSheetAction( + title: Text(S.menuCatalogUpdate), + leading: const Icon(KIcons.modal), + routePathParameters: {'id': catalog.id}, + route: Routes.menuCatalogModal, + ), + BottomSheetAction( + title: Text(S.menuProductReorder), + leading: const Icon(KIcons.reorder), + route: Routes.menuCatalogReorder, + routePathParameters: {'id': catalog.id}, + ), + ], handleDelete: (item) => item.remove(), ), ); } - Iterable> _actionBuilder(catalog) { - return >[ - BottomSheetAction( - title: Text(S.menuCatalogUpdate), - leading: const Icon(KIcons.modal), - routePathParameters: {'id': catalog.id}, - route: Routes.menuCatalogModal, - ), - BottomSheetAction( - title: Text(S.menuCatalogReorder), - leading: const Icon(KIcons.reorder), - route: Routes.menuReorder, - ), - ]; - } - Widget _tileBuilder( BuildContext context, Catalog catalog, diff --git a/lib/ui/menu/widgets/menu_product_list.dart b/lib/ui/menu/widgets/menu_product_list.dart index b6662d79..a63f60fd 100644 --- a/lib/ui/menu/widgets/menu_product_list.dart +++ b/lib/ui/menu/widgets/menu_product_list.dart @@ -42,12 +42,6 @@ class MenuProductList extends StatelessWidget { route: Routes.menuProductModal, routePathParameters: {'id': product.id}, ), - BottomSheetAction( - title: Text(S.menuProductReorder), - leading: const Icon(KIcons.reorder), - route: Routes.menuCatalogReorder, - routePathParameters: {'id': product.catalog.id}, - ), ]; } diff --git a/lib/ui/order_attr/order_attribute_page.dart b/lib/ui/order_attr/order_attribute_page.dart index ba911839..1d2452bc 100644 --- a/lib/ui/order_attr/order_attribute_page.dart +++ b/lib/ui/order_attr/order_attribute_page.dart @@ -28,7 +28,7 @@ class OrderAttributePage extends StatelessWidget { key: const Key('order_attributes.reorder'), tooltip: S.orderAttributeReorder, onPressed: () => context.pushNamed(Routes.orderAttrReorder), - icon: const Icon(Icons.compare_arrows_sharp), + icon: const Icon(KIcons.reorder), ), ], ), diff --git a/lib/ui/order_attr/widgets/order_attribute_list.dart b/lib/ui/order_attr/widgets/order_attribute_list.dart index 495d145f..79e06c1f 100644 --- a/lib/ui/order_attr/widgets/order_attribute_list.dart +++ b/lib/ui/order_attr/widgets/order_attribute_list.dart @@ -22,23 +22,19 @@ class OrderAttributeList extends StatelessWidget { @override Widget build(BuildContext context) { - return SingleChildScrollView( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(kSpacing1), - child: HintText(S.totalCount(attributes.length)), - ), - for (final attribute in attributes) - ChangeNotifierProvider.value( - value: attribute, - child: const _OrderAttributeCard(), - ), - // Floating action button offset - const SizedBox(height: 72.0), - ], + return ListView(children: [ + Padding( + padding: const EdgeInsets.all(kSpacing1), + child: HintText(S.totalCount(attributes.length)), ), - ); + for (final attribute in attributes) + ChangeNotifierProvider.value( + value: attribute, + child: const _OrderAttributeCard(), + ), + // Floating action button offset + const SizedBox(height: 72.0), + ]); } } diff --git a/test/ui/menu/catalog_view_test.dart b/test/ui/menu/catalog_view_test.dart index 9ed826af..753d7a42 100644 --- a/test/ui/menu/catalog_view_test.dart +++ b/test/ui/menu/catalog_view_test.dart @@ -180,7 +180,7 @@ void main() { await moveTo(tester, catalog); - await tester.tap(find.byIcon(Icons.compare_arrows_sharp)); + await tester.tap(find.byIcon(KIcons.reorder)); await tester.pumpAndSettle(); await tester.drag( diff --git a/test/ui/menu/menu_page_test.dart b/test/ui/menu/menu_page_test.dart index e00dc645..7d171799 100644 --- a/test/ui/menu/menu_page_test.dart +++ b/test/ui/menu/menu_page_test.dart @@ -160,7 +160,7 @@ void main() { ChangeNotifierProvider.value(value: Menu.instance), ], child: buildApp())); - await tester.tap(find.byIcon(Icons.compare_arrows_sharp)); + await tester.tap(find.byIcon(KIcons.reorder)); await tester.pumpAndSettle(); await tester.drag( diff --git a/test/ui/order_attr/order_attribute_page_test.dart b/test/ui/order_attr/order_attribute_page_test.dart index 82222daa..5e8e9935 100644 --- a/test/ui/order_attr/order_attribute_page_test.dart +++ b/test/ui/order_attr/order_attribute_page_test.dart @@ -11,6 +11,7 @@ import 'package:possystem/routes.dart'; import 'package:possystem/services/storage.dart'; import 'package:possystem/settings/currency_setting.dart'; import 'package:possystem/settings/settings_provider.dart'; +import 'package:possystem/translator.dart'; import 'package:possystem/ui/order_attr/order_attribute_page.dart'; import 'package:provider/provider.dart'; @@ -199,7 +200,7 @@ void main() { testWidgets('Reorder attributes', (tester) async { await buildAppWithAttributes(tester); - await tester.tap(find.byKey(const Key('order_attributes.reorder'))); + await tester.tap(find.byIcon(KIcons.reorder)); await tester.pumpAndSettle(); final rect = tester.getRect(find.byKey(const Key('reorder.0'))); @@ -364,7 +365,7 @@ void main() { await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('order_attributes.1.more'))); await tester.pumpAndSettle(); - await tester.tap(find.byIcon(Icons.reorder_sharp)); + await tester.tap(find.text(S.orderAttributeOptionReorder)); await tester.pumpAndSettle(); await tester.drag(