diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index bbdb5f8c..806a2081 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -33,13 +33,14 @@ import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_ bool isInWishlist = false; int price = 0; -dynamic itemID; +var itemID; var product; var customerId; var item; dynamic languageID; List wishlistData; + class PharmacyPage extends StatefulWidget { // final PharmacyProduct product; // PharmacyPage(this.product); @@ -49,7 +50,7 @@ class PharmacyPage extends StatefulWidget { } class _PharmacyPageState extends State { - dynamic wishlistVar; +// dynamic wishlistVar; getLanguageID() async { languageID = await sharedPref.getString(APP_LANGUAGE); @@ -61,7 +62,7 @@ class _PharmacyPageState extends State { var model; // String ProductId="4561"; //String id ="3608"; - String ProductId = ""; + String productId = ""; String id = ""; @override void initState() { @@ -123,7 +124,7 @@ class _PharmacyPageState extends State { ? MediaQuery.of(context).size.height * 0.28 : 0, padding: - EdgeInsets.symmetric(horizontal: 18.0, vertical: 18.0), + EdgeInsets.symmetric(horizontal: 18.0, vertical: 14.0), // height: MediaQuery.of(context).size.height * 0.28, // width: 200.0, // height: MediaQuery.of(context).size.height / 4 + 20, @@ -221,11 +222,9 @@ class _PharmacyPageState extends State { BorderRadius.circular( 30.0)), child: Text( - model - .prescriptionsList[ - index] - .isInOutPatientDescription - .toString(), + languageID == "ar" + ? model.prescriptionsList[index].isInOutPatientDescriptionN.toString() + : model.prescriptionsList[index].isInOutPatientDescription.toString(), style: TextStyle( color: Colors.white, fontSize: 15.0, @@ -341,257 +340,238 @@ class _PharmacyPageState extends State { : Container(), ), ), - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).recommended, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - borderColor: Colors.green, - textColor: Colors.green, - vPadding: 6, - hPadding: 4, - handler: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - RecommendedProductPage())); - }, - ), - ], - ), - ), - Container( - height: model.recommendedProductList.length > 0 - ? MediaQuery.of(context).size.height * 0.30 - : 0, - margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), -// padding: EdgeInsets.symmetric(horizontal: 5.0, vertical: 22.0), -// margin: EdgeInsets.only(left: 10), - child: BaseView( - onModelReady: (model) => - model.getRecommendedProducts(ProductId), - builder: (_, model, wi) => model - .recommendedProductList.length != - null - ? ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - physics: ScrollPhysics(), - // physics: NeverScrollableScrollPhysics(), - itemCount: model.recommendedProductList.length, - itemBuilder: (context, index) { - return Card( - elevation: 2, - shape: RoundedRectangleBorder( - side: BorderSide( - color: Colors.grey[300], width: 2), - borderRadius: BorderRadius.circular(10)), -// - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(15), - ), - ), - padding: EdgeInsets.symmetric(horizontal: 4), - width: MediaQuery.of(context).size.width / 3, -// - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Stack(children: [ - Container( - child: Align( - alignment: Alignment.topRight, - child: //true - itemID.contains(model - .recommendedProductList[ - index] - .id) - // !isInWishlist - ? IconButton( - icon: Icon(Icons - .favorite_border), - color: Colors.grey, - iconSize: 30, - onPressed: () { - setState(() { - addToWishlistFunction( - itemID); - }); - }, - ) - : IconButton( - icon: Icon( - Icons.favorite), - color: Colors.red, - iconSize: 30, - onPressed: () { - setState(() { - deleteFromWishlistFunction( - itemID); - }); - }, - ) -// - ), - ), - Container( - margin: EdgeInsets.fromLTRB( - 0, 16, 10, 16), - alignment: Alignment.center, -// padding: EdgeInsets.only(left: 25, bottom: 20), - child: (model - .recommendedProductList[ - index] - .images != - null && - model - .recommendedProductList[ - index] - .images - .length > - 0) - ? Image.network( - model - .recommendedProductList[ - index] - .images[0] - .src - .toString(), -// item.images[0].src, - fit: BoxFit.cover, - height: 60, - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 60, - ), - ), - Container( - width: model - .recommendedProductList[ - index] - .rxMessage != - null - ? MediaQuery.of(context) - .size - .width / - 5 - : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(6)), - ), - child: Texts( - model.recommendedProductList[index] - .rxMessage != - null - ? model - .recommendedProductList[ - index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ), - ), - ]), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - model - .recommendedProductList[index] - .name, - style: TextStyle( - color: Colors.black, - fontSize: 13.0, -// fontWeight: FontWeight.bold, - ), - ), - Padding( -// padding: const EdgeInsets.only(top: 15, bottom: 10), - padding: const EdgeInsets.only( - top: 10, bottom: 5), - child: Texts( - "SAR ${model.recommendedProductList[index].price}", - bold: true, - fontSize: 14, - ), - ), - ], - ), - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: - EdgeInsets.only(right: 10), -// margin: EdgeInsets.only(left: 5), - child: Align( - alignment: Alignment.topLeft, - child: RatingBar.readOnly( - initialRating: model - .recommendedProductList[ - index] - .approvedRatingSum - .toDouble(), -// initialRating: productRate, - size: 13.0, - filledColor: - Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: - Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), - ), - ), - Texts( - "(${model.recommendedProductList[index].approvedTotalReviews.toString()})", -// bold: true, - fontSize: 12, - ), - ]), - ], - ), - ), - ); - }) - : Container( -// child: Text("NO DATA"), - ), - ), - ), +// Container( +// margin: EdgeInsets.fromLTRB(10, 10, 10, 10), +// child: Row( +// mainAxisAlignment: MainAxisAlignment.spaceBetween, +// children: [ +// Texts( +// TranslationBase.of(context).recommended, +// bold: true, +// ), +// BorderedButton( +// TranslationBase.of(context).viewAll, +// hasBorder: true, +// borderColor: Colors.green, +// textColor: Colors.green, +// vPadding: 6, +// hPadding: 4, +// handler: () { +// Navigator.push( +// context, +// MaterialPageRoute( +// builder: (context) => +// RecommendedProductPage(productId : "2316"))); +// }, +// ), +// ], +// ), +// ), +// Container( +// height: model.recommendedProductList.length > 0 +// ? MediaQuery.of(context).size.height * 0.32 +// : 0, +// margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), +//// padding: EdgeInsets.symmetric(horizontal: 5.0, vertical: 22.0), +//// margin: EdgeInsets.only(left: 10), +// child: BaseView( +// onModelReady: (model) => +// model.getRecommendedProducts(productId), +// builder: (_, model, wi) => model +// .recommendedProductList.length != +// null +// ? ListView.builder( +// scrollDirection: Axis.horizontal, +// shrinkWrap: true, +// physics: ScrollPhysics(), +// // physics: NeverScrollableScrollPhysics(), +// itemCount: model.recommendedProductList.length, +// itemBuilder: (context, index) { +// return Card( +// elevation: 2, +// shape: RoundedRectangleBorder( +// side: BorderSide( +// color: Colors.grey[300], width: 2), +// borderRadius: BorderRadius.circular(10)), +// margin: EdgeInsets.symmetric( +// horizontal: 8, +// vertical: 0, +// ), +// child: Container( +// decoration: BoxDecoration( +// borderRadius: BorderRadius.all( +// Radius.circular(15), +// ), +// ), +// padding: EdgeInsets.symmetric(horizontal: 4), +// width: MediaQuery.of(context).size.width / 3, +// child: Column( +// crossAxisAlignment: +// CrossAxisAlignment.start, +// children: [ +// Stack(children: [ +// Container( +// child: Align( +// alignment: Alignment.topRight, +// child: //true +// itemID.contains(model.recommendedProductList[index].id) +// // !isInWishlist +// ? IconButton( +// icon: Icon(Icons +// .favorite_border), +// color: Colors.grey, +// iconSize: 30, +// onPressed: () { +// setState(() { +// addToWishlistFunction( +// itemID); +// }); +// }, +// ) +// : IconButton( +// icon: Icon( +// Icons.favorite), +// color: Colors.red, +// iconSize: 30, +// onPressed: () { +// setState(() { +// deleteFromWishlistFunction( +// itemID); +// }); +// }, +// ) +//// +// ), +// ), +// Container( +// margin: EdgeInsets.fromLTRB( +// 0, 16, 10, 16), +// alignment: Alignment.center, +//// padding: EdgeInsets.only(left: 25, bottom: 20), +// child: (model.recommendedProductList[index].images != null && +// model.recommendedProductList[index].images.length > 0) +// ? Image.network( +// model.recommendedProductList[index].images[0].src.toString(), +//// item.images[0].src, +// fit: BoxFit.cover, +// height: 60, +// ) +// : Image.asset( +// "assets/images/no_image.png", +// fit: BoxFit.cover, +// height: 60, +// ), +// ), +// Container( +// width: model +// .recommendedProductList[ +// index] +// .rxMessage != +// null +// ? MediaQuery.of(context) +// .size +// .width / +// 5 +// : 0, +// padding: EdgeInsets.all(4), +// decoration: BoxDecoration( +// color: Color(0xffb23838), +// borderRadius: BorderRadius.only( +// topLeft: Radius.circular(6)), +// ), +// child: Texts( +// model.recommendedProductList[index] +// .rxMessage != +// null +// ? model +// .recommendedProductList[ +// index] +// .rxMessage +// : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w400, +// ), +// ), +// ]), +// Container( +// margin: EdgeInsets.symmetric( +// horizontal: 6, +// vertical: 0, +// ), +// child: Column( +// crossAxisAlignment: +// CrossAxisAlignment.start, +// children: [ +// Text( +// languageID == "ar" +// ? model.recommendedProductList[index].namen +// : model.recommendedProductList[index].name, +// style: TextStyle( +// color: Colors.black, +// fontSize: 13.0, +//// fontWeight: FontWeight.bold, +// ), +// ), +// Padding( +//// padding: const EdgeInsets.only(top: 15, bottom: 10), +// padding: const EdgeInsets.only( +// top: 10, bottom: 5), +// child: Texts( +// "SAR ${model.recommendedProductList[index].price}", +// bold: true, +// fontSize: 14, +// ), +// ), +// ], +// ), +// ), +// Row( +// crossAxisAlignment: +// CrossAxisAlignment.start, +// children: [ +// Container( +// padding: +// EdgeInsets.only(right: 10), +//// margin: EdgeInsets.only(left: 5), +// child: Align( +// alignment: Alignment.topLeft, +// child: RatingBar.readOnly( +// initialRating: model +// .recommendedProductList[ +// index] +// .approvedRatingSum +// .toDouble(), +//// initialRating: productRate, +// size: 13.0, +// filledColor: +// Colors.yellow[700], +// emptyColor: Colors.grey[500], +// isHalfAllowed: true, +// halfFilledIcon: +// Icons.star_half, +// filledIcon: Icons.star, +// emptyIcon: Icons.star, +// ), +// ), +// ), +// Texts( +// "(${model.recommendedProductList[index].approvedTotalReviews.toString()})", +//// bold: true, +// fontSize: 12, +// ), +// ]), +// ], +// ), +// ), +// ); +// }) +// : Container( +//// child: Text("NO DATA"), +// ), +// ), +// ), Container( margin: EdgeInsets.fromLTRB(10, 10, 10, 0), child: Row( diff --git a/lib/pages/pharmacies/screens/recommended-product-page.dart b/lib/pages/pharmacies/screens/recommended-product-page.dart index df5e08d3..28e3cce3 100644 --- a/lib/pages/pharmacies/screens/recommended-product-page.dart +++ b/lib/pages/pharmacies/screens/recommended-product-page.dart @@ -12,17 +12,25 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; dynamic languageID; bool isInWishlist = false; +int price = 0; var itemID; +var product; +var customerId; class RecommendedProductPage extends StatefulWidget { + String productId ; + RecommendedProductPage({this.productId}); + @override - _RecommendedProductPageState createState() => _RecommendedProductPageState(); + _RecommendedProductPageState createState() => _RecommendedProductPageState(productId: productId); } class _RecommendedProductPageState extends State with SingleTickerProviderStateMixin { List recommendedProductList = []; - String ProductId = "4561"; + String productId; + _RecommendedProductPageState({this.productId}); + String id = ""; bool styleOne = true; bool styleTwo = false; Icon styleIcon = Icon( @@ -35,9 +43,15 @@ class _RecommendedProductPageState extends State languageID = await sharedPref.getString(APP_LANGUAGE); } + // String productId = "4561"; + // String productId = ""; + @override void initState() { - super.initState(); + checkWishlist(); + userInfo(id, product); + print("-------------this--------------"); + print(itemID); } @override @@ -46,364 +60,366 @@ class _RecommendedProductPageState extends State final double itemHeight = ((size.height - kToolbarHeight - 24) * 0.80) / 2; final double itemWidth = size.width / 2; return BaseView( - onModelReady: (model) => model.getRecommendedProducts(ProductId), + onModelReady: (model) => model.getRecommendedProducts(productId), builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).recommended, baseViewModel: model, isShowAppBar: true, isPharmacy: true, backgroundColor: Colors.white, - body: Column(children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.only( - top: 8, - bottom: 10, - left: 10, - ), - child: Text( - model.recommendedProductList.length.toString(), - style: TextStyle( - color: Colors.black, - fontSize: 14.0, + body: SingleChildScrollView( + child: Column(children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only( + top: 8, + bottom: 10, + left: 10, + ), + child: Text( + model.recommendedProductList.length.toString(), + style: TextStyle( + color: Colors.black, + fontSize: 14.0, + ), ), ), - ), - Container( - padding: EdgeInsets.only(top: 8, bottom: 10, left: 8), - child: Text( - TranslationBase.of(context).result, - style: TextStyle( - color: Colors.black, - fontSize: 14.0, + Container( + padding: EdgeInsets.only(top: 8, bottom: 10, left: 8), + child: Text( + TranslationBase.of(context).result, + style: TextStyle( + color: Colors.black, + fontSize: 14.0, + ), ), ), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: SizedBox( - child: Container( - width: 1, - color: Colors.grey, + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: SizedBox( + child: Container( + width: 1, + color: Colors.grey, + ), ), ), - ), - Container( - child: Image.asset( - 'assets/images/pharmacy/sort.png', - width: 20, - height: 20, + Container( + child: Image.asset( + 'assets/images/pharmacy/sort.png', + width: 20, + height: 20, // color: Colors.red, + ), ), - ), - Container( - child: Text( - TranslationBase.of(context).sort, - style: TextStyle( - color: Colors.black, - fontSize: 14.0, + Container( + child: Text( + TranslationBase.of(context).sort, + style: TextStyle( + color: Colors.black, + fontSize: 14.0, + ), ), ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: SizedBox( - child: Container( - width: 1, - color: Colors.grey, + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: SizedBox( + child: Container( + width: 1, + color: Colors.grey, + ), ), ), - ), - Divider( - thickness: 1.0, - color: Colors.black12, - ), - Padding( - padding: EdgeInsets.all(8.0), - child: InkWell( - child: styleIcon, - onTap: () { - setState(() { - if (styleOne == true) { - styleOne = false; - styleTwo = true; - styleIcon = Icon( - Icons.auto_awesome_mosaic, - color: Colors.blue, - size: 29.0, - ); - } else { - styleOne = true; - styleTwo = false; - styleIcon = Icon( - Icons.widgets_sharp, - color: Colors.blue, - size: 29.0, - ); - } - }); - }, + Divider( + thickness: 1.0, + color: Colors.black12, ), - ), - ], - ), - ]), - SizedBox( - height: 2, - ), - Divider( - color: Colors.grey[350], - height: 10, - thickness: 6, - indent: 0, - endIndent: 0, - ), - styleOne == true - ? Container( - margin: EdgeInsets.all(5.0), - child: model.recommendedProductList.length != null - ? CustomScrollView( - primary: false, - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - slivers: [ - SliverPadding( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), - sliver: SliverGrid.count( - crossAxisCount: 2, - childAspectRatio: (itemWidth / itemHeight), - children: model.recommendedProductList - .map((e) => Card( - elevation: 2, - shape: RoundedRectangleBorder( - side: BorderSide( - color: Colors.grey[300], - width: 2), - borderRadius: - BorderRadius.circular( - 10)), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all( - Radius.circular(15), - ), + Padding( + padding: EdgeInsets.all(8.0), + child: InkWell( + child: styleIcon, + onTap: () { + setState(() { + if (styleOne == true) { + styleOne = false; + styleTwo = true; + styleIcon = Icon( + Icons.auto_awesome_mosaic, + color: Colors.blue, + size: 29.0, + ); + } else { + styleOne = true; + styleTwo = false; + styleIcon = Icon( + Icons.widgets_sharp, + color: Colors.blue, + size: 29.0, + ); + } + }); + }, + ), + ), + ], + ), + ]), + SizedBox( + height: 2, + ), + Divider( + color: Colors.grey[350], + height: 10, + thickness: 6, + indent: 0, + endIndent: 0, + ), + styleOne == true + ? Container( + margin: EdgeInsets.all(5.0), + child: model.recommendedProductList.length != null + ? CustomScrollView( + primary: false, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + slivers: [ + SliverPadding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), + sliver: SliverGrid.count( + crossAxisCount: 2, + childAspectRatio: (itemWidth / itemHeight), + children: model.recommendedProductList + .map((e) => Card( + elevation: 2, + shape: RoundedRectangleBorder( + side: BorderSide( + color: Colors.grey[300], + width: 2), + borderRadius: + BorderRadius.circular( + 10)), + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 11, ), - padding: EdgeInsets.symmetric( - horizontal: 4), - width: MediaQuery.of(context) - .size - .width / - 3, + child: Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all( + Radius.circular(15), + ), + ), + padding: EdgeInsets.symmetric( + horizontal: 4), + width: MediaQuery.of(context) + .size.width / 3, // - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Stack(children: [ - Container( - child: Align( - alignment: - Alignment - .topRight, - child: //true - //wishlistVar[index].id.contains(model.recommendedProductList[index].id) - !isInWishlist - ? IconButton( - icon: - Icon(Icons.favorite_border), - color: - Colors.grey, - iconSize: - 30, - onPressed: - () { - setState(() { - addToWishlistFunction(itemID); - }); - }, - ) - : IconButton( - icon: - Icon(Icons.favorite), - color: - Colors.red, - iconSize: - 30, - onPressed: - () { - setState(() { - deleteFromWishlistFunction(itemID); - }); - }, - ) + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Stack(children: [ + Container( + child: Align( + alignment: + Alignment + .topRight, + child: + itemID.contains(e.id) + // !isInWishlist + ? IconButton( + icon: + Icon(Icons.favorite_border), + color: + Colors.grey, + iconSize: + 30, + onPressed: + () { + setState(() { + addToWishlistFunction(itemID); + }); + }, + ) + : + IconButton( + icon: + Icon(Icons.favorite), + color: + Colors.red, + iconSize: + 30, + onPressed: + () { + setState(() { + deleteFromWishlistFunction(itemID); + }); + }, + ) // - ), - ), - Container( - margin: EdgeInsets - .fromLTRB(0, 16, - 10, 16), - alignment: - Alignment.center, + ), + ), + Container( + margin: EdgeInsets + .fromLTRB(0, 16, + 10, 16), + alignment: + Alignment.center, // padding: EdgeInsets.only(left: 25, bottom: 20), - child: (e.images != - null && - e.images.length > - 0) - ? Image.network( - e.images[0] - .src - .toString(), + child: (e.images != + null && + e.images.length > + 0) + ? Image.network( + e.images[0] + .src + .toString(), // item.images[0].src, - fit: BoxFit - .cover, - height: 60, - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit - .cover, - height: 60, - ), - ), - Container( - width: e.rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + fit: BoxFit + .cover, + height: 60, + ) + : Image.asset( + "assets/images/no_image.png", + fit: BoxFit + .cover, + height: 60, + ), ), - child: Texts( - e.rxMessage != null - ? e.rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, + Container( + width: e.rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: Texts( + e.rxMessage != null + ? e.rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ), ), - ), - ]), - Container( - margin: EdgeInsets - .symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Text( - e.name, - style: TextStyle( - color: Colors - .black, - fontSize: 13.0, + ]), + Container( + margin: EdgeInsets + .symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + languageID == "ar" + ? e.namen + : e.name, + style: TextStyle( + color: Colors + .black, + fontSize: 13.0, // fontWeight: FontWeight.bold, + ), ), - ), - Padding( + Padding( // padding: const EdgeInsets.only(top: 15, bottom: 10), - padding: - const EdgeInsets - .only( - top: 10, - bottom: - 5), - child: Texts( - "SAR ${e.price}", - bold: true, - fontSize: 14, + padding: + const EdgeInsets + .only( + top: 10, + bottom: + 5), + child: Texts( + "SAR ${e.price}", + bold: true, + fontSize: 14, + ), ), - ), - ], + ], + ), ), - ), - Row( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Container( - padding: EdgeInsets - .only( - right: - 10), + Row( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Container( + padding: EdgeInsets + .only( + right: + 10), // margin: EdgeInsets.only(left: 5), - child: Align( - alignment: - Alignment - .topLeft, - child: RatingBar - .readOnly( - initialRating: e - .approvedRatingSum - .toDouble(), + child: Align( + alignment: + Alignment + .topLeft, + child: RatingBar + .readOnly( + initialRating: e + .approvedRatingSum + .toDouble(), // initialRating: productRate, - size: 13.0, - filledColor: - Colors.yellow[ - 700], - emptyColor: - Colors.grey[ - 500], - isHalfAllowed: - true, - halfFilledIcon: - Icons - .star_half, - filledIcon: - Icons - .star, - emptyIcon: - Icons - .star, + size: 13.0, + filledColor: + Colors.yellow[ + 700], + emptyColor: + Colors.grey[ + 500], + isHalfAllowed: + true, + halfFilledIcon: + Icons + .star_half, + filledIcon: + Icons + .star, + emptyIcon: + Icons + .star, + ), ), ), - ), - Texts( - "(${e.approvedTotalReviews.toString()})", + Texts( + "(${e.approvedTotalReviews.toString()})", // bold: true, - fontSize: 12, - ), - ]), - ], + fontSize: 12, + ), + ]), + ], + ), ), - ), - ) + ) // Column( // crossAxisAlignment: // CrossAxisAlignment.start, @@ -510,8 +526,8 @@ class _RecommendedProductPageState extends State // ]), // ], // ), - ) - .toList(), + ) + .toList(), // children:[ // ListView.builder( // scrollDirection: Axis.vertical, @@ -631,193 +647,193 @@ class _RecommendedProductPageState extends State // } // ), // ] + ), ), - ), - ]) - : Container(), - ) - : Container( - height: model.recommendedProductList.length > 0 - ? MediaQuery.of(context).size.height * 0.60 - : 0, - child: ListView.builder( - physics: ScrollPhysics(), + ]) + : Container(), + ) + : Container( + height: model.recommendedProductList.length > 0 + ? MediaQuery.of(context).size.height * 0.60 + : 0, + child: ListView.builder( + physics: ScrollPhysics(), // physics: NeverScrollableScrollPhysics(), - itemCount: model.recommendedProductList.length, - itemBuilder: (context, index) { - return Card( - elevation: 2, - shape: RoundedRectangleBorder( - side: - BorderSide(color: Colors.grey[300], width: 2), - borderRadius: BorderRadius.circular(10)), + itemCount: model.recommendedProductList.length, + itemBuilder: (context, index) { + return Card( + elevation: 2, + shape: RoundedRectangleBorder( + side: + BorderSide(color: Colors.grey[300], width: 2), + borderRadius: BorderRadius.circular(10)), // - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(15), - ), + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, ), - padding: EdgeInsets.symmetric(horizontal: 5), - width: MediaQuery.of(context).size.width / 3, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(15), + ), + ), + padding: EdgeInsets.symmetric(horizontal: 5), + width: MediaQuery.of(context).size.width / 3, // - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Stack(children: [ - Container( - child: Align( - alignment: Alignment.topRight, - child: //true - //wishlistVar[index].id.contains(model.recommendedProductList[index].id) - !isInWishlist - ? IconButton( - icon: Icon( - Icons.favorite_border), - color: Colors.grey, - iconSize: 30, - onPressed: () { - setState(() { - addToWishlistFunction( - itemID); - }); - }, - ) - : IconButton( - icon: Icon(Icons.favorite), - color: Colors.red, - iconSize: 30, - onPressed: () { - setState(() { - deleteFromWishlistFunction( - itemID); - }); - }, - ) + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack(children: [ + Container( + child: Align( + alignment: Alignment.topRight, + child: //true + //wishlistVar[index].id.contains(model.recommendedProductList[index].id) + !isInWishlist + ? IconButton( + icon: Icon( + Icons.favorite_border), + color: Colors.grey, + iconSize: 30, + onPressed: () { + setState(() { + addToWishlistFunction( + itemID); + }); + }, + ) + : IconButton( + icon: Icon(Icons.favorite), + color: Colors.red, + iconSize: 30, + onPressed: () { + setState(() { + deleteFromWishlistFunction( + itemID); + }); + }, + ) // - ), - ), - Container( - margin: EdgeInsets.fromLTRB(0, 16, 10, 16), - alignment: Alignment.center, + ), + ), + Container( + margin: EdgeInsets.fromLTRB(0, 16, 10, 16), + alignment: Alignment.center, // padding: EdgeInsets.only(left: 25, bottom: 20), - child: (model.recommendedProductList[index] - .images != - null && - model.recommendedProductList[index] - .images.length > - 0) - ? Image.network( - model.recommendedProductList[index] - .images[0].src - .toString(), + child: (model.recommendedProductList[index] + .images != + null && + model.recommendedProductList[index] + .images.length > + 0) + ? Image.network( + model.recommendedProductList[index] + .images[0].src + .toString(), // item.images[0].src, - fit: BoxFit.cover, - height: 60, - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 60, - ), - ), - Container( - width: model.recommendedProductList[index] - .rxMessage != - null - ? MediaQuery.of(context).size.width / 5 - : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(6)), + fit: BoxFit.cover, + height: 60, + ) + : Image.asset( + "assets/images/no_image.png", + fit: BoxFit.cover, + height: 60, + ), ), - child: Texts( - model.recommendedProductList[index] + Container( + width: model.recommendedProductList[index] .rxMessage != null - ? model.recommendedProductList[index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, + ? MediaQuery.of(context).size.width / 5 + : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(6)), + ), + child: Texts( + model.recommendedProductList[index] + .rxMessage != + null + ? model.recommendedProductList[index] + .rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ), ), - ), - ]), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 2, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - model - .recommendedProductList[index].name, - style: TextStyle( - color: Colors.black, - fontSize: 13.0, + ]), + Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 2, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + model + .recommendedProductList[index].name, + style: TextStyle( + color: Colors.black, + fontSize: 13.0, // fontWeight: FontWeight.bold, + ), ), - ), - Padding( + Padding( // padding: const EdgeInsets.only(top: 15, bottom: 10), - padding: const EdgeInsets.only( - top: 10, bottom: 5), - child: Texts( - "SAR ${model.recommendedProductList[index].price}", - bold: true, - fontSize: 14, + padding: const EdgeInsets.only( + top: 10, bottom: 5), + child: Texts( + "SAR ${model.recommendedProductList[index].price}", + bold: true, + fontSize: 14, + ), ), - ), - ], + ], + ), ), - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.only( - right: 10, bottom: 10), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only( + right: 10, bottom: 10), // margin: EdgeInsets.only(left: 5), - child: Align( - alignment: Alignment.topLeft, - child: RatingBar.readOnly( - initialRating: model - .recommendedProductList[index] - .approvedRatingSum - .toDouble(), + child: Align( + alignment: Alignment.topLeft, + child: RatingBar.readOnly( + initialRating: model + .recommendedProductList[index] + .approvedRatingSum + .toDouble(), // initialRating: productRate, - size: 13.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + size: 13.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), ), ), - ), - Texts( - "(${model.recommendedProductList[index].approvedTotalReviews.toString()})", + Texts( + "(${model.recommendedProductList[index].approvedTotalReviews.toString()})", // bold: true, - fontSize: 12, - ), - ]), - ], + fontSize: 12, + ), + ]), + ], + ), ), - ), - ); + ); // Container( // height: 30, // padding: EdgeInsets.only( left: 10.0, top: 10, right: 10), @@ -927,22 +943,55 @@ class _RecommendedProductPageState extends State // ], // ), // ); - }), - ), - ]), + }), + ), + ]), + ), ), ); } -} + checkWishlist() async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.checkWishlistData(); + for (int i = 0; i < x.wishListItems.length; i++) { + // itemID = x.wishListItems[i].id; + print("-------------wishlist---------------"); + print(itemID); +// print(product.id); + print(x.wishListItems[i].productId); + if (itemID == x.wishListItems[i].productId) { + isInWishlist = true; +// print('in wishlist'); + break; + } else { + isInWishlist = false; +// print('not in wishlist'); + } + } + } -addToWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlist = true; - await x.addToWishlistData(itemID); -} + 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; + } -deleteFromWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlist = false; - await x.addToWishlistData(itemID); + + addToWishlistFunction(itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + isInWishlist = true; + await x.addToWishlistData(itemID); + } + + deleteFromWishlistFunction(itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + isInWishlist = false; + await x.addToWishlistData(itemID); + } } + diff --git a/lib/pages/pharmacy/order/OrderDetails.dart b/lib/pages/pharmacy/order/OrderDetails.dart index 5e9b26ea..9c3c91b9 100644 --- a/lib/pages/pharmacy/order/OrderDetails.dart +++ b/lib/pages/pharmacy/order/OrderDetails.dart @@ -332,17 +332,14 @@ class _OrderDetailsPageState extends State { itemBuilder: (context, index) { return Container( child: productTile( - productName: model - .orderListModel[0].orderItems[index].product.name + productName: languageID == "ar" + ? model.orderListModel[0].orderItems[index].product.namen.toString() + : model.orderListModel[0].orderItems[index].product.name.toString(), + productPrice: model.orderListModel[0].orderItems[index].product.price .toString(), - productPrice: model - .orderListModel[0].orderItems[index].product.price - .toString(), - productRate: model.orderListModel[0].orderItems[index] - .product.approvedRatingSum + productRate: model.orderListModel[0].orderItems[index].product.approvedRatingSum .toDouble(), - productReviews: model.orderListModel[0] - .orderItems[index].product.approvedTotalReviews, + productReviews: model.orderListModel[0].orderItems[index].product.approvedTotalReviews, totalPrice: "${(model.orderListModel[0].orderItems[index].product.price * model.orderListModel[0].orderItems[index].quantity).toStringAsFixed(2)}", qyt: model