diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 0395a4ba..9b05635b 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -462,7 +462,8 @@ class BaseAppClient { body: json.encode(body), headers: { 'Content-Type': 'application/json', - 'Accept': 'application/json' + 'Accept': 'application/json', + 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', }); final int statusCode = response.statusCode; print("statusCode :$statusCode"); diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index e3a6255e..030fd4b2 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -27,7 +27,6 @@ class ProductDetailViewModel extends BaseViewModel{ Future getProductReviewsData(productID) async { - print('ENAD REview'); hasError = false; setState(ViewState.Busy); await _productDetailService.getProductReviews(productID); @@ -39,7 +38,6 @@ class ProductDetailViewModel extends BaseViewModel{ } Future getProductLocationData() async { - print('ENAD in model view'); hasError = false; setState(ViewState.Busy); await _productLocationService.getProductAvailabiltyDetail(); diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 3a46f45c..41a66683 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -159,7 +159,7 @@ class _LandingPagePharmacyState extends State { PharmacyPage(), PharmacyCategorisePage(), // OffersCategorisePage(), - WishlistPage(), + WishlistPage(false), PharmacyProfilePage(), // Container( // child: Text('text'), diff --git a/lib/pages/pharmacies/compare.dart b/lib/pages/pharmacies/compare.dart index d1872187..505533cb 100644 --- a/lib/pages/pharmacies/compare.dart +++ b/lib/pages/pharmacies/compare.dart @@ -196,7 +196,9 @@ class _slideDetailState extends State { alignment: Alignment.topLeft, child: RichText( text: TextSpan( - text: widget.data[index].specifications[0].name, + text: widget.data[index].specifications != null ? + widget.data[index].specifications[0].name : + "No data", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, @@ -211,7 +213,9 @@ class _slideDetailState extends State { alignment: Alignment.topLeft, child: RichText( text: TextSpan( - text: widget.data[index].specifications[1].name, + text: widget.data[index].specifications != null ? + widget.data[index].specifications[1].name : + "No data", style: TextStyle( color: Colors.black54, fontSize: 15, @@ -234,7 +238,9 @@ class _slideDetailState extends State { alignment: Alignment.topLeft, child: RichText( text: TextSpan( - text: widget.data[index].specifications[2].name, + text:widget.data[index].specifications != null ? + widget.data[index].specifications[2].name : + "No data", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, @@ -249,7 +255,9 @@ class _slideDetailState extends State { alignment: Alignment.topLeft, child: RichText( text: TextSpan( - text: widget.data[index].specifications[3].name, + text: widget.data[index].specifications != null ? + widget.data[index].specifications[3].name : + "No data", style: TextStyle( color: Colors.black54, fontSize: 15, @@ -272,7 +280,9 @@ class _slideDetailState extends State { alignment: Alignment.topLeft, child: RichText( text: TextSpan( - text: widget.data[index].specifications[4].name, + text:widget.data[index].specifications != null ? + widget.data[index].specifications[4].name : + "No data", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, @@ -287,7 +297,9 @@ class _slideDetailState extends State { alignment: Alignment.topLeft, child: RichText( text: TextSpan( - text: widget.data[index].specifications[5].name, + text:widget.data[index].specifications != null ? + widget.data[index].specifications[5].name : + "No data", style: TextStyle( color: Colors.black54, fontSize: 15, diff --git a/lib/pages/pharmacies/product-brands.dart b/lib/pages/pharmacies/product-brands.dart index b2ef5f4e..56b67127 100644 --- a/lib/pages/pharmacies/product-brands.dart +++ b/lib/pages/pharmacies/product-brands.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/pages/final_products_page.dart'; import 'package:diplomaticquarterapp/pages/login/register-info.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/search_brands_page.dart'; import 'package:diplomaticquarterapp/pages/search_products_page.dart'; @@ -61,7 +62,7 @@ class _ProductBrandsPageState extends State { height: 220, width: double.infinity, color: Colors.white, - child: topBrand(), + child: topBrand(context), ), SizedBox( height: 10, @@ -125,7 +126,11 @@ class _ProductBrandsPageState extends State { ), ), onTap: (){ - print("ENAD"); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => FinalProductsPage(id: model.brandsListList[index].id.toString(),)), + ); }, ); }), @@ -139,7 +144,7 @@ class _ProductBrandsPageState extends State { } -topBrand() { +topBrand(BuildContext context) { return BaseView( onModelReady: (model) => model.getTopBrandsData(), builder: (_, model, wi) => GridView.count( @@ -180,7 +185,11 @@ topBrand() { ), ), onTap: (){ - print("ENAD"); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => FinalProductsPage(id: model.topBrandsListList[index].id.toString(),)), + ); }, ), ], diff --git a/lib/pages/pharmacies/product_detail.dart b/lib/pages/pharmacies/product_detail.dart index 8d9d6d35..6d02b465 100644 --- a/lib/pages/pharmacies/product_detail.dart +++ b/lib/pages/pharmacies/product_detail.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/login/welcome.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; @@ -18,8 +19,7 @@ int price = 0; var languageID; bool isOverQuantity = false; bool isInWishlit = false; -var itemID; -var product; +String itemID; var customerId; CompareList compareItems = new CompareList(); PharmacyProduct specificationData; @@ -38,15 +38,46 @@ class __ProductDetailPageState extends State { bool isAvailabilty = false; dynamic wishlistItems; + checkWishlist() async { + GifLoaderDialogUtils.showMyDialog(context); + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.checkWishlistData(); + +// isInWishlit = x.wishListItems.map((e) => e.id.toString()).toList().contains(itemID); + + for (int i = 0; i < x.wishListItems.length; i++) { + if (itemID == x.wishListItems[i].product.id) { + isInWishlit = true; + break; + } else { + isInWishlit = false; + } + } + GifLoaderDialogUtils.hideDialog(context); + setState(() {}); + } + void initState() { price = 1; specificationData = widget.product; - setState(() { - customerId = userInfo(widget.product.id, widget.product); - }); + userInfo(); super.initState(); } + void userInfo() async { + print(specificationData); + customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + if (customerId != null) { + itemID = widget.product.id; + checkWishlist(); +// getSpecificationData(itemID); + } + print("customerId:$customerId"); + + setState(() {}); +// getSpecificationData(itemID); + } + Widget build(BuildContext context) { return customerId != null ? DetailPageScafold( @@ -80,12 +111,18 @@ class __ProductDetailPageState extends State { alignment: Alignment.centerRight, child: languageID == 'ar' ? Text( - widget.product.discountDescriptionn, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), + widget.product + .discountDescriptionn, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), ) : Text( - widget.product.discountDescription, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), + widget.product + .discountDescription, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), ), ), ), @@ -96,7 +133,8 @@ class __ProductDetailPageState extends State { flex: 0, child: Container( child: Image( - image: AssetImage('assets/images/offer.png'), + image: AssetImage( + 'assets/images/offer.png'), ), ), ), @@ -174,7 +212,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).details, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -202,7 +242,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).reviews, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -230,7 +272,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).availability, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -258,7 +302,10 @@ class __ProductDetailPageState extends State { Container( child: Text( TranslationBase.of(context).description, - style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), ), ), SizedBox( @@ -266,8 +313,13 @@ class __ProductDetailPageState extends State { ), Container( child: Text( - languageID == 'ar' ? widget.product.shortDescriptionn : widget.product.shortDescription ?? "", - style: TextStyle(fontSize: 16, fontFamily: 'WorkSans-Regular'), + languageID == 'ar' + ? widget.product.shortDescriptionn + : widget.product.shortDescription ?? + "", + style: TextStyle( + fontSize: 16, + fontFamily: 'WorkSans-Regular'), ), ), SizedBox( @@ -276,7 +328,10 @@ class __ProductDetailPageState extends State { Container( child: Text( TranslationBase.of(context).howToUse, - style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), ), ), SizedBox( @@ -284,8 +339,12 @@ class __ProductDetailPageState extends State { ), Container( child: Text( - languageID == 'ar' ? widget.product.fullDescriptionn : widget.product.fullDescription, - style: TextStyle(fontSize: 16, fontFamily: 'WorkSans-Regular'), + languageID == 'ar' + ? widget.product.fullDescriptionn + : widget.product.fullDescription, + style: TextStyle( + fontSize: 16, + fontFamily: 'WorkSans-Regular'), ), ), ], @@ -293,98 +352,161 @@ class __ProductDetailPageState extends State { ) : isReviews ? BaseView( - onModelReady: (model) => model.getProductReviewsData(widget.product.id), - builder: (_, model, wi) => - model.productDetailService.length != 0 && model.productDetailService[0].reviews.length != 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model.productDetailService[0].reviews.length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model.productDetailService[0].reviews[index].customerId.toString(), - style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), - ), - ), - Container( - margin: EdgeInsets.only(left: 210), - child: RatingBar.readOnly( - initialRating: model.productDetailService[0].reviews[index].rating.toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), - ), - ], + onModelReady: (model) => + model.getProductReviewsData( + widget.product.id), + builder: (_, model, wi) => model + .productDetailService + .length != + 0 && + model.productDetailService[0] + .reviews.length != + 0 + ? ListView.builder( + physics: ScrollPhysics(), + itemCount: model + .productDetailService[0] + .reviews + .length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemBuilder: (BuildContext context, + int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + child: Row( + children: [ + Container( + child: Text( + model + .productDetailService[ + 0] + .reviews[ + index] + .customerId + .toString(), + style: TextStyle( + fontSize: 17, + color: Colors + .grey, + fontWeight: + FontWeight + .w600), + ), ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - model.productDetailService[0].reviews[index].reviewText, - style: TextStyle(fontSize: 20), + Container( + margin: + EdgeInsets.only( + left: 210), + child: RatingBar + .readOnly( + initialRating: model + .productDetailService[ + 0] + .reviews[ + index] + .rating + .toDouble(), + size: 15.0, + filledColor: + Colors.yellow[ + 700], + emptyColor: Colors + .grey[500], + isHalfAllowed: + true, + halfFilledIcon: + Icons + .star_half, + filledIcon: + Icons.star, + emptyIcon: + Icons.star, + ), ), - ), - SizedBox( - height: 50, - ), - Divider(height: 1, color: Colors.grey), - ], + ], + ), ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text('No Reviews Available'), - ), + SizedBox( + height: 10, + ), + Container( + child: Text( + model + .productDetailService[ + 0] + .reviews[index] + .reviewText, + style: TextStyle( + fontSize: 20), + ), + ), + SizedBox( + height: 50, + ), + Divider( + height: 1, + color: Colors.grey), + ], + ), + ); + }, + ) + : Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text('No Reviews Available'), + ), ) : isAvailabilty ? BaseView( - onModelReady: (model) => model.getProductLocationData(), - builder: (_, model, wi) => model.productLocationService.length == 0 + onModelReady: (model) => + model.getProductLocationData(), + builder: (_, model, wi) => model + .productLocationService + .length == 0 ? Container( padding: EdgeInsets.all(15), alignment: Alignment.center, - child: Text('No location Available'), + child: Text( + 'No location Available'), ) : ListView.builder( physics: ScrollPhysics(), scrollDirection: Axis.vertical, shrinkWrap: true, - itemCount: model.productLocationService.length, - itemBuilder: (BuildContext context, int index) { + itemCount: model + .productLocationService + .length, + itemBuilder: + (BuildContext context, + int index) { return Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start, children: [ Row( // crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ Expanded( flex: 1, - child: Image.network(model.productLocationService[index].projectImageUrl), + child: Image.network(model + .productLocationService[ + index] + .projectImageUrl), ), SizedBox( width: 10, @@ -392,31 +514,48 @@ class __ProductDetailPageState extends State { Expanded( flex: 4, child: Text( - model.productLocationService[index].locationDescription + + model + .productLocationService[ + index] + .locationDescription + "\n" + - fixingString(model.productLocationService[0].cityName.toString()), - style: TextStyle(fontSize: 12), + fixingString(model + .productLocationService[ + 0] + .cityName + .toString()), + style: TextStyle( + fontSize: + 12), ), ), Expanded( flex: 1, child: IconButton( - icon: Icon(Icons.location_on), - color: Colors.red, - onPressed: () {}, + icon: Icon(Icons + .location_on), + color: + Colors.red, + onPressed: + () {}, ), ), Expanded( flex: 1, child: IconButton( - icon: Icon(Icons.phone), - color: Colors.red, - onPressed: () {}, + icon: Icon(Icons + .phone), + color: + Colors.red, + onPressed: + () {}, ), ), ], ), - Divider(height: 1.2, color: Colors.grey) + Divider( + height: 1.2, + color: Colors.grey) ], ), ); @@ -431,8 +570,12 @@ class __ProductDetailPageState extends State { ], ), ), - bottomSheet: footerWidget(widget.product.stockAvailability != 'Out of stock', widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, widget.product.stockQuantity, widget.product), + bottomSheet: footerWidget( + widget.product.stockAvailability != 'Out of stock', + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + widget.product.stockQuantity, + widget.product), ) : AppScaffold( appBarTitle: 'product detail page', @@ -465,12 +608,18 @@ class __ProductDetailPageState extends State { alignment: Alignment.centerRight, child: languageID == 'ar' ? Text( - widget.product.discountDescriptionn, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), + widget.product + .discountDescriptionn, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), ) : Text( - widget.product.discountDescription, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), + widget.product + .discountDescription, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), ), ), ), @@ -481,7 +630,8 @@ class __ProductDetailPageState extends State { flex: 0, child: Container( child: Image( - image: AssetImage('assets/images/offer.png'), + image: AssetImage( + 'assets/images/offer.png'), ), ), ), @@ -551,7 +701,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).details, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -579,7 +731,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).reviews, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -607,7 +761,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).availability, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -635,7 +791,10 @@ class __ProductDetailPageState extends State { Container( child: Text( TranslationBase.of(context).description, - style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), ), ), SizedBox( @@ -643,8 +802,12 @@ class __ProductDetailPageState extends State { ), Container( child: Text( - languageID == 'ar' ? widget.product.fullDescriptionn : widget.product.fullDescription, - style: TextStyle(fontSize: 16, fontFamily: 'WorkSans-Regular'), + languageID == 'ar' + ? widget.product.fullDescriptionn + : widget.product.fullDescription, + style: TextStyle( + fontSize: 16, + fontFamily: 'WorkSans-Regular'), ), ), ], @@ -652,79 +815,132 @@ class __ProductDetailPageState extends State { ) : isReviews ? BaseView( - onModelReady: (model) => model.getProductReviewsData(widget.product.id), - builder: (_, model, wi) => - model.productDetailService.length != 0 && model.productDetailService[0].reviews.length != 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model.productDetailService[0].reviews.length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model.productDetailService[0].reviews[index].customerId.toString(), - style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), - ), - ), - Container( - margin: EdgeInsets.only(left: 210), - child: RatingBar.readOnly( - initialRating: model.productDetailService[0].reviews[index].rating.toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), - ), - ], + onModelReady: (model) => + model.getProductReviewsData( + widget.product.id), + builder: (_, model, wi) => model + .productDetailService + .length != + 0 && + model.productDetailService[0] + .reviews.length != + 0 + ? ListView.builder( + physics: ScrollPhysics(), + itemCount: model + .productDetailService[0] + .reviews + .length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemBuilder: (BuildContext context, + int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + child: Row( + children: [ + Container( + child: Text( + model + .productDetailService[ + 0] + .reviews[ + index] + .customerId + .toString(), + style: TextStyle( + fontSize: 17, + color: Colors + .grey, + fontWeight: + FontWeight + .w600), + ), ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - model.productDetailService[0].reviews[index].reviewText, - style: TextStyle(fontSize: 20), + Container( + margin: + EdgeInsets.only( + left: 210), + child: RatingBar + .readOnly( + initialRating: model + .productDetailService[ + 0] + .reviews[ + index] + .rating + .toDouble(), + size: 15.0, + filledColor: + Colors.yellow[ + 700], + emptyColor: Colors + .grey[500], + isHalfAllowed: + true, + halfFilledIcon: + Icons + .star_half, + filledIcon: + Icons.star, + emptyIcon: + Icons.star, + ), ), - ), - SizedBox( - height: 50, - ), - Divider(height: 1, color: Colors.grey), - ], + ], + ), ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text('No Reviews Available'), - ), + SizedBox( + height: 10, + ), + Container( + child: Text( + model + .productDetailService[ + 0] + .reviews[index] + .reviewText, + style: TextStyle( + fontSize: 20), + ), + ), + SizedBox( + height: 50, + ), + Divider( + height: 1, + color: Colors.grey), + ], + ), + ); + }, + ) + : Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text('No Reviews Available'), + ), ) : isAvailabilty ? BaseView( - onModelReady: (model) => model.getProductLocationData(), - builder: (_, model, wi) => ListView.builder( + onModelReady: (model) => + model.getProductLocationData(), + builder: (_, model, wi) => + ListView.builder( physics: ScrollPhysics(), scrollDirection: Axis.vertical, shrinkWrap: true, - itemCount: model.productLocationService.length, - itemBuilder: (BuildContext context, int index) { + itemCount: model + .productLocationService.length, + itemBuilder: (BuildContext context, + int index) { return Padding( padding: EdgeInsets.all(8.0), child: Column( @@ -733,11 +949,15 @@ class __ProductDetailPageState extends State { children: [ Row( // crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, children: [ Expanded( flex: 1, - child: Image.network(model.productLocationService[index].projectImageUrl), + child: Image.network(model + .productLocationService[ + index] + .projectImageUrl), ), SizedBox( width: 10, @@ -745,16 +965,25 @@ class __ProductDetailPageState extends State { Expanded( flex: 4, child: Text( - model.productLocationService[index].locationDescription + + model + .productLocationService[ + index] + .locationDescription + "\n" + - fixingString(model.productLocationService[0].cityName.toString()), - style: TextStyle(fontSize: 12), + fixingString(model + .productLocationService[ + 0] + .cityName + .toString()), + style: TextStyle( + fontSize: 12), ), ), Expanded( flex: 1, child: IconButton( - icon: Icon(Icons.location_on), + icon: Icon(Icons + .location_on), color: Colors.red, onPressed: () {}, ), @@ -762,14 +991,17 @@ class __ProductDetailPageState extends State { Expanded( flex: 1, child: IconButton( - icon: Icon(Icons.phone), + icon: + Icon(Icons.phone), color: Colors.red, onPressed: () {}, ), ), ], ), - Divider(height: 1.2, color: Colors.grey) + Divider( + height: 1.2, + color: Colors.grey) ], ), ); @@ -784,8 +1016,12 @@ class __ProductDetailPageState extends State { ], ), ), - bottomSheet: footerWidget(widget.product.stockAvailability != 'Out of stock', widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, widget.product.stockQuantity, widget.product), + bottomSheet: footerWidget( + widget.product.stockAvailability != 'Out of stock', + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + widget.product.stockQuantity, + widget.product), ); } } @@ -796,7 +1032,8 @@ class footerWidget extends StatefulWidget { final int minQuantity; final int quantityLimit; final PharmacyProduct item; - footerWidget(this.isAvailble, this.maxQuantity, this.minQuantity, this.quantityLimit, this.item); + footerWidget(this.isAvailble, this.maxQuantity, this.minQuantity, + this.quantityLimit, this.item); @override _footerWidgetState createState() => _footerWidgetState(); } @@ -826,7 +1063,8 @@ class _footerWidgetState extends State { padding: const EdgeInsets.all(8.0), child: Text( TranslationBase.of(context).quantity, - style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 15, fontWeight: FontWeight.bold), ), ), // ListView( @@ -848,7 +1086,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '1', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -873,7 +1113,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '2', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -898,7 +1140,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '3', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -923,7 +1167,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '4', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -948,7 +1194,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '5', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -973,7 +1221,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '6', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -998,7 +1248,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '7', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -1023,7 +1275,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '8', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -1048,7 +1302,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '9', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -1073,7 +1329,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '10', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -1094,7 +1352,8 @@ class _footerWidgetState extends State { Container( width: 50.0, child: TextField( - decoration: InputDecoration(labelText: 'quantity #'), + decoration: + InputDecoration(labelText: 'quantity #'), onChanged: (text) { print(price); print(widget.quantityLimit); @@ -1164,7 +1423,9 @@ class _footerWidgetState extends State { }, ), ), - !widget.isAvailble && price > 0 || price > widget.quantityLimit + !widget.isAvailble && price > 0 || + price > widget.quantityLimit || + widget.item.rxMessage != null ? Container( width: 190, height: 46, @@ -1173,7 +1434,10 @@ class _footerWidgetState extends State { alignment: Alignment.center, child: Text( TranslationBase.of(context).addToCart, - style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), ), ), ) @@ -1188,14 +1452,19 @@ class _footerWidgetState extends State { color: Colors.green, child: Text( TranslationBase.of(context).addToCart, - style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), ), ), ), SizedBox( width: 5, ), - !widget.isAvailble && price > 0 || price > widget.quantityLimit + !widget.isAvailble && price > 0 || + price > widget.quantityLimit || + widget.item.rxMessage != null ? Container( width: 120, height: 46, @@ -1204,7 +1473,10 @@ class _footerWidgetState extends State { alignment: Alignment.center, child: Text( TranslationBase.of(context).buyNow, - style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), ), ), ) @@ -1214,7 +1486,8 @@ class _footerWidgetState extends State { addToCartFunction(price, widget.item.id); Navigator.push( context, - MaterialPageRoute(builder: (context) => CartOrderPage()), + MaterialPageRoute( + builder: (context) => CartOrderPage()), ); }, child: Container( @@ -1224,7 +1497,10 @@ class _footerWidgetState extends State { color: Colors.blue, child: Text( TranslationBase.of(context).buyNow, - style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), ), ), ), @@ -1255,7 +1531,7 @@ class _productNameAndPriceState extends State { child: Row( children: [ Text( - widget.item.price.toString()+" "+ "SAR", + widget.item.price.toString() + " " + "SAR", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30), ), SizedBox( @@ -1265,12 +1541,15 @@ class _productNameAndPriceState extends State { widget.item.stockAvailability, style: widget.item.stockAvailability == 'Out of stock' ? TextStyle(fontWeight: FontWeight.bold, color: Colors.red) - : TextStyle(fontWeight: FontWeight.bold, color: Colors.green), + : TextStyle( + fontWeight: FontWeight.bold, color: Colors.green), ), SizedBox(width: 20), - widget.item.stockAvailability == 'Out of stock' && customerId != null + widget.item.stockAvailability == 'Out of stock' && + customerId != null ? InkWell( - onTap: () => notifyMeWhenAvailable(context, widget.item.id), + onTap: () => + notifyMeWhenAvailable(context, widget.item.id), child: Row(children: [ Text( TranslationBase.of(context).notifyMe, @@ -1288,34 +1567,33 @@ class _productNameAndPriceState extends State { ]), ) : Container( - margin: languageID == 'ar' ? EdgeInsets.only(right: 25) : EdgeInsets.only(left: 25), + margin: languageID == 'ar' + ? EdgeInsets.only(right: 25) + : EdgeInsets.only(left: 25), width: 40, height: 40, decoration: BoxDecoration( color: Colors.grey, borderRadius: BorderRadius.circular(30), ), - child: !isInWishlit - ? IconButton( - icon: Icon(Icons.favorite_border), - color: Colors.white, - onPressed: () { - setState(() { - addToWishlistFunction(widget.item.id); - }); -// MyStatelessWidget(); - }, - ) - : IconButton( - icon: Icon(Icons.favorite), - color: Colors.red, - onPressed: () { - setState(() { - deleteFromWishlistFunction(widget.item.id); - }); -// MyStatelessWidget(); - }, - )), + child: IconButton( + icon: Icon(!isInWishlit + ? Icons.favorite_border + : Icons.favorite), + color: !isInWishlit ? Colors.white : Colors.red, + onPressed: () async { + if (customerId != null) { + if (!isInWishlit) { + await addToWishlistFunction(widget.item.id); + } else { + await deleteFromWishlistFunction(widget.item.id); + } + } else { + return; + } + setState(() {}); + }, + )), ], ), ), @@ -1324,9 +1602,12 @@ class _productNameAndPriceState extends State { child: Container( margin: EdgeInsets.only(left: 5), child: Align( - alignment: languageID == 'ar' ? Alignment.topRight : Alignment.topLeft, + alignment: + languageID == 'ar' ? Alignment.topRight : Alignment.topLeft, child: Text( - languageID == 'ar' ? widget.item.fullDescriptionn : widget.item.fullDescription, + languageID == 'ar' + ? widget.item.fullDescriptionn + : widget.item.fullDescription, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), ), ), @@ -1358,7 +1639,9 @@ class _productNameAndPriceState extends State { child: Container( child: widget.item.rxMessage != null ? Text( - languageID == 'ar' ? widget.item.rxMessagen.toString() : widget.item.rxMessage.toString(), + languageID == 'ar' + ? widget.item.rxMessagen.toString() + : widget.item.rxMessage.toString(), style: TextStyle(color: Colors.red, fontSize: 10), ) : Container()), @@ -1377,135 +1660,6 @@ class _productNameAndPriceState extends State { } } -//productNameAndPrice(BuildContext context, item) { -// return Column( -// mainAxisAlignment: MainAxisAlignment.start, -// children: [ -// Padding( -// padding: const EdgeInsets.all(8.0), -// child: Row( -// children: [ -// Text( -// item.price.toString(), -// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30), -// ), -// SizedBox( -// width: 40, -// ), -// Text( -// item.stockAvailability, -// style: item.stockAvailability == 'Out of stock' -// ? TextStyle(fontWeight: FontWeight.bold, color: Colors.red) -// : TextStyle(fontWeight: FontWeight.bold, color: Colors.green), -// ), -// SizedBox(width: 20), -// item.stockAvailability == 'Out of stock' -// ? Text( -// TranslationBase.of(context).notifyMe, -// style: TextStyle( -// color: Colors.blue, -// decoration: TextDecoration.underline, -// ), -// ) -// : Container(), -// item.stockAvailability == 'Out of stock' -// ? Icon( -// FontAwesomeIcons.bell, -// color: Colors.blue, -// size: 15.0, -// ) -// : Container(), -// -// Container( -// margin: languageID=='ar' ? EdgeInsets.only(right: 25) : EdgeInsets.only(left: 25), -// width: 40, -// height: 40, -// decoration: BoxDecoration( -// color: Colors.grey, -// borderRadius: BorderRadius.circular(30), -// ), -// child: !isInWishlit ?IconButton( -// icon: Icon(Icons.favorite_border), -// color: Colors.white, -// onPressed: () { -// addToWishlistFunction(item.id); -//// MyStatelessWidget(); -// -// }, -// ):IconButton( -// icon: Icon(Icons.favorite), -// color: Colors.red, -// onPressed: () { -// deleteFromWishlistFunction(item.id); -//// MyStatelessWidget(); -// -// }, -// ) -// ), -// -// ], -// ), -// ), -// Padding( -// padding: const EdgeInsets.all(8.0), -// child: Container( -// margin: EdgeInsets.only(left: 5), -// child: Align( -// alignment: -// languageID == 'ar' ? Alignment.topRight : Alignment.topLeft, -// child: Text( -// languageID == 'ar' ? item.fullDescriptionn : item.fullDescription, -// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), -// ), -// ), -// ), -// ), -// Row( -// children: [ -// Expanded( -// flex: 2, -// child: Container( -// margin: EdgeInsets.only(right: 150), -// child: Align( -// alignment: Alignment.bottomLeft, -// child: RatingBar.readOnly( -// initialRating: 3, -// size: 15.0, -// filledColor: Colors.yellow[700], -// emptyColor: Colors.grey[500], -// isHalfAllowed: true, -// halfFilledIcon: Icons.star_half, -// filledIcon: Icons.star, -// emptyIcon: Icons.star, -// ), -// ), -// ), -// ), -// Expanded( -// flex: 1, -// child: Container( -// child: item.rxMessage != null -// ? Text( -// languageID == 'ar' -// ? item.rxMessagen.toString() -// : item.rxMessage.toString(), -// style: TextStyle(color: Colors.red, fontSize: 10), -// ) -// : Container()), -// ), -// item.rxMessage != null -// ? Icon( -// FontAwesomeIcons.questionCircle, -// color: Colors.red, -// size: 15.0, -// ) -// : Container(), -// ], -// ), -// ], -// ); -//} - slideDetail() { return Row( mainAxisAlignment: MainAxisAlignment.start, @@ -1524,7 +1678,9 @@ slideDetail() { ), color: Colors.white, ), - child: const Text('1', textAlign: TextAlign.center, style: TextStyle(color: Color(0xFF000000))), + child: const Text('1', + textAlign: TextAlign.center, + style: TextStyle(color: Color(0xFF000000))), ), ) ], @@ -1568,22 +1724,21 @@ addToWishlistFunction(itemID) async { deleteFromWishlistFunction(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); isInWishlit = false; - await x.addToWishlistData(itemID); + await x.deletWishlistData(itemID); } checkWishlist() async { ProductDetailViewModel x = new ProductDetailViewModel(); await x.checkWishlistData(); + +// isInWishlit = x.wishListItems.map((e) => e.id.toString()).toList().contains(itemID); + for (int i = 0; i < x.wishListItems.length; i++) { -// print(itemID); -// print(x.wishListItems[i].product.id); if (itemID == x.wishListItems[i].product.id) { isInWishlit = true; -// print('in wishlist'); break; } else { isInWishlit = false; -// print('not in wishlist'); } } } @@ -1603,21 +1758,28 @@ settingModalBottomSheet(context) { child: new Wrap( children: [ new ListTile( - leading: new Icon(Icons.shopping_cart), - title: new Text('Add to cart'), + leading: Icon(Icons.shopping_cart), + title: Text('Add to cart'), onTap: () => { - if (price > 0) {addToCartFunction(price, itemID)} else {AppToast.showErrorToast(message: "you should add quantity")} + if (price > 0) + {addToCartFunction(price, itemID)} + else + { + AppToast.showErrorToast( + message: "you should add quantity") + } }), - new ListTile( - leading: new Icon(Icons.favorite_border), - title: new Text('Add to wishlist'), + ListTile( + leading: Icon(Icons.favorite_border), + title: Text('Add to wishlist'), onTap: () => {addToWishlistFunction(itemID)}, ), - new ListTile( - leading: new Icon(Icons.compare), - title: new Text('Compare'), + ListTile( + leading: Icon(Icons.compare), + title: Text('Compare'), onTap: () => { - Provider.of(context, listen: false).addItem(specificationData), + Provider.of(context, listen: false) + .addItem(specificationData), }, ), ], @@ -1625,15 +1787,3 @@ settingModalBottomSheet(context) { ); }); } - -Future userInfo(id, product) async { - customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); - if (customerId != null) { - itemID = id; - product = product; - checkWishlist(); - } - print("customerId:$customerId"); - return customerId; -// getSpecificationData(itemID); -} diff --git a/lib/pages/pharmacies/wishlist.dart b/lib/pages/pharmacies/wishlist.dart index 822dfe89..000e8404 100644 --- a/lib/pages/pharmacies/wishlist.dart +++ b/lib/pages/pharmacies/wishlist.dart @@ -5,6 +5,8 @@ import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; class WishlistPage extends StatefulWidget { + bool showBar; + WishlistPage(this.showBar); @override _WishlistPageState createState() => _WishlistPageState(); } @@ -17,9 +19,9 @@ class _WishlistPageState extends State { onModelReady: (model) => model.getWishlistData(), builder: (_, model, wi) => AppScaffold( appBarTitle: 'Wishlist page', - isShowAppBar: false, + isShowAppBar: widget.showBar, isShowDecPage: false, - isPharmacy: false, + isPharmacy: true, baseViewModel: model, body: model.wishListList.length == 0 ? Container( diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index fb1e1c2a..6c07e2a4 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -226,7 +226,7 @@ class _ProfilePageState extends State { context, MaterialPageRoute( builder: (context) => - WishlistPage())); + WishlistPage(true))); }, child: Column( children: [ diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 0aca11a3..276151a7 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -121,7 +121,7 @@ class ProductDetailService extends BaseService { request = { "shopping_cart_item": {"quantity": 1, "shopping_cart_type": "Wishlist", "product_id": itemID, "customer_id": customerId, "language_id": 1} }; - await baseAppClient.post(GET_SHOPPING_CART, + await baseAppClient.pharmacyPost(GET_SHOPPING_CART, onSuccess: (dynamic response, int statusCode) { _wishListProducts.clear(); response['shopping_carts'].forEach((item) { @@ -172,6 +172,7 @@ class ProductDetailService extends BaseService { _productSpecification.clear(); response['specification'].forEach((item) { _productSpecification.add(SpecificationModel.fromJson(item)); + print(_productSpecification); }); }, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index 169decb0..ddf4f14f 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -66,8 +66,8 @@ class productTile extends StatelessWidget { ) : Container( margin: EdgeInsets.only(left: 10), - child: Image.asset( - "assets/images/no_image.png", + child: Image.network( + productImage, width: 80, height: 80, )