You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
354 lines
14 KiB
Dart
354 lines
14 KiB
Dart
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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/pharmacies/screens/cart-page/cart-order-page.dart';
|
|
import 'package:diplomaticquarterapp/pages/pharmacy/order/ProductReview.dart';
|
|
import 'package:diplomaticquarterapp/theme/colors.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/uitl/utils.dart';
|
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class productTile extends StatelessWidget {
|
|
final String? productName;
|
|
final String? productPrice;
|
|
final double? productRate;
|
|
final int? productReviews;
|
|
final String? qyt;
|
|
final String? totalPrice;
|
|
final bool isOrderDetails;
|
|
final String? productImage;
|
|
final bool showLine;
|
|
final String? img;
|
|
final String? imgs;
|
|
final int? status;
|
|
final PharmacyProduct? product;
|
|
final dynamic productID;
|
|
final Function? onDelete;
|
|
final dynamic approvedTotalReviews;
|
|
final dynamic isRx;
|
|
|
|
// final VoidCallback deleteWishlistItems;
|
|
|
|
productTile(
|
|
{this.productName,
|
|
this.productPrice,
|
|
this.productRate,
|
|
this.productReviews,
|
|
this.qyt,
|
|
this.totalPrice,
|
|
this.isOrderDetails = false,
|
|
this.productImage,
|
|
this.showLine = true,
|
|
this.img,
|
|
this.imgs,
|
|
this.status,
|
|
this.product,
|
|
this.productID,
|
|
this.onDelete,
|
|
this.approvedTotalReviews,
|
|
this.isRx});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
return Container(
|
|
height: 180,
|
|
width: double.infinity,
|
|
color: Colors.white,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
this.imgs != null && this.imgs!.length > 0
|
|
? Container(
|
|
margin: EdgeInsets.only(left: 10),
|
|
child: Image.network(
|
|
imgs!,
|
|
// productImage.trim(),
|
|
fit: BoxFit.cover,
|
|
width: 80,
|
|
height: 80,
|
|
),
|
|
)
|
|
: Container(
|
|
margin: EdgeInsets.only(left: 10),
|
|
child: Image.network(
|
|
productImage!,
|
|
width: 80,
|
|
height: 80,
|
|
)
|
|
// fit: BoxFit.cover,
|
|
),
|
|
Expanded(
|
|
flex: 5,
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.all(5),
|
|
child: projectViewModel.isArabic
|
|
? Align(
|
|
alignment: Alignment.topRight,
|
|
child: RichText(
|
|
text: TextSpan(
|
|
text: productName,
|
|
style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
)
|
|
: Align(
|
|
alignment: Alignment.topLeft,
|
|
child: RichText(
|
|
text: TextSpan(
|
|
text: productName,
|
|
style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.all(5),
|
|
child: projectViewModel.isArabic
|
|
? Align(
|
|
alignment: Alignment.topRight,
|
|
child: RichText(
|
|
text: TextSpan(
|
|
text: 'SAR $productPrice',
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13),
|
|
),
|
|
),
|
|
)
|
|
: Align(
|
|
alignment: Alignment.topLeft,
|
|
child: RichText(
|
|
text: TextSpan(
|
|
text: 'SAR $productPrice',
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
this.isOrderDetails == false
|
|
? Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.all(5),
|
|
child: Align(
|
|
alignment: Alignment.topLeft,
|
|
child: RatingBar.builder(
|
|
initialRating: productRate!,
|
|
// size: 15.0,
|
|
// filledColor: Colors.yellow[700],
|
|
// emptyColor: Colors.grey[500],
|
|
// isHalfAllowed: true,
|
|
// halfFilledIcon: Icons.star_half,
|
|
// filledIcon: Icons.star,
|
|
// emptyIcon: Icons.star,
|
|
itemBuilder: (BuildContext context, int index) => Icon(
|
|
Icons.star,
|
|
color: CustomColors.accentColor,
|
|
size: 15,
|
|
),
|
|
onRatingUpdate: (double value) {},
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
'${approvedTotalReviews} ${TranslationBase.of(context).reviews}',
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 13),
|
|
),
|
|
],
|
|
)
|
|
: Container(),
|
|
],
|
|
),
|
|
),
|
|
this.isOrderDetails == false
|
|
? Expanded(
|
|
flex: 1,
|
|
child: Column(
|
|
children: [
|
|
IconButton(
|
|
icon: Icon(FontAwesomeIcons.trashAlt, size: 15),
|
|
onPressed: () {
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
// deleteFromWishlistFunction(productID);
|
|
onDelete!(productID);
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 50,
|
|
),
|
|
IconButton(
|
|
icon: Icon(
|
|
Icons.shopping_cart,
|
|
size: 18,
|
|
color: Colors.green,
|
|
),
|
|
onPressed: () async {
|
|
if (isRx == false) {
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
await addToCartFunction(1, productID, context);
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
Utils.navigateToCartPage();
|
|
} else {
|
|
AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription);
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
)
|
|
: Container(),
|
|
],
|
|
),
|
|
this.isOrderDetails == true
|
|
? Expanded(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(bottom: 5.0),
|
|
child: RichText(
|
|
text: TextSpan(
|
|
text: TranslationBase.of(context).quantity + "" + '$qyt',
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 13),
|
|
),
|
|
),
|
|
),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
TranslationBase.of(context).total,
|
|
style: TextStyle(
|
|
color: Colors.grey,
|
|
fontSize: 13.0,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
RichText(
|
|
text: TextSpan(
|
|
text: ' $totalPrice SAR',
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 15),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
)
|
|
: Container(),
|
|
// this.isOrderDetails == true && model.order[0].orderStatusId == 30?
|
|
|
|
if (status == 30 || status == 997 && this.isOrderDetails == true)
|
|
Expanded(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
Container(
|
|
// margin: EdgeInsets.all(5.0),
|
|
child: Align(
|
|
alignment: Alignment.topLeft,
|
|
child: RatingBar(
|
|
initialRating: productRate!,
|
|
//size: 15.0,
|
|
// filledColor: ,
|
|
// emptyColor: ,
|
|
// isHalfAllowed: true,
|
|
// halfFilledIcon: Icons.star_half,
|
|
// filledIcon: ,
|
|
ratingWidget: RatingWidget(
|
|
full: Icon(
|
|
Icons.star,
|
|
color: CustomColors.accentColor,
|
|
size: 15,
|
|
),
|
|
half: Icon(
|
|
Icons.star_half,
|
|
color: CustomColors.accentColor,
|
|
size: 15,
|
|
),
|
|
empty: Icon(
|
|
Icons.star_half,
|
|
color: CustomColors.accentColor,
|
|
size: 15,
|
|
),
|
|
),
|
|
updateOnDrag: false,
|
|
unratedColor: Colors.grey[500],
|
|
onRatingUpdate: (double value) {},
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
// margin: EdgeInsets.all(5),
|
|
child: Align(
|
|
// alignment: Alignment.topLeft,
|
|
child: RichText(
|
|
text: TextSpan(
|
|
text: '${productReviews} ${TranslationBase.of(context).reviews}',
|
|
// text: '($productReviews reviews)',
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 13),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
Navigator.push(context, FadePage(page: ProductReviewPage(product!)));
|
|
},
|
|
child: Container(
|
|
padding: EdgeInsets.only(left: 13.0, right: 13.0, top: 5.0),
|
|
height: 30.0,
|
|
decoration: BoxDecoration(border: Border.all(color: Colors.orange, style: BorderStyle.solid, width: 1.0), color: Colors.transparent, borderRadius: BorderRadius.circular(5.0)),
|
|
child: Text(
|
|
TranslationBase.of(context).writeReview,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.orange,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
/*Container(
|
|
|
|
),*/
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// deleteFromWishlistFunction(itemID) async {
|
|
// ProductDetailViewModel x = new ProductDetailViewModel();
|
|
// await x.deletWishlistData(itemID);
|
|
// }
|
|
|
|
addToCartFunction(quantity, itemID, BuildContext context) async {
|
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
|
await x.addToCartData(quantity, itemID, context);
|
|
}
|
|
}
|