import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.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/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scafold_detail_page.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; int price = 0; var languageID; bool isOverQuantity = false; bool isInWishlit = false; String itemID; var customerId; CompareList compareItems = new CompareList(); PharmacyProduct specificationData; class ProductDetailPage extends StatefulWidget { final PharmacyProduct product; ProductDetailPage(this.product); @override __ProductDetailPageState createState() => __ProductDetailPageState(); } class __ProductDetailPageState extends State { bool isTrue = true; bool isDetails = true; bool isReviews = false; bool isAvailabilty = false; dynamic wishlistItems; var model; // String ProductId="4561"; String productId = ""; 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; 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( appBarTitle: 'product detail page', isShowAppBar: true, isPharmacy: true, isShowDecPage: false, body: SingleChildScrollView( child: Column( children: [ Container( width: double.infinity, color: Colors.white, child: Column( children: [ Image.network( widget.product.images[0].src.trim(), ), widget.product.discountDescription != null ? Container( width: double.infinity, height: 50, color: Colors.yellowAccent, child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( flex: 1, child: Container( alignment: Alignment.centerRight, child: languageID == 'ar' ? Text( widget.product .discountDescriptionn, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 17), ) : Text( widget.product .discountDescription, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 17), ), ), ), SizedBox( width: 10, ), Expanded( flex: 0, child: Container( child: Image( image: AssetImage( 'assets/images/offer.png'), ), ), ), ], ), ) : Container(), ], ), ), SizedBox( height: 4, ), Container( width: 500, height: 150, color: Colors.white, child: productNameAndPrice(context, widget.product), ), SizedBox( height: 6, ), Container( width: 500, height: 120, color: Colors.white, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Container( child: Text( TranslationBase.of(context).specification, style: TextStyle(fontWeight: FontWeight.bold), ), ), ), Divider(color: Colors.grey), Padding( padding: const EdgeInsets.all(8.0), child: Container( child: Text( "there is no data", ), ), ), ], ), ), SizedBox( height: 6, ), Container( width: 500, margin: EdgeInsets.only(bottom: 6), // height: 350, color: Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( children: [ FlatButton( onPressed: () { setState(() { isDetails = true; isReviews = false; isAvailabilty = false; }); }, child: Text( TranslationBase.of(context).details, style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), isDetails ? Container( width: 100, height: 5, color: Colors.green, ) : Container() ], ), SizedBox( width: 20, ), Column( children: [ FlatButton( onPressed: () { setState(() { isDetails = false; isReviews = true; isAvailabilty = false; }); }, child: Text( TranslationBase.of(context).reviews, style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), isReviews ? Container( width: 100, height: 5, color: Colors.green, ) : Container(), ], ), SizedBox( width: 20, ), Column( children: [ FlatButton( onPressed: () { setState(() { isDetails = false; isReviews = false; isAvailabilty = true; }); }, child: Text( TranslationBase.of(context).availability, style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), isAvailabilty ? Container( width: 100, height: 5, color: Colors.green, ) : Container(), ], ), ], ), SizedBox( height: 10, ), isDetails ? Padding( padding: const EdgeInsets.all(8.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( child: Text( TranslationBase.of(context) .description, style: TextStyle( fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), ), ), SizedBox( height: 10, ), Divider(height: 1, color: Colors.grey), SizedBox( height: 15, ), Container( child: Text( languageID == 'ar' ? widget.product.fullDescriptionn : widget.product .fullDescription ?? "", style: TextStyle( fontSize: 16, fontFamily: 'WorkSans-Regular'), ), ), SizedBox( height: 20, ), ]), ) // Container( // child: Text( // languageID == 'ar' // ? widget.product.fullDescriptionn // : widget.product.fullDescription, // style: TextStyle( // fontSize: 16, // fontFamily: 'WorkSans-Regular'), // ), // ), // SizedBox( // height: 10, // ), // Container( // child: Text( // TranslationBase.of(context).howToUse, // style: TextStyle( // fontSize: 17, // color: Colors.grey, // fontWeight: FontWeight.w600), // ), // ), // SizedBox( // height: 6, // ), // Divider( // height: 2, // color: Colors.grey), // SizedBox( // height: 10, // ), // Container( // child: Text( // languageID == 'ar' // ? widget.product.shortDescriptionn // : widget.product.shortDescription, // style: TextStyle( // fontSize: 16, // fontFamily: 'WorkSans-Regular'), // ), // ), // ], // ), // ) : 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, ), ), ], ), ), 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 ? Container( padding: EdgeInsets.all(15), alignment: Alignment.center, child: Text( 'No location Available'), ) : ListView.builder( physics: ScrollPhysics(), scrollDirection: Axis.vertical, shrinkWrap: true, itemCount: model .productLocationService .length, itemBuilder: (BuildContext context, int index) { return Padding( padding: EdgeInsets.all(8.0), child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start, children: [ Row( // crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment .start, children: [ Expanded( flex: 1, child: Image.network(model .productLocationService[ index] .projectImageUrl), ), SizedBox( width: 10, ), Expanded( flex: 4, child: Text( model .productLocationService[ index] .locationDescription + "\n" + fixingString(model .productLocationService[ 0] .cityName .toString()), style: TextStyle( fontSize: 12), ), ), Expanded( flex: 1, child: IconButton( icon: Icon(Icons .location_on), color: Colors.red, onPressed: () {}, ), ), Expanded( flex: 1, child: IconButton( icon: Icon(Icons .phone), color: Colors.red, onPressed: () {}, ), ), ], ), Divider( height: 1.2, color: Colors.grey) ], ), ); }, ), ) : Container(), ], ), ), Row( children: [ // Container( // width: 500, // height: 100, // margin: EdgeInsets.only(bottom: 100), // color: Colors.white, // child: Text("ENAD TEST"), // ), Container( width: 410, height: 50, // margin: EdgeInsets.only(bottom: 5), color: Colors.white, child: Texts( TranslationBase.of(context).recommended, bold: true, ), ), ], ), SingleChildScrollView( child: Container( color: Colors.white, child: Column( // crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, // mainAxisSize: MainAxisSize.min, children: [ Container( color: Colors.white, height: 210, margin: EdgeInsets.only(bottom: 75), padding: EdgeInsets.only(bottom: 5), // margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), child: BaseView( onModelReady: (model) => model.getRecommendedProducts(widget.product.id.toString()), builder: (_, model, wi) => Container( child: // Text(model.recommendedProductList[0].id), model.recommendedProductList.length != null ? Expanded( child: 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"), ), ) ), ), ], ), ), ) ], ), ), bottomSheet: footerWidget( widget.product.stockAvailability != 'Out of stock', widget.product.orderMaximumQuantity, widget.product.orderMinimumQuantity, widget.product.stockQuantity, widget.product), ) : AppScaffold( appBarTitle: 'product detail page', isShowAppBar: true, isPharmacy: true, isShowDecPage: false, body: SingleChildScrollView( child: Column( children: [ Container( width: double.infinity, color: Colors.white, child: Column( children: [ Image.network( widget.product.images[0].src.trim(), ), widget.product.discountDescription != null ? Container( width: double.infinity, height: 50, color: Colors.yellowAccent, child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( flex: 1, child: Container( alignment: Alignment.centerRight, child: languageID == 'ar' ? Text( widget.product .discountDescriptionn, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 17), ) : Text( widget.product .discountDescription, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 17), ), ), ), SizedBox( width: 10, ), Expanded( flex: 0, child: Container( child: Image( image: AssetImage( 'assets/images/offer.png'), ), ), ), ], ), ) : Container(), ], ), ), SizedBox( height: 4, ), Container( width: 500, height: 150, color: Colors.white, child: productNameAndPrice(context, widget.product), ), SizedBox( height: 6, ), Container( width: 500, height: 120, color: Colors.white, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Container( child: Text( TranslationBase.of(context).specification, style: TextStyle(fontWeight: FontWeight.bold), ), ), ), Divider(color: Colors.grey) ], ), ), SizedBox( height: 6, ), Container( width: 500, margin: EdgeInsets.only(bottom: 100), // height: 350, color: Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( children: [ FlatButton( onPressed: () { setState(() { isDetails = true; isReviews = false; isAvailabilty = false; }); }, child: Text( TranslationBase.of(context).details, style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), isDetails ? Container( width: 100, height: 5, color: Colors.green, ) : Container() ], ), SizedBox( width: 20, ), Column( children: [ FlatButton( onPressed: () { setState(() { isDetails = false; isReviews = true; isAvailabilty = false; }); }, child: Text( TranslationBase.of(context).reviews, style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), isReviews ? Container( width: 100, height: 5, color: Colors.green, ) : Container(), ], ), SizedBox( width: 20, ), Column( children: [ FlatButton( onPressed: () { setState(() { isDetails = false; isReviews = false; isAvailabilty = true; }); }, child: Text( TranslationBase.of(context).availability, style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), isAvailabilty ? Container( width: 100, height: 5, color: Colors.green, ) : Container(), ], ), ], ), SizedBox( height: 10, ), isDetails ? Padding( padding: const EdgeInsets.all(8.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( child: Text( TranslationBase.of(context).description, style: TextStyle( fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), ), ), SizedBox( height: 6, ), Divider(height: 1, color: Colors.grey), SizedBox( height: 10, ), Container( child: Text( languageID == 'ar' ? widget.product.shortDescriptionn : widget.product.shortDescription, style: TextStyle( fontSize: 16, fontFamily: 'WorkSans-Regular'), ), ), SizedBox( height: 10, ), Container( child: Text( TranslationBase.of(context).howToUse, style: TextStyle( fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), ), ), SizedBox( height: 6, ), Divider(height: 2, color: Colors.grey), SizedBox( height: 10, ), Container( child: Text( languageID == 'ar' ? widget.product.fullDescriptionn : widget.product.fullDescription, style: TextStyle( fontSize: 16, fontFamily: 'WorkSans-Regular'), ), ), ], ), ) : 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, ), ), ], ), ), 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( physics: ScrollPhysics(), scrollDirection: Axis.vertical, shrinkWrap: true, itemCount: model .productLocationService.length, itemBuilder: (BuildContext context, int index) { return Padding( padding: EdgeInsets.all(8.0), child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start, children: [ Row( // crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( flex: 1, child: Image.network(model .productLocationService[ index] .projectImageUrl), ), SizedBox( width: 10, ), Expanded( flex: 4, child: Text( model .productLocationService[ index] .locationDescription + "\n" + fixingString(model .productLocationService[ 0] .cityName .toString()), style: TextStyle( fontSize: 12), ), ), Expanded( flex: 1, child: IconButton( icon: Icon(Icons .location_on), color: Colors.red, onPressed: () {}, ), ), Expanded( flex: 1, child: IconButton( icon: Icon(Icons.phone), color: Colors.red, onPressed: () {}, ), ), ], ), Divider( height: 1.2, color: Colors.grey) ], ), ); }, ), ) : Container(), ], ), ), // ListView(scrollDirection: Axis.vertical, shrinkWrap: true, children: [Text('ENAD')]), ], ), ), bottomSheet: footerWidget( widget.product.stockAvailability != 'Out of stock', widget.product.orderMaximumQuantity, widget.product.orderMinimumQuantity, widget.product.stockQuantity, widget.product), ); } } class footerWidget extends StatefulWidget { final bool isAvailble; final int maxQuantity; final int minQuantity; final int quantityLimit; final PharmacyProduct item; footerWidget(this.isAvailble, this.maxQuantity, this.minQuantity, this.quantityLimit, this.item); @override _footerWidgetState createState() => _footerWidgetState(); } class _footerWidgetState extends State { double quantityUI = 70; bool showUI = false; @override Widget build(BuildContext context) { return Container( width: double.infinity, height: quantityUI, color: Colors.white, child: Column( children: [ showUI ? Container( width: double.infinity, height: 90, color: Colors.white, child: Container( child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Text( TranslationBase.of(context).quantity, style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold), ), ), // ListView( // scrollDirection: Axis.horizontal, // children: [ // itemQuantity(), // ], // ), Container( // margin: EdgeInsets.symmetric(vertical: 20.0), height: 50.0, child: ListView( scrollDirection: Axis.horizontal, children: [ InkWell( child: Container( alignment: Alignment.center, width: 50.0, color: Colors.white, child: Text( '1', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { setState(() { price = 1; if (price >= widget.quantityLimit) { isOverQuantity = true; } else { isOverQuantity = false; return price; } }); }, ), SizedBox( width: 5, ), InkWell( child: Container( alignment: Alignment.center, width: 50.0, color: Colors.white, child: Text( '2', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { setState(() { price = 2; if (price >= widget.quantityLimit) { isOverQuantity = true; } else { isOverQuantity = false; return price; } }); }, ), SizedBox( width: 5, ), InkWell( child: Container( alignment: Alignment.center, width: 50.0, color: Colors.white, child: Text( '3', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { setState(() { price = 3; if (price >= widget.quantityLimit) { isOverQuantity = true; } else { isOverQuantity = false; return price; } }); }, ), SizedBox( width: 5, ), InkWell( child: Container( alignment: Alignment.center, width: 50.0, color: Colors.white, child: Text( '4', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { setState(() { price = 4; if (price >= widget.quantityLimit) { isOverQuantity = true; } else { isOverQuantity = false; return price; } }); }, ), SizedBox( width: 5, ), InkWell( child: Container( alignment: Alignment.center, width: 50.0, color: Colors.white, child: Text( '5', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { setState(() { price = 5; if (price >= widget.quantityLimit) { isOverQuantity = true; } else { isOverQuantity = false; return price; } }); }, ), SizedBox( width: 5, ), InkWell( child: Container( alignment: Alignment.center, width: 50.0, color: Colors.white, child: Text( '6', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { setState(() { price = 6; if (price >= widget.quantityLimit) { isOverQuantity = true; } else { isOverQuantity = false; return price; } }); }, ), SizedBox( width: 5, ), InkWell( child: Container( alignment: Alignment.center, width: 50.0, color: Colors.white, child: Text( '7', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { setState(() { price = 7; if (price >= widget.quantityLimit) { isOverQuantity = true; } else { isOverQuantity = false; return price; } }); }, ), SizedBox( width: 5, ), InkWell( child: Container( alignment: Alignment.center, width: 50.0, color: Colors.white, child: Text( '8', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { setState(() { price = 8; if (price >= widget.quantityLimit) { isOverQuantity = true; } else { isOverQuantity = false; return price; } }); }, ), SizedBox( width: 5, ), InkWell( child: Container( alignment: Alignment.center, width: 50.0, color: Colors.white, child: Text( '9', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { setState(() { price = 9; if (price >= widget.quantityLimit) { isOverQuantity = true; } else { isOverQuantity = false; return price; } }); }, ), SizedBox( width: 5, ), InkWell( child: Container( alignment: Alignment.center, width: 50.0, color: Colors.white, child: Text( '10', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { setState(() { price = 10; if (price >= widget.quantityLimit) { isOverQuantity = true; } else { isOverQuantity = false; return price; } }); }, ), SizedBox( width: 5, ), Container( width: 50.0, child: TextField( decoration: InputDecoration(labelText: 'quantity #'), onChanged: (text) { print(price); print(widget.quantityLimit); if (int.tryParse(text) == null) { text = ''; } else { setState(() { price = int.parse(text); if (price >= widget.quantityLimit) { isOverQuantity = true; } else { isOverQuantity = false; } }); } }, ), ), ], ), ) ], ), ), ) : Container( height: 20, ), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: 70, height: 50, child: FlatButton( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( flex: 4, child: Text( price.toString(), style: TextStyle(fontSize: 20), ), ), Expanded( flex: 5, child: Text( TranslationBase.of(context).quantityShortcut, style: TextStyle(fontSize: 16), ), ), ], ), onPressed: () { setState(() { if (showUI) { quantityUI = 70; showUI = false; } else { quantityUI = 150; showUI = true; } }); }, ), ), !widget.isAvailble && price > 0 || price > widget.quantityLimit || widget.item.rxMessage != null ? Container( width: 190, height: 46, color: Colors.grey, child: Align( alignment: Alignment.center, child: Text( TranslationBase.of(context).addToCart, style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), ), ), ) : InkWell( onTap: () { addToCartFunction(price, widget.item.id); }, child: Container( alignment: Alignment.center, width: 190, height: 46, color: Colors.green, child: Text( TranslationBase.of(context).addToCart, style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), ), ), ), SizedBox( width: 5, ), !widget.isAvailble && price > 0 || price > widget.quantityLimit || widget.item.rxMessage != null ? Container( width: 120, height: 46, color: Colors.grey, child: Align( alignment: Alignment.center, child: Text( TranslationBase.of(context).buyNow, style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), ), ), ) : InkWell( onTap: () { print('buy now'); addToCartFunction(price, widget.item.id); Navigator.push( context, FadePage(page: CartOrderPage()), ); }, child: Container( alignment: Alignment.center, width: 120, height: 46, color: Colors.blue, child: Text( TranslationBase.of(context).buyNow, style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), ), ), ), ], ), ], ), ); } } class productNameAndPrice extends StatefulWidget { BuildContext context; PharmacyProduct item; productNameAndPrice(this.context, this.item); @override _productNameAndPriceState createState() => _productNameAndPriceState(); } class _productNameAndPriceState extends State { @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Row( children: [ Text( widget.item.price.toString() + " " + "SAR", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30), ), SizedBox( width: 40, ), Text( widget.item.stockAvailability, style: widget.item.stockAvailability == 'Out of stock' ? TextStyle(fontWeight: FontWeight.bold, color: Colors.red) : TextStyle( fontWeight: FontWeight.bold, color: Colors.green), ), SizedBox(width: 20), widget.item.stockAvailability == 'Out of stock' && customerId != null ? InkWell( onTap: () => notifyMeWhenAvailable(context, widget.item.id), child: Row(children: [ Text( TranslationBase.of(context).notifyMe, style: TextStyle( color: Colors.blue, decoration: TextDecoration.underline, ), ), SizedBox(width: 4), Icon( FontAwesomeIcons.bell, color: Colors.blue, size: 15.0, ) ]), ) : 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: 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(() {}); }, )), ], ), ), 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' ? widget.item.fullDescriptionn : widget.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: widget.item.rxMessage != null ? Text( languageID == 'ar' ? widget.item.rxMessagen.toString() : widget.item.rxMessage.toString(), style: TextStyle(color: Colors.red, fontSize: 10), ) : Container()), ), widget.item.rxMessage != null ? Icon( FontAwesomeIcons.questionCircle, color: Colors.red, size: 15.0, ) : Container(), ], ), ], ); } } slideDetail() { return Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Container( padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 15.0), decoration: const BoxDecoration( border: Border( top: BorderSide(width: 0.5, color: Colors.grey), left: BorderSide(width: 0.5, color: Colors.grey), right: BorderSide(width: 0.5, color: Colors.grey), bottom: BorderSide(width: 0.5, color: Colors.grey), ), color: Colors.white, ), child: const Text('1', textAlign: TextAlign.center, style: TextStyle(color: Color(0xFF000000))), ), ) ], ); } fixingString(txt) { String stringTxt; String newTxt; stringTxt = txt.toString(); newTxt = stringTxt.split('.')[1]; return newTxt; } getLanguageID() async { languageID = await sharedPref.getString(APP_LANGUAGE); } getSpecificationData(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); specificationData = await x.productSpecificationData(itemID); } addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); await x.addToCartData(quantity, itemID); } notifyMeWhenAvailable(context, itemId) async { ProductDetailViewModel x = new ProductDetailViewModel(); await x.notifyMe(customerId, itemId); } addToWishlistFunction(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); isInWishlit = true; await x.addToWishlistData(itemID); } deleteFromWishlistFunction(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); isInWishlit = false; 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++) { if (itemID == x.wishListItems[i].product.id) { isInWishlit = true; break; } else { isInWishlit = false; } } } class sttingModalBottomSheet extends StatelessWidget { @override Widget build(BuildContext context) { return Container(); } } settingModalBottomSheet(context) { showModalBottomSheet( context: context, builder: (BuildContext bc) { return Container( child: new Wrap( children: [ new ListTile( 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") } }), ListTile( leading: Icon(Icons.favorite_border), title: Text('Add to wishlist'), onTap: () => {addToWishlistFunction(itemID)}, ), ListTile( leading: Icon(Icons.compare), title: Text('Compare'), onTap: () => { Provider.of(context, listen: false) .addItem(specificationData), }, ), ], ), ); }); }