diff --git a/lib/cart_screen.dart b/lib/cart_screen.dart index e471e39..ddf7fff 100644 --- a/lib/cart_screen.dart +++ b/lib/cart_screen.dart @@ -4,6 +4,7 @@ import 'models/payment.dart'; import 'models/product.dart'; import 'models/shop.dart'; import 'utils/formatter.dart'; +import 'widgets/cart_item_counter.dart'; import 'widgets/payment_info.dart'; import 'widgets/shop_info.dart'; diff --git a/lib/widgets/cart_item.dart b/lib/widgets/cart_item.dart index 6465f01..67eee5b 100644 --- a/lib/widgets/cart_item.dart +++ b/lib/widgets/cart_item.dart @@ -78,6 +78,15 @@ class CartItem extends StatelessWidget { ), ], ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + CartItemCounter(), + SizedBox( + width: 20, + ), + ], + ), SizedBox( height: 20, ), diff --git a/lib/widgets/cart_item_counter.dart b/lib/widgets/cart_item_counter.dart new file mode 100644 index 0000000..14dfc8f --- /dev/null +++ b/lib/widgets/cart_item_counter.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; + +class CartItemCounter extends StatelessWidget { + const CartItemCounter({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey.withOpacity(0.4), + ), + borderRadius: BorderRadius.circular(6), + ), + child: Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + IconButton( + icon: Icon(Icons.remove), + disabledColor: Colors.grey, + onPressed: () {}, + ), + Text('1'), + IconButton( + icon: Icon(Icons.add), + onPressed: () {}, + ), + ], + ), + ); + } +} diff --git a/lib/widgets/counter.dart b/lib/widgets/counter.dart new file mode 100644 index 0000000..fc6d06a --- /dev/null +++ b/lib/widgets/counter.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; + +class Counter extends InheritedWidget { + const Counter({ + Key? key, + required this.value, + required Widget child, + }) : super(key: key, child: child); + + final int value; + + static Counter of(BuildContext context) { + final Counter? result = + context.dependOnInheritedWidgetOfExactType(); + assert(result != null, 'No Counter found in context'); + return result!; + } + + @override + bool updateShouldNotify(Counter old) { + return old.value != value; + } +}