diff --git a/lib/pages/pharmacies/screens/product-details/CustomIcon.dart b/lib/pages/pharmacies/screens/product-details/CustomIcon.dart new file mode 100644 index 00000000..c9a71afa --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/CustomIcon.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; + +class IconWithBg extends StatelessWidget { + final IconData icon; + final Color color; + final Function onPress; + + const IconWithBg({Key key, this.icon, this.color, this.onPress}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(left: 25), + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.circular(30), + ), + child: IconButton( + icon: Icon(icon), + color: color, + onPressed: () async { + onPress(); + }, + )); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart new file mode 100644 index 00000000..36c43364 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart @@ -0,0 +1,66 @@ +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +import '../cart-order-page.dart'; +import 'CustomIcon.dart'; + +class ProductAppBar extends StatelessWidget with PreferredSizeWidget { + @override + 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, + color: Colors.grey, + onPress: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CartOrderPage()), + ); + }), + IconWithBg( + icon: FontAwesomeIcons.ellipsisV, + color: Colors.grey, + onPress: () { + //TODO Elham* + // settingModalBottomSheet(context); + }, + ), + ], + ) + ], + ), + ], + ), + ); + } + + @override + // TODO: implement preferredSize + @override + Size get preferredSize => Size(double.maxFinite, 50); +} + + diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 71dbbddd..08a622aa 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -25,6 +25,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_mo import '../cart-order-page.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'ProductAppBar.dart'; import 'availability_info.dart'; import 'details_info.dart'; import 'discount_description.dart'; @@ -106,11 +107,12 @@ class __ProductDetailPageState extends State final screenSize = MediaQuery.of(context).size; return customerId != null - ? DetailPageScafold( + ? AppScaffold( appBarTitle: TranslationBase.of(context).productDetails, isShowAppBar: true, isPharmacy: true, isShowDecPage: false, + customAppBar: ProductAppBar(), body: SingleChildScrollView( child: Column( children: [ @@ -119,14 +121,14 @@ class __ProductDetailPageState extends State color: Colors.white, child: Column( children: [ - if(widget.product.images.isNotEmpty) - Container( - height: MediaQuery.of(context).size.height*.40, - child: Image.network( - widget.product.images[0].src.trim(), - fit: BoxFit.contain, + if (widget.product.images.isNotEmpty) + Container( + height: MediaQuery.of(context).size.height * .40, + child: Image.network( + widget.product.images[0].src.trim(), + fit: BoxFit.contain, + ), ), - ), if (widget.product.discountDescription != null) DiscountDescription(product: widget.product) ], @@ -157,7 +159,8 @@ class __ProductDetailPageState extends State crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10), + padding: EdgeInsets.symmetric( + vertical: 15, horizontal: 10), child: Texts( TranslationBase.of(context).specification, fontSize: 15, @@ -273,7 +276,9 @@ class __ProductDetailPageState extends State color: Colors.white, ), CustomDivider( - color: isDetails ? Colors.green : Colors.transparent, + color: isDetails + ? Colors.green + : Colors.transparent, ) ], ), @@ -298,8 +303,10 @@ class __ProductDetailPageState extends State ), color: Colors.white, ), - CustomDivider( - color: isReviews ? Colors.green : Colors.transparent, + CustomDivider( + color: isReviews + ? Colors.green + : Colors.transparent, ), ], ), @@ -324,8 +331,10 @@ class __ProductDetailPageState extends State ), color: Colors.white, ), - CustomDivider( - color: isAvailability ? Colors.green : Colors.transparent, + CustomDivider( + color: isAvailability + ? Colors.green + : Colors.transparent, ), ], ), @@ -367,7 +376,9 @@ class __ProductDetailPageState extends State // ), // RecommendedProducts(product: widget.product) - SizedBox(height: 80,) + SizedBox( + height: 80, + ) ], ), ), 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 0be6a213..4f607e48 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 @@ -8,6 +8,8 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; +import 'CustomIcon.dart'; + class ProductNameAndPrice extends StatefulWidget { BuildContext context; PharmacyProduct item; @@ -36,19 +38,25 @@ class _ProductNameAndPriceState extends State { return Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - SizedBox(height: 10,), + SizedBox( + height: 10, + ), FractionallySizedBox( widthFactor: 0.95, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Texts(widget.item.price.toString() + " " + "SAR", - fontWeight: FontWeight.bold, fontSize: 20 - ), - Texts( projectViewModel.isArabic - ? widget.item.stockAvailabilityn - : widget.item.stockAvailability, - fontWeight: FontWeight.bold, fontSize: 15, color: widget.item.stockAvailability == 'Out of stock'?Colors.red:Colors.green, + fontWeight: FontWeight.bold, fontSize: 20), + Texts( + projectViewModel.isArabic + ? widget.item.stockAvailabilityn + : widget.item.stockAvailability, + fontWeight: FontWeight.bold, + fontSize: 15, + color: widget.item.stockAvailability == 'Out of stock' + ? Colors.red + : Colors.green, ), // SizedBox(width: 20), widget.item.stockAvailability == 'Out of stock' && @@ -70,22 +78,13 @@ class _ProductNameAndPriceState extends State { ) ]), ) - : Container( - margin: projectViewModel.isArabic - ? EdgeInsets.only(right: 25) - : EdgeInsets.only(left: 25), - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.grey[300], - borderRadius: BorderRadius.circular(30), - ), - child: IconButton( - icon: Icon(!widget.isInWishList - ? Icons.favorite_border - : Icons.favorite), - color: !widget.isInWishList ? Colors.white : Colors.red, - onPressed: () async { + : IconWithBg( + icon: !widget.isInWishList + ? Icons.favorite_border + : Icons.favorite, + color: !widget.isInWishList ? Colors.white : Colors.red, + onPress: () async { + { if (widget.customerId != null) { if (!widget.isInWishList) { GifLoaderDialogUtils.showMyDialog(context); @@ -100,8 +99,9 @@ class _ProductNameAndPriceState extends State { return; } setState(() {}); - }, - )), + } + }, + ) ], ), ), @@ -132,7 +132,8 @@ class _ProductNameAndPriceState extends State { child: Row( children: [ RatingBar.readOnly( - initialRating:double.parse( widget.item.approvedRatingSum.toString()), + initialRating: double.parse( + widget.item.approvedRatingSum.toString()), size: 15.0, filledColor: Colors.yellow[700], emptyColor: Colors.grey[400], @@ -141,13 +142,17 @@ class _ProductNameAndPriceState extends State { filledIcon: Icons.star, emptyIcon: Icons.star, ), - SizedBox(width: 10,), + SizedBox( + width: 10, + ), Texts( "${widget.item.approvedRatingSum}", fontWeight: FontWeight.bold, fontSize: 12, ), - SizedBox(width: 30,), + SizedBox( + width: 30, + ), Texts( "(${widget.item.approvedTotalReviews}${TranslationBase.of(context).review})", fontSize: 12, @@ -178,7 +183,9 @@ class _ProductNameAndPriceState extends State { ], ), ), - SizedBox(height: 10,), + SizedBox( + height: 10, + ), ], ); } diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index b99ac1dc..dcac916b 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -62,6 +62,8 @@ class AppScaffold extends StatelessWidget { locator(); AppBarWidget appBar; + final Widget customAppBar; + AppScaffold( {@required this.body, this.appBarTitle = '', @@ -85,7 +87,9 @@ class AppScaffold extends StatelessWidget { this.infoList, this.isHelp = false, this.showHomeAppBarIcon = true, - this.imagesInfo}); + this.imagesInfo, + appBar, + this.customAppBar}); AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -99,16 +103,18 @@ class AppScaffold extends StatelessWidget { backgroundColor: backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, appBar: isShowAppBar - ? appBar = AppBarWidget( - appBarTitle: appBarTitle, - appBarIcons: appBarIcons, - showHomeAppBarIcon: showHomeAppBarIcon, - isPharmacy: isPharmacy, - showPharmacyCart: showPharmacyCart, - isOfferPackages: isOfferPackages, - showOfferPackagesCart: showOfferPackagesCart, - isShowDecPage: isShowDecPage, - ) + ? customAppBar != null + ? customAppBar + : appBar = AppBarWidget( + appBarTitle: appBarTitle, + appBarIcons: appBarIcons, + showHomeAppBarIcon: showHomeAppBarIcon, + isPharmacy: isPharmacy, + showPharmacyCart: showPharmacyCart, + isOfferPackages: isOfferPackages, + showOfferPackagesCart: showOfferPackagesCart, + isShowDecPage: isShowDecPage, + ) : null, bottomSheet: bottomSheet, body: SafeArea( @@ -177,6 +183,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { } String _badgeText = "0"; + class AppBarWidgetState extends State { @override Widget build(BuildContext context) { @@ -221,7 +228,8 @@ class AppBarWidgetState extends State { ? IconButton( icon: Badge( shape: BadgeShape.circle, - badgeContent: Text(_badgeText, style: TextStyle(color: Colors.white)), + badgeContent: + Text(_badgeText, style: TextStyle(color: Colors.white)), child: Icon(Icons.shopping_cart)), color: Colors.white, onPressed: () { @@ -365,10 +373,10 @@ class _RobotIcon extends State { bottom: -15); } - // setAnimation() async { - // /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || - // // var animation = - // // IS_TEXT_COMPLETED == ? true : false; +// setAnimation() async { +// /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || +// // var animation = +// // IS_TEXT_COMPLETED == ? true : false; - // } +// } }