diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index c2dd64b9..31747141 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -1,7 +1,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index cb886f2d..9f00e27c 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -3,7 +3,7 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/wishlist.dart'; diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index c3acb0ba..fb4b934f 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -2,7 +2,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; diff --git a/lib/pages/pharmacies/product_detail.dart b/lib/pages/pharmacies/product_detail.dart deleted file mode 100644 index 06cae695..00000000 --- a/lib/pages/pharmacies/product_detail.dart +++ /dev/null @@ -1,2198 +0,0 @@ -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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/pharmacies/compare-list.dart'; -import 'package:diplomaticquarterapp/uitl/app_toast.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/others/app_scafold_detail_page.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; -import 'package:flutter/material.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/core/model/pharmacies/recommendedProduct_model.dart'; -import 'screens/cart-order-page.dart'; -import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; - -int price = 0; -dynamic languageID; -bool isOverQuantity = false; -bool isInWishlit = false; -//int isSelected = 1; -bool isSelected= true; -String itemID; -var customerId; -CompareList compareItems = new CompareList(); -PharmacyProduct specificationData; -//Products recommendedData; - -class ProductDetailPage extends StatefulWidget { - final PharmacyProduct product; -// final Products recommendedProducts; - - - ProductDetailPage(this.product ); - - - @override - __ProductDetailPageState createState() => __ProductDetailPageState(); -} - -class __ProductDetailPageState extends State { - AppSharedPreferences sharedPref = AppSharedPreferences(); - - bool isTrue = true; - bool isDetails = true; - bool isReviews = false; - bool isAvailabilty = false; - dynamic wishlistItems; - //var model; - - // String ProductId="4561"; - // String productId = ""; - getLanguageID() async { - languageID = await sharedPref.getString(APP_LANGUAGE); - } - - 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() { - getLanguageID(); - 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(); - } - print("customerId:$customerId"); - - setState(() {}); - } - - Widget build(BuildContext context) { - return customerId != null - ? DetailPageScafold( - appBarTitle: TranslationBase.of(context).productDetails, - 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: 220, - color: Colors.white, - child: productNameAndPrice(context, widget.product), - ), - SizedBox( - height: 6, - ), - Container( - width: 500, - height: 100, - 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( - TranslationBase.of(context).noData, -// "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(TranslationBase.of(context).noReviewsAvailable,), -// 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(TranslationBase.of(context).noLocationAvailable,), -// 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: [ - customerId != null ? Container( - width: 410, - height: 50, - // margin: EdgeInsets.only(bottom: 5), - color: Colors.white, - child: Texts( - TranslationBase.of(context).recommended, - bold: true, - ), - ) - : Container(), - ], - ), - SingleChildScrollView( - child: Container( - width: 410, - 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), - builder: (_, model, wi) => Container( - child: - 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 InkWell( - onTap: () - async { - GifLoaderDialogUtils.showMyDialog(context); - RecommendedProductModel data = model.recommendedProductList[index]; - var json = data.toJson(); - PharmacyProduct product = new PharmacyProduct.fromJson(json); - await Navigator.pushReplacement( - context, - FadePage( - page: ProductDetailPage(product), - )); - GifLoaderDialogUtils.hideDialog(context); - }, - child: 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: IconButton( - icon: Icon(model.recommendedProductList[index].isinwishlist != true ? Icons.favorite_border : Icons.favorite), - color: model.recommendedProductList[index].isinwishlist != true ? Colors.grey : Colors.red, - onPressed: () async { - - if (customerId != null ) { - if (!isInWishlit && model.recommendedProductList[index].isinwishlist != true) { - GifLoaderDialogUtils.showMyDialog(context); - await addToWishlistFunction(model.recommendedProductList[index].id); -// checkWishlist(); - GifLoaderDialogUtils.hideDialog(context); - setState((){ - model.recommendedProductList[index].isinwishlist= true; - }); - - } else { - GifLoaderDialogUtils.showMyDialog(context); - await deleteFromWishlistFunction(model.recommendedProductList[index].id); - GifLoaderDialogUtils.hideDialog(context); - setState((){ - model.recommendedProductList[index].isinwishlist = false; - }); - } - } else { - return ; - } - setState(() { - // checkWishlist(); - }); - }, - )), - -// child: Align( -// alignment: Alignment.topRight, -// child:itemID.contains(model.recommendedProductList[index]['id']) -// // !isInWishlist -// ? IconButton( -// icon: Icon(Icons.favorite_border), -// color: Colors.grey, -// iconSize: 30, -// onPressed: () { -// setState(() { -// if (customerId != null && isInWishlit ) { -// deleteFromWishlistFunction( -// model.recommendedProductList[index].id); -// } }); -// }, -// ) -// : IconButton( -// icon: Icon(Icons.favorite), -// color: Colors.red, -// iconSize: 30, -// onPressed: () { -// setState(() { -// if (customerId != null && !isInWishlit ) { -// addToWishlistFunction( -// model.recommendedProductList[index].id); -// } }); -// }, -// ) -// ), - ), - - 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: model.recommendedProductList[index].rxMessage != null - ? Texts( - languageID == "ar" - ? model.recommendedProductList[index].rxMessagen - : model.recommendedProductList[index].rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ):Texts (""), - ), - ]), - 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: < - Widget>[ - 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].notApprovedTotalReviews.toString()})", -// bold: true, - fontSize: - 12, - ), - ]), - ], - ), - ), - ), - ); - }), - ) - : Container( - // color: Colors.white, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - // crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Texts(TranslationBase.of(context).nonRecommended, - color: Colors.black,), - ], - ), - ), - )), - ), - ], - ), - ), - ) - ], - ), - ), - bottomSheet: footerWidget( - widget.product.stockAvailability != 'Out of stock', - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - widget.product.stockQuantity, - widget.product), - ) - : AppScaffold( - appBarTitle: TranslationBase.of(context).productDetails, - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - showPharmacyCart: false, - showHomeAppBarIcon: 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(TranslationBase.of(context).noReviewsAvailable), -// 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, context); - }, - 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, context); - 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( - languageID == 'ar'? - widget.item.stockAvailabilityn : 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) { - GifLoaderDialogUtils.showMyDialog(context); - await addToWishlistFunction(widget.item.id); - GifLoaderDialogUtils.hideDialog(context); - } 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, BuildContext context) async { - GifLoaderDialogUtils.showMyDialog(context); - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID).then((value) { - GifLoaderDialogUtils.hideDialog(context); - }); -} - -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(TranslationBase.of(context) - .addToCart,), - onTap: () => { - if (price > 0) - {addToCartFunction(price, itemID, context)} - else - { - AppToast.showErrorToast( - message: "you should add quantity") - } - }), - ListTile( - leading: Icon(Icons.favorite_border), - title: Text(TranslationBase.of(context) - .addToWishlist,), - onTap: () => {addToWishlistFunction(itemID)}, - ), - ListTile( - leading: Icon(Icons.compare), - title: Text(TranslationBase.of(context) - .compare,), - onTap: () => { - Provider.of(context, listen: false) - .addItem(specificationData), - }, - ), - ], - ), - ); - }); -} diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 755b5cef..ee5c077f 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -12,6 +12,9 @@ import 'package:diplomaticquarterapp/pages/landing/home_page.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/lacum-activitaion-vida-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/lakum-main-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/recommended-product-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/BannerPager.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.dart'; diff --git a/lib/pages/pharmacies/screens/product-details/CustomIcon.dart b/lib/pages/pharmacies/screens/product-details/CustomIcon.dart new file mode 100644 index 00000000..c9a71afa --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/CustomIcon.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; + +class IconWithBg extends StatelessWidget { + final IconData icon; + final Color color; + final Function onPress; + + const IconWithBg({Key key, this.icon, this.color, this.onPress}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(left: 25), + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.circular(30), + ), + child: IconButton( + icon: Icon(icon), + color: color, + onPressed: () async { + onPress(); + }, + )); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart new file mode 100644 index 00000000..36c43364 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart @@ -0,0 +1,66 @@ +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +import '../cart-order-page.dart'; +import 'CustomIcon.dart'; + +class ProductAppBar extends StatelessWidget with PreferredSizeWidget { + @override + Widget build(BuildContext context) { + return Container( + color: Colors.white, + child: Column( + children: [ + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + IconWithBg( + icon: Icons.arrow_back_ios, + color: Colors.grey, + onPress: () { + Navigator.pop(context); + }, + ), + ], + ), + Row( + children: [ + IconWithBg( + icon: Icons.shopping_cart, + color: Colors.grey, + onPress: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CartOrderPage()), + ); + }), + IconWithBg( + icon: FontAwesomeIcons.ellipsisV, + color: Colors.grey, + onPress: () { + //TODO Elham* + // settingModalBottomSheet(context); + }, + ), + ], + ) + ], + ), + ], + ), + ); + } + + @override + // TODO: implement preferredSize + @override + Size get preferredSize => Size(double.maxFinite, 50); +} + + diff --git a/lib/pages/pharmacies/screens/product-details/availability_info.dart b/lib/pages/pharmacies/screens/product-details/availability_info.dart new file mode 100644 index 00000000..0c00d22a --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/availability_info.dart @@ -0,0 +1,85 @@ +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:flutter/material.dart'; + +class AvailabilityInfo extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getProductLocationData(), + + builder: (_, model, wi) => NetworkBaseView( + baseViewModel: model, + child: model.productLocationService.length == 0 + ? Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noLocationAvailable, + ), + ) + : 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( + children: [ + Row( + 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" + + convertCityName( + 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) + ], + ), + ); + }, + ), + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/details_info.dart b/lib/pages/pharmacies/screens/product-details/details_info.dart new file mode 100644 index 00000000..bc5e7f80 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/details_info.dart @@ -0,0 +1,56 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class DetailsInfo extends StatelessWidget { + + final PharmacyProduct product; + + const DetailsInfo({Key key, this.product}) : super(key: key); + + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + child: Texts( + TranslationBase.of(context) + .description, + fontSize: 17, + color: Colors.grey, + ), + ), + SizedBox( + height: 10, + ), + Divider(height: 1, color: Colors.grey), + SizedBox( + height: 15, + ), + Container( + child: Texts( + projectViewModel.isArabic + ? product.fullDescriptionn + : product + .fullDescription ?? + "", + fontSize: 16, + ), + ), + SizedBox( + height: 20, + ), + ]), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/discount_description.dart b/lib/pages/pharmacies/screens/product-details/discount_description.dart new file mode 100644 index 00000000..1c2b27d4 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/discount_description.dart @@ -0,0 +1,48 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:flutter/material.dart'; + +class DiscountDescription extends StatelessWidget { + final PharmacyProduct product; + + const DiscountDescription({Key key, this.product}) : super(key: key); + @override + Widget build(BuildContext context) { + return 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: Text( + 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'), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart new file mode 100644 index 00000000..cca4eef5 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -0,0 +1,240 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/footor/quantity_box.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +import '../../cart-order-page.dart'; + +class FooterWidget extends StatefulWidget { + final bool isAvailable; + final int maxQuantity; + final int minQuantity; + final int quantityLimit; + final PharmacyProduct item; + final Function addToCartFunction; + + int price; + bool isOverQuantity; + + FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity, + this.quantityLimit, this.item, + {this.price, this.isOverQuantity = false, this.addToCartFunction}); + + @override + _FooterWidgetState createState() => _FooterWidgetState(); +} + +class _FooterWidgetState extends State { + double quantityUI = 70; + bool showUI = false; + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), + ), + border: Border.all(color: HexColor('#707070'), width: 0), + ), + width: double.infinity, + height: quantityUI, + child: Column( + children: [ + showUI + ? Container( + width: double.infinity, + height: 100, + color: Colors.white, + child: Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 10, + ), + Row( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + "Quantity", + style: TextStyle( + fontSize: 15, fontWeight: FontWeight.bold), + ), + ), + InkWell( + child: Icon(Icons.close, color: Colors.black), + onTap: () { + setState(() { + quantityUI = 70; + showUI = false; + }); + }, + ) + ], + mainAxisAlignment: MainAxisAlignment.spaceBetween, + ), + Container( + height: 50.0, + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + SizedBox( + width: 5, + ), + for (int i = 1; i <= 10; i++) + QuantityBox( + label: i, + onTapFunc: onChangeValue, + isSelected: widget.price == i), + Column( + children: [ + Container( + width: 100, + decoration: BoxDecoration( + border: + Border.all(color: Colors.grey[300]), + color: Colors.white, + ), + child: TextField( + decoration: InputDecoration( + labelText: 'quantity #'), + onChanged: (text) { + print(widget.price); + print(widget.quantityLimit); + if (int.tryParse(text) == null) { + text = ''; + } else { + setState(() { + widget.price = int.parse(text); + if (widget.price >= + widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.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( + widget.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; + } + }); + }, + ), + ), + Container( + width: MediaQuery.of(context).size.width * 0.4, + child: SecondaryButton( + label: TranslationBase.of(context).addToCart.toUpperCase(), + disabled: !widget.isAvailable && widget.price > 0 || + widget.price > widget.quantityLimit || + widget.item.rxMessage != null, + onTap: () { + widget.addToCartFunction( + widget.price, widget.item.id, context); + }, + borderRadius: 5, + color: Colors.green, + ), + ), + SizedBox( + width: 5, + ), + Container( + width: MediaQuery.of(context).size.width * 0.3, + child: SecondaryButton( + label: TranslationBase.of(context).buyNow.toUpperCase(), + disabled: !widget.isAvailable && widget.price > 0 || + widget.price > widget.quantityLimit || + widget.item.rxMessage != null, + onTap: () { + widget.addToCartFunction( + widget.price, widget.item.id, context); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + }, + borderRadius: 5, + color: !widget.isAvailable && widget.price > 0 || + widget.price > widget.quantityLimit || + widget.item.rxMessage != null + ? Colors.grey + : Colors.grey[800], + ), + ), + ], + ), + ], + ), + ); + } + + onChangeValue(int i) { + setState(() { + ///TODO Elham* Check this if its good + widget.price = i; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/footor/quantity_box.dart b/lib/pages/pharmacies/screens/product-details/footor/quantity_box.dart new file mode 100644 index 00000000..35e69e0c --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/footor/quantity_box.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; + +class QuantityBox extends StatelessWidget { + final int label; + final bool isSelected; + final Function(int) onTapFunc; + + QuantityBox({ + Key key, + this.label, + this.onTapFunc, this.isSelected = false, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + InkWell( + child: Container( + decoration: BoxDecoration( + border: Border.all(color:isSelected?Colors.green: Colors.grey[300]), + color: Colors.white, + ), + alignment: Alignment.center, + width: 50.0, + + child: Text( + '$label', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + ), + ), + onTap:(){ + onTapFunc(label); + } + ), + SizedBox( + width: 5, + ) + ], + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart new file mode 100644 index 00000000..08a622aa --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -0,0 +1,966 @@ +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-name-and-price.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/recommended_products.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/reviews_info.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.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/others/app_scafold_detail_page.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.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/core/model/pharmacies/recommendedProduct_model.dart'; +import '../cart-order-page.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; + +import 'ProductAppBar.dart'; +import 'availability_info.dart'; +import 'details_info.dart'; +import 'discount_description.dart'; +import 'footor/footer-widget.dart'; + +int price = 0; +bool isOverQuantity = false; +bool isInWishList = false; +bool isSelected = true; +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 + with SingleTickerProviderStateMixin { + TabController _tabController; + AppSharedPreferences sharedPref = AppSharedPreferences(); + + bool isTrue = true; + bool isDetails = true; + bool isReviews = false; + bool isAvailability = false; + int _activeTab = 0; + + checkWishlist() async { + GifLoaderDialogUtils.showMyDialog(context); + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.checkWishlistData(); + + for (int i = 0; i < x.wishListItems.length; i++) { + if (itemID == x.wishListItems[i].product.id) { + isInWishList = true; + break; + } else { + isInWishList = false; + } + } + GifLoaderDialogUtils.hideDialog(context); + setState(() {}); + } + + void initState() { + price = 1; + specificationData = widget.product; + _tabController = TabController(length: 3, vsync: this); + + userInfo(); + super.initState(); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + + void userInfo() async { + print(specificationData); + customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + if (customerId != null) { + itemID = widget.product.id; + checkWishlist(); + } + setState(() {}); + } + + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + final screenSize = MediaQuery.of(context).size; + + return customerId != null + ? AppScaffold( + appBarTitle: TranslationBase.of(context).productDetails, + isShowAppBar: true, + isPharmacy: true, + isShowDecPage: false, + customAppBar: ProductAppBar(), + body: SingleChildScrollView( + child: Column( + children: [ + Container( + width: double.infinity, + color: Colors.white, + child: Column( + children: [ + if (widget.product.images.isNotEmpty) + Container( + height: MediaQuery.of(context).size.height * .40, + child: Image.network( + widget.product.images[0].src.trim(), + fit: BoxFit.contain, + ), + ), + if (widget.product.discountDescription != null) + DiscountDescription(product: widget.product) + ], + ), + ), + SizedBox( + height: 4, + ), + Container( + color: Colors.white, + child: ProductNameAndPrice( + context, + widget.product, + customerId: customerId, + addToWishlistFunction: addToWishlistFunction, + deleteFromWishlistFunction: deleteFromWishlistFunction, + notifyMeWhenAvailable: notifyMeWhenAvailable, + isInWishList: isInWishList, + ), + ), + SizedBox( + height: 6, + ), + Container( + color: Colors.white, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.symmetric( + vertical: 15, horizontal: 10), + child: Texts( + TranslationBase.of(context).specification, + fontSize: 15, + fontWeight: FontWeight.bold, + ), + width: double.infinity, + ), + // Divider(color: Colors.grey), + ], + ), + ), + SizedBox( + height: 6, + ), + // Container( + // height: 500, + // color: Colors.white, + // child: Scaffold( + // backgroundColor: Colors.white, + // extendBodyBehindAppBar: false, + // appBar: PreferredSize( + // preferredSize: Size.fromHeight( + // MediaQuery.of(context).size.height * 0.070), + // child: Container( + // height: MediaQuery.of(context).size.height * 0.070, + // decoration: BoxDecoration( + // border: Border( + // bottom: BorderSide( + // color: Theme.of(context).dividerColor, + // width: 0.5), //width: 0.7 + // ), + // color: Colors.white), + // child: Center( + // child: TabBar( + // isScrollable: false, + // controller: _tabController, + // // indicatorColor: Colors.transparent, + // indicatorWeight: 1.0, + // indicatorSize: TabBarIndicatorSize.tab, + // indicatorColor:Colors.green, + // labelColor: Theme.of(context).primaryColor, + // labelPadding: EdgeInsets.only( + // top: 0, left: 0, right: 0, bottom: 0), + // unselectedLabelColor: Colors.grey[800], + // tabs: [ + // tabWidget(screenSize, _activeTab == 0, + // TranslationBase.of(context).details, + // ), + // tabWidget(screenSize, _activeTab == 1, + // TranslationBase.of(context).review, + // ), + // tabWidget(screenSize, _activeTab == 2, + // TranslationBase.of(context).availability), + // ], + // ), + // ), + // ), + // ), + // body: Column( + // children: [ + // Expanded( + // child: TabBarView( + // physics: BouncingScrollPhysics(), + // controller: _tabController, + // children: [ + // DetailsInfo( + // product: widget.product, + // ), + // ReviewsInfo( + // product: widget.product, + // ), + // AvailabilityInfo() + // ], + // ), + // ), + // + // ], + // ), + // ), + // ), + + SizedBox( + height: 6, + ), + + //TODO Elham* Remove this + Container( + // width: 500, + margin: EdgeInsets.only(bottom: 6), + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = true; + isReviews = false; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).details, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isDetails + ? Colors.green + : Colors.transparent, + ) + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = false; + isReviews = true; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).reviews, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isReviews + ? Colors.green + : Colors.transparent, + ), + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = false; + isReviews = false; + isAvailability = true; + }); + }, + child: Text( + TranslationBase.of(context).availability, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isAvailability + ? Colors.green + : Colors.transparent, + ), + ], + ), + ], + ), + SizedBox( + height: 10, + ), + isDetails + ? DetailsInfo( + product: widget.product, + ) + : isReviews + ? ReviewsInfo( + product: widget.product, + ) + : isAvailability + ? AvailabilityInfo() + : Container(), + ], + ), + ), + + ///TODO Elham* check if we need recommanded + // Row( + // children: [ + // customerId != null + // ? Container( + // width: 410, + // height: 50, + // color: Colors.white, + // child: Texts( + // TranslationBase.of(context).recommended, + // bold: true, + // ), + // ) + // : Container(), + // ], + // ), + // RecommendedProducts(product: widget.product) + + SizedBox( + height: 80, + ) + ], + ), + ), + bottomSheet: FooterWidget( + widget.product.stockAvailability != 'Out of stock', + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + widget.product.stockQuantity, + widget.product, + price: price, + isOverQuantity: isOverQuantity, + addToCartFunction: addToCartFunction, + ), + ) + : AppScaffold( + appBarTitle: TranslationBase.of(context).productDetails, + isShowAppBar: true, + isPharmacy: true, + isShowDecPage: false, + showPharmacyCart: false, + showHomeAppBarIcon: 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: projectViewModel.isArabic + ? 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, + customerId: customerId, + addToWishlistFunction: addToWishlistFunction, + deleteFromWishlistFunction: deleteFromWishlistFunction, + notifyMeWhenAvailable: notifyMeWhenAvailable, + isInWishList: isInWishList, + ), + ), + 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; + isAvailability = 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; + isAvailability = 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; + isAvailability = true; + }); + }, + child: Text( + TranslationBase.of(context).availability, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + isAvailability + ? 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( + projectViewModel.isArabic + ? 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( + projectViewModel.isArabic + ? 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( + TranslationBase.of(context) + .noReviewsAvailable), + ), + ) + : isAvailability + ? 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( + children: [ + Row( + 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" + + convertCityName( + 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(), + ], + ), + ), + ], + ), + ), + bottomSheet: FooterWidget( + widget.product.stockAvailability != 'Out of stock', + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + widget.product.stockQuantity, + widget.product, + price: price, + isOverQuantity: isOverQuantity, + addToCartFunction: addToCartFunction, + ), + ); + } +} + +class CustomDivider extends StatelessWidget { + const CustomDivider({ + Key key, + this.color, + }) : super(key: key); + + final Color color; + + @override + Widget build(BuildContext context) { + return Container( + width: 120, + height: 2, + color: color, + ); + } +} + +convertCityName(txt) { + String stringTxt; + String newTxt; + stringTxt = txt.toString(); + newTxt = stringTxt.split('.')[1]; + + return newTxt; +} + +addToCartFunction(quantity, itemID, BuildContext context) async { + GifLoaderDialogUtils.showMyDialog(context); + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID).then((value) { + GifLoaderDialogUtils.hideDialog(context); + }); +} + +notifyMeWhenAvailable(context, itemId) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.notifyMe(customerId, 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.deletWishlistData(itemID); +} + +//TODO Elham* move to file +Widget tabWidget( + Size screenSize, + bool isActive, + String title, +) { + return Center( + child: Container( + height: screenSize.height * 0.070, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AppText( + title, + fontSize: SizeConfig.textMultiplier * 1.5, + // color: Color(0xFF2B353E), + fontWeight: FontWeight.w700, + ), + ], + ), + ), + ); +} diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart new file mode 100644 index 00000000..4f607e48 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -0,0 +1,192 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.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:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; + +import 'CustomIcon.dart'; + +class ProductNameAndPrice extends StatefulWidget { + BuildContext context; + PharmacyProduct item; + final customerId; + final bool isInWishList; + final Function notifyMeWhenAvailable; + final Function addToWishlistFunction; + final Function deleteFromWishlistFunction; + + ProductNameAndPrice(this.context, this.item, + {this.customerId, + this.isInWishList, + this.notifyMeWhenAvailable, + this.addToWishlistFunction, + this.deleteFromWishlistFunction}); + + @override + _ProductNameAndPriceState createState() => _ProductNameAndPriceState(); +} + +class _ProductNameAndPriceState extends State { + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + + return Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: 10, + ), + FractionallySizedBox( + widthFactor: 0.95, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts(widget.item.price.toString() + " " + "SAR", + fontWeight: FontWeight.bold, fontSize: 20), + Texts( + projectViewModel.isArabic + ? widget.item.stockAvailabilityn + : widget.item.stockAvailability, + fontWeight: FontWeight.bold, + fontSize: 15, + color: widget.item.stockAvailability == 'Out of stock' + ? Colors.red + : Colors.green, + ), + // SizedBox(width: 20), + widget.item.stockAvailability == 'Out of stock' && + widget.customerId != null + ? InkWell( + onTap: () => + widget.notifyMeWhenAvailable(context, widget.item.id), + child: Row(children: [ + Texts( + TranslationBase.of(context).notifyMe, + decoration: TextDecoration.underline, + color: Colors.blue, + ), + SizedBox(width: 4), + Icon( + FontAwesomeIcons.bell, + color: Colors.blue, + size: 15.0, + ) + ]), + ) + : IconWithBg( + icon: !widget.isInWishList + ? Icons.favorite_border + : Icons.favorite, + color: !widget.isInWishList ? Colors.white : Colors.red, + onPress: () async { + { + if (widget.customerId != null) { + if (!widget.isInWishList) { + GifLoaderDialogUtils.showMyDialog(context); + await widget + .addToWishlistFunction(widget.item.id); + GifLoaderDialogUtils.hideDialog(context); + } else { + await widget + .deleteFromWishlistFunction(widget.item.id); + } + } else { + return; + } + setState(() {}); + } + }, + ) + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + margin: EdgeInsets.only(left: 5), + child: Align( + alignment: projectViewModel.isArabic + ? Alignment.topRight + : Alignment.topLeft, + child: Text( + projectViewModel.isArabic + ? widget.item.namen + : widget.item.name, + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + ), + ), + ), + ), + FractionallySizedBox( + widthFactor: 0.95, + child: Row( + children: [ + Container( + child: Align( + alignment: Alignment.bottomLeft, + child: Row( + children: [ + RatingBar.readOnly( + initialRating: double.parse( + widget.item.approvedRatingSum.toString()), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[400], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + SizedBox( + width: 10, + ), + Texts( + "${widget.item.approvedRatingSum}", + fontWeight: FontWeight.bold, + fontSize: 12, + ), + SizedBox( + width: 30, + ), + Texts( + "(${widget.item.approvedTotalReviews}${TranslationBase.of(context).review})", + fontSize: 12, + ), + ], + ), + ), + ), + Expanded( + flex: 1, + child: Container( + child: widget.item.rxMessage != null + ? Text( + projectViewModel.isArabic + ? 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(), + ], + ), + ), + SizedBox( + height: 10, + ), + ], + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/recommended_products.dart b/lib/pages/pharmacies/screens/product-details/recommended_products.dart new file mode 100644 index 00000000..f40f1f08 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/recommended_products.dart @@ -0,0 +1,388 @@ +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/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.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/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; + +class RecommendedProducts extends StatefulWidget { + final PharmacyProduct product; + + const RecommendedProducts({Key key, this.product}) : super(key: key); + + @override + _RecommendedProductsState createState() => _RecommendedProductsState(); +} + +class _RecommendedProductsState extends State { + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return SingleChildScrollView( + child: Container( + width: 410, + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + 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), + builder: (_, model, wi) => Container( + child: + model.recommendedProductList.length != null + ? ListView.builder( + scrollDirection: + Axis.horizontal, + shrinkWrap: true, + physics: ScrollPhysics(), + // physics: NeverScrollableScrollPhysics(), + itemCount: model + .recommendedProductList + .length, + itemBuilder: (context, index) { + return InkWell( + onTap: () async { + GifLoaderDialogUtils + .showMyDialog( + context); + RecommendedProductModel + data = + model.recommendedProductList[ + index]; + var json = data.toJson(); + PharmacyProduct product = + new PharmacyProduct + .fromJson(json); + await Navigator + .pushReplacement( + context, + FadePage( + page: + ProductDetailPage( + product), + ), + ); + GifLoaderDialogUtils + .hideDialog(context); + }, + child: 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: + IconButton( + icon: Icon(model.recommendedProductList[index].isinwishlist != + true + ? Icons + .favorite_border + : Icons + .favorite), + color: model.recommendedProductList[index].isinwishlist != + true + ? Colors + .grey + : Colors + .red, + onPressed: + () async { + if (customerId != + null) { + if (!isInWishList && + model.recommendedProductList[index].isinwishlist != + true) { + GifLoaderDialogUtils.showMyDialog( + context); + await addToWishlistFunction(model + .recommendedProductList[index] + .id); +// checkWishlist(); + GifLoaderDialogUtils.hideDialog( + context); + setState( + () { + model.recommendedProductList[index].isinwishlist = + true; + }); + } else { + GifLoaderDialogUtils.showMyDialog( + context); + await deleteFromWishlistFunction(model + .recommendedProductList[index] + .id); + GifLoaderDialogUtils.hideDialog( + context); + setState( + () { + model.recommendedProductList[index].isinwishlist = + false; + }); + } + } else { + return; + } + setState( + () { + // checkWishlist(); + }); + }, + ), + ), + ), + Container( + margin: EdgeInsets + .fromLTRB( + 0, + 16, + 10, + 16), + alignment: + Alignment + .center, + child: (model.recommendedProductList[index].images != + null && + model.recommendedProductList[index].images.length > + 0) + ? Image + .network( + model + .recommendedProductList[index] + .images[0] + .src + .toString(), + 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: model.recommendedProductList[index] + .rxMessage != + null + ? Texts( + projectViewModel.isArabic + ? model.recommendedProductList[index].rxMessagen + : model.recommendedProductList[index].rxMessage, + color: Colors + .white, + regular: + true, + fontSize: + 10, + fontWeight: + FontWeight.w400, + ) + : Texts(""), + ), + ]), + Container( + margin: EdgeInsets + .symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + projectViewModel + .isArabic + ? 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: < + Widget>[ + Container( + padding: EdgeInsets.only( + right: + 10), + child: + Align( + alignment: + Alignment + .topLeft, + child: RatingBar + .readOnly( + initialRating: model + .recommendedProductList[index] + .approvedRatingSum + .toDouble(), + 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].notApprovedTotalReviews.toString()})", +// bold: true, + fontSize: + 12, + ), + ]), + ], + ), + ), + ), + ); + }) + : Container( + // color: Colors.white, + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Texts( + TranslationBase.of(context) + .nonRecommended, + color: Colors.black, + ), + ], + ), + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/reviews_info.dart b/lib/pages/pharmacies/screens/product-details/reviews_info.dart new file mode 100644 index 00000000..ed1970cd --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/reviews_info.dart @@ -0,0 +1,96 @@ +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/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:flutter/material.dart'; +import 'package:rating_bar/rating_bar.dart'; + +class ReviewsInfo extends StatelessWidget { + final PharmacyProduct product; + + const ReviewsInfo({Key key, this.product}) : super(key: key); + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getProductReviewsData(product.id), + builder: (_, model, wi) => NetworkBaseView( + baseViewModel:model , + child: 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( + TranslationBase.of(context).noReviewsAvailable, + ), +// Text('No Reviews Available'), + ), + ), + ); + } +} diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index b7a061d5..40895a00 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -1,7 +1,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/phramacy-product-detail-page.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; diff --git a/lib/pages/search_products_page.dart b/lib/pages/search_products_page.dart index 16720946..42d3e61b 100644 --- a/lib/pages/search_products_page.dart +++ b/lib/pages/search_products_page.dart @@ -2,7 +2,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 45617072..51c535b9 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -1,6 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; diff --git a/lib/widgets/buttons/secondary_button.dart b/lib/widgets/buttons/secondary_button.dart index 8c4ba851..9d5df436 100644 --- a/lib/widgets/buttons/secondary_button.dart +++ b/lib/widgets/buttons/secondary_button.dart @@ -29,7 +29,7 @@ class SecondaryButton extends StatefulWidget { this.small = false, this.disabled = false, this.borderColor, - this.noBorderRadius = false}) + this.noBorderRadius = false, this.borderRadius}) : super(key: key); final String label; @@ -43,6 +43,9 @@ class SecondaryButton extends StatefulWidget { final bool iconOnly; final bool disabled; final bool noBorderRadius; + final double borderRadius; + + @override _SecondaryButtonState createState() => _SecondaryButtonState(); @@ -169,7 +172,7 @@ class _SecondaryButtonState extends State child: ClipRRect( borderRadius: widget.noBorderRadius ? BorderRadius.all(Radius.circular(0.0)) - : BorderRadius.all(Radius.circular(10.0)), + : BorderRadius.all(Radius.circular(widget.borderRadius??10.0)), child: Stack( children: [ Positioned( diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 962d0506..87976dcb 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -62,6 +62,8 @@ class AppScaffold extends StatelessWidget { locator(); AppBarWidget appBar; + final Widget customAppBar; + AppScaffold( {@required this.body, this.appBarTitle = '', @@ -85,7 +87,9 @@ class AppScaffold extends StatelessWidget { this.infoList, this.isHelp = false, this.showHomeAppBarIcon = true, - this.imagesInfo}); + this.imagesInfo, + appBar, + this.customAppBar}); AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -99,16 +103,18 @@ class AppScaffold extends StatelessWidget { backgroundColor: backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, appBar: isShowAppBar - ? appBar = AppBarWidget( - appBarTitle: appBarTitle, - appBarIcons: appBarIcons, - showHomeAppBarIcon: showHomeAppBarIcon, - isPharmacy: isPharmacy, - showPharmacyCart: showPharmacyCart, - isOfferPackages: isOfferPackages, - showOfferPackagesCart: showOfferPackagesCart, - isShowDecPage: isShowDecPage, - ) + ? customAppBar != null + ? customAppBar + : appBar = AppBarWidget( + appBarTitle: appBarTitle, + appBarIcons: appBarIcons, + showHomeAppBarIcon: showHomeAppBarIcon, + isPharmacy: isPharmacy, + showPharmacyCart: showPharmacyCart, + isOfferPackages: isOfferPackages, + showOfferPackagesCart: showOfferPackagesCart, + isShowDecPage: isShowDecPage, + ) : null, bottomSheet: bottomSheet, body: SafeArea( @@ -223,7 +229,8 @@ class AppBarWidgetState extends State { // ? IconButton( // icon: Badge( // shape: BadgeShape.circle, - // badgeContent: Text(_badgeText, style: TextStyle(color: Colors.white)), + // badgeContent: + Text(_badgeText, style: TextStyle(color: Colors.white)), // child: Icon(Icons.shopping_cart)), // color: Colors.white, // onPressed: () { @@ -368,10 +375,10 @@ class _RobotIcon extends State { bottom: -15); } - // setAnimation() async { - // /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || - // // var animation = - // // IS_TEXT_COMPLETED == ? true : false; +// setAnimation() async { +// /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || +// // var animation = +// // IS_TEXT_COMPLETED == ? true : false; - // } +// } } diff --git a/lib/widgets/others/app_scafold_detail_page.dart b/lib/widgets/others/app_scafold_detail_page.dart index b7f98b08..595e0872 100644 --- a/lib/widgets/others/app_scafold_detail_page.dart +++ b/lib/widgets/others/app_scafold_detail_page.dart @@ -6,7 +6,9 @@ import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; import 'package:diplomaticquarterapp/routes.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/bottom_bar.dart'; @@ -23,7 +25,7 @@ import '../progress_indicator/app_loader_widget.dart'; import 'arrow_back.dart'; import 'network_base_view.dart'; import 'not_auh_page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; class DetailPageScafold extends StatefulWidget { @@ -183,6 +185,18 @@ class AppBarWidget extends StatelessWidget with PreferredSizeWidget { ), centerTitle: true, actions: [ + /// TODO Elham* fix this + if(isPharmacy) + IconButton( + icon: Icon(Icons.shopping_cart), + color: Colors.grey, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CartOrderPage()), + ); + }), image != null ? InkWell( onTap: () => Navigator.push( @@ -219,4 +233,49 @@ class AppBarWidget extends StatelessWidget with PreferredSizeWidget { @override Size get preferredSize => Size(double.maxFinite, 60); + + + settingModalBottomSheet(context) { + showModalBottomSheet( + context: context, + builder: (BuildContext bc) { + return Container( + child: new Wrap( + children: [ + new ListTile( + leading: Icon(Icons.shopping_cart), + title: Text( + TranslationBase.of(context).addToCart, + ), + onTap: () => { + if (price > 0) + {addToCartFunction(price, itemID, context)} + else + { + AppToast.showErrorToast( + message: "you should add quantity") + } + }), + ListTile( + leading: Icon(Icons.favorite_border), + title: Text( + TranslationBase.of(context).addToWishlist, + ), + onTap: () => {addToWishlistFunction(itemID)}, + ), + ListTile( + leading: Icon(Icons.compare), + title: Text( + TranslationBase.of(context).compare, + ), + onTap: () => { + Provider.of(context, listen: false) + .addItem(specificationData), + }, + ), + ], + ), + ); + }); + } }