Skip to content

Commit

Permalink
fix: catalog more action reorder products
Browse files Browse the repository at this point in the history
  • Loading branch information
evan361425 committed Oct 29, 2023
1 parent 9e49c96 commit aceb256
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 48 deletions.
3 changes: 1 addition & 2 deletions lib/components/scaffold/reorderable_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -74,7 +73,7 @@ class _ReorderableScaffoldState<T extends ModelOrderable>
title: Text(item.name),
trailing: ReorderableDragStartListener(
index: index,
child: const Icon(KIcons.reorder),
child: const Icon(Icons.reorder_sharp),
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/constants/icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/ui/menu/menu_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class _MenuPageState extends State<MenuPage> {
pathParameters: {'id': selected!.id},
);
},
icon: const Icon(Icons.compare_arrows_sharp),
icon: const Icon(KIcons.reorder),
),
SearchBarWrapper(
key: const Key('menu.search'),
Expand Down
31 changes: 14 additions & 17 deletions lib/ui/menu/widgets/menu_catalog_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,25 @@ class MenuCatalogList extends StatelessWidget {
deleteValue: _Action.delete,
tileBuilder: _tileBuilder,
confirmContextBuilder: _confirmContextBuilder,
actionBuilder: _actionBuilder,
actionBuilder: (Catalog catalog) => <BottomSheetAction<_Action>>[
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<BottomSheetAction<_Action>> _actionBuilder(catalog) {
return <BottomSheetAction<_Action>>[
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,
Expand Down
6 changes: 0 additions & 6 deletions lib/ui/menu/widgets/menu_product_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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},
),
];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/ui/order_attr/order_attribute_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
],
),
Expand Down
28 changes: 12 additions & 16 deletions lib/ui/order_attr/widgets/order_attribute_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,19 @@ class OrderAttributeList extends StatelessWidget {

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(kSpacing1),
child: HintText(S.totalCount(attributes.length)),
),
for (final attribute in attributes)
ChangeNotifierProvider<OrderAttribute>.value(
value: attribute,
child: const _OrderAttributeCard(),
),
// Floating action button offset
const SizedBox(height: 72.0),
],
return ListView(children: <Widget>[
Padding(
padding: const EdgeInsets.all(kSpacing1),
child: HintText(S.totalCount(attributes.length)),
),
);
for (final attribute in attributes)
ChangeNotifierProvider<OrderAttribute>.value(
value: attribute,
child: const _OrderAttributeCard(),
),
// Floating action button offset
const SizedBox(height: 72.0),
]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/ui/menu/catalog_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion test/ui/menu/menu_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void main() {
ChangeNotifierProvider<Menu>.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(
Expand Down
5 changes: 3 additions & 2 deletions test/ui/order_attr/order_attribute_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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')));

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit aceb256

Please sign in to comment.