From 7c15bca7465760e5fcb895f61dc6372eeb02f68f Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 5 Oct 2021 16:24:42 +0300 Subject: [PATCH] fix item --- .../screens/product-details/CustomIcon.dart | 4 +- .../product-details/ProductAppBar.dart | 139 ++++++++++++------ .../product-details/footor/footer-widget.dart | 5 +- .../product-details/product-detail.dart | 16 +- .../product-name-and-price.dart | 2 +- 5 files changed, 115 insertions(+), 51 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/CustomIcon.dart b/lib/pages/pharmacies/screens/product-details/CustomIcon.dart index c9a71afa..fc8b2288 100644 --- a/lib/pages/pharmacies/screens/product-details/CustomIcon.dart +++ b/lib/pages/pharmacies/screens/product-details/CustomIcon.dart @@ -11,11 +11,11 @@ class IconWithBg extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.only(left: 25), + // margin: EdgeInsets.only(left: 25), width: 40, height: 40, decoration: BoxDecoration( - color: Colors.grey[300], + color: Colors.grey[200], borderRadius: BorderRadius.circular(30), ), child: IconButton( diff --git a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart index 36c43364..c895d7c9 100644 --- a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart +++ b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart @@ -1,6 +1,11 @@ +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import '../../compare-list.dart'; import '../cart-order-page.dart'; import 'CustomIcon.dart'; @@ -9,58 +14,108 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { Widget build(BuildContext context) { return Container( color: Colors.white, - child: Column( - children: [ - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - IconWithBg( - icon: Icons.arrow_back_ios, - color: Colors.grey, - onPress: () { - Navigator.pop(context); - }, - ), - ], - ), - Row( - children: [ - IconWithBg( - icon: Icons.shopping_cart, + + child: FractionallySizedBox( + widthFactor: 0.95, + child: Column( + children: [ + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + IconWithBg( + icon: Icons.arrow_back_ios, color: Colors.grey, onPress: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => CartOrderPage()), - ); - }), - IconWithBg( - icon: FontAwesomeIcons.ellipsisV, - color: Colors.grey, - onPress: () { - //TODO Elham* - // settingModalBottomSheet(context); - }, - ), - ], - ) - ], - ), - ], + Navigator.pop(context); + }, + ), + ], + ), + Row( + children: [ + IconWithBg( + icon: Icons.shopping_cart, + color: Colors.grey, + onPress: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CartOrderPage()), + ); + }), + SizedBox(width: 10,), + IconWithBg( + icon: FontAwesomeIcons.ellipsisV, + color: Colors.grey, + onPress: () { + settingModalBottomSheet(context); + }, + ), + ], + ) + ], + ), + ], + ), ), ); } + + @override // TODO: implement preferredSize @override Size get preferredSize => Size(double.maxFinite, 50); + + settingModalBottomSheet(context) { + showModalBottomSheet( + context: context, + builder: (BuildContext bc) { + return Container( + child: new Wrap( + children: [ + new ListTile( + leading: Icon(Icons.shopping_cart), + title: Text( + TranslationBase.of(context).addToCart, + ), + onTap: () => { + if (price > 0) + {addToCartFunction(price, itemID, context)} + else + { + AppToast.showErrorToast( + message: "you should add quantity") + } + }), + ListTile( + leading: Icon(Icons.favorite_border), + title: Text( + TranslationBase.of(context).addToWishlist, + ), + onTap: () => {addToWishlistFunction(itemID)}, + ), + ListTile( + leading: Icon(Icons.compare), + title: Text( + TranslationBase.of(context).compare, + ), + onTap: () => { + Provider.of(context, listen: false) + .addItem(specificationData), + }, + ), + ], + ), + ); + }); + } } diff --git a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart index cca4eef5..88302480 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -178,7 +178,7 @@ class _FooterWidgetState extends State { ), ), Container( - width: MediaQuery.of(context).size.width * 0.4, + width: MediaQuery.of(context).size.width * 0.45, child: SecondaryButton( label: TranslationBase.of(context).addToCart.toUpperCase(), disabled: !widget.isAvailable && widget.price > 0 || @@ -188,6 +188,7 @@ class _FooterWidgetState extends State { widget.addToCartFunction( widget.price, widget.item.id, context); }, + borderRadius: 5, color: Colors.green, ), @@ -196,7 +197,7 @@ class _FooterWidgetState extends State { width: 5, ), Container( - width: MediaQuery.of(context).size.width * 0.3, + width: MediaQuery.of(context).size.width * 0.35, child: SecondaryButton( label: TranslationBase.of(context).buyNow.toUpperCase(), disabled: !widget.isAvailable && widget.price > 0 || diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 08a622aa..d2ce4f35 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -112,7 +112,7 @@ class __ProductDetailPageState extends State isShowAppBar: true, isPharmacy: true, isShowDecPage: false, - customAppBar: ProductAppBar(), + customAppBar: ProductAppBar(), body: SingleChildScrollView( child: Column( children: [ @@ -143,9 +143,17 @@ class __ProductDetailPageState extends State context, widget.product, customerId: customerId, - addToWishlistFunction: addToWishlistFunction, - deleteFromWishlistFunction: deleteFromWishlistFunction, - notifyMeWhenAvailable: notifyMeWhenAvailable, + addToWishlistFunction: (item) { + addToWishlistFunction(item); + setState(() {}); + }, + deleteFromWishlistFunction: (item) { + deleteFromWishlistFunction(item); + setState(() {}); + }, + notifyMeWhenAvailable: (context, itemId) { + notifyMeWhenAvailable(context, itemId); + }, isInWishList: isInWishList, ), ), diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index 4f607e48..b7906b78 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -46,7 +46,7 @@ class _ProductNameAndPriceState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts(widget.item.price.toString() + " " + "SAR", + Texts(widget.item.price.toString() + " " + "SR", fontWeight: FontWeight.bold, fontSize: 20), Texts( projectViewModel.isArabic