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.
HMG_Patient_App/lib/widgets/offers_packages/PackagesOfferCard.dart

169 lines
7.5 KiB
Dart

import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart';
import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackageDetailPage.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/StarRating.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rating_bar/rating_bar.dart';
bool wide = true;
class PackagesItemCard extends StatefulWidget {
final double itemWidth;
final double itemHeight;
final double itemContentPadding;
final PackagesResponseModel itemModel;
final Function(PackagesResponseModel product) onCartClick;
const PackagesItemCard({this.itemWidth, this.itemHeight, @required this.itemModel, @required this.itemContentPadding, @required this.onCartClick, Key key}) : super(key: key);
@override
State<StatefulWidget> createState() => PackagesItemCardState();
}
class PackagesItemCardState extends State<PackagesItemCard> {
imageUrl() => widget.itemModel.images.isNotEmpty ? widget.itemModel.images.first.src : "https://wallpaperaccess.com/full/30103.jpg";
@override
Widget build(BuildContext context) {
wide = !wide;
return InkWell(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => OfferAndPackagesDetail(itemModel: widget.itemModel)));
},
child: Container(
// width: widget.itemWidth,
// color: Colors.transparent,
decoration: cardRadius(15.0),
width: MediaQuery.of(context).size.width * 0.46,
padding: const EdgeInsets.all(9.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(15.0),
child: Image.network("https://mdlaboratories.com/offersdiscounts/images/thumbs/0000162_dermatology-testing.jpeg", fit: BoxFit.fill, height: 180.0, width: 180.0),
),
Container(margin: const EdgeInsets.only(top: 8.0), child: Text(widget.itemModel.name, maxLines: 1, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold, letterSpacing: -0.56))),
Container(width: MediaQuery.of(context).size.width * 0.4, child: Text("Special discount for all HMG Employees and their first…", maxLines: 2, style: TextStyle(fontSize: 10.0, fontWeight: FontWeight.w600, letterSpacing: -0.4, color: CustomColors.textColor), overflow: TextOverflow.clip)),
if (widget.itemModel.hasDiscountsApplied) Container(margin: const EdgeInsets.only(top: 19.0), child: Text(widget.itemModel.oldPrice.toString() + " " + TranslationBase.of(context).sar, style: TextStyle(fontSize: 9.0, fontWeight: FontWeight.w600, letterSpacing: -0.36, decoration: TextDecoration.lineThrough, color: CustomColors.grey2))),
Container(
margin: widget.itemModel.hasDiscountsApplied ? const EdgeInsets.only(top: 0.0) : const EdgeInsets.only(top: 19.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(margin: const EdgeInsets.only(top: 0.0), child: Text(widget.itemModel.price.toString().trim() + " " + TranslationBase.of(context).sar, style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.bold, letterSpacing: -0.56))),
RatingBar.readOnly(
initialRating: 4.5,
size: 18.0,
filledColor: Color(0XFFD02127),
emptyColor: Color(0XFFD02127),
isHalfAllowed: true,
halfFilledIcon: Icons.star_half,
filledIcon: Icons.star,
emptyIcon: Icons.star_border,
),
],
),
InkWell(
child: Icon(
Icons.add_shopping_cart_rounded,
size: 30.0,
color: Colors.black,
),
onTap: () {
widget.onCartClick(widget.itemModel);
},
),
],
),
),
],
),
),
);
// Stack(
// children: [
// Column(
// mainAxisSize: MainAxisSize.max,
// children: [
// AspectRatio(
// aspectRatio:1 / 1,
// child: applyShadow(
// child: ClipRRect(
// borderRadius: BorderRadius.circular(10),
// child: Utils.loadNetworkImage(
// url: imageUrl(),
// )),
// )),
// Texts(
// widget.itemModel.getName(),
// fontWeight: FontWeight.normal,
// color: Colors.black,
// fontSize: 15
// ),
// Padding(
// padding: const EdgeInsets.only(left: 10, right: 10),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.end,
// mainAxisSize: MainAxisSize.max,
// children: [
// Stack(
// children: [
// Texts(
// '${widget.itemModel.oldPrice} ${'SAR'}',
// fontWeight: FontWeight.normal,
// decoration: TextDecoration.lineThrough,
// color: Colors.grey,
// fontSize: 12
// ),
// Padding(
// padding: const EdgeInsets.only(top: 8),
// child: Texts(
// '${widget.itemModel.price} ${'SAR'}',
// fontWeight: FontWeight.bold,
// color: Colors.green,
// fontSize: 18
// ),
// ),
// Padding(
// padding: const EdgeInsets.only(top: 35),
// child: StarRating(
// size: 15,
// totalCount: null,
// totalAverage: widget.itemModel.approvedRatingSum.toDouble(),
// forceStars: true),
// )
// ],
// ),
// Spacer(
// flex: 1,
// ),
// InkWell(
// child: Icon(
// Icons.add_shopping_cart_rounded,
// size: 30.0,
// color: Colors.grey,
// ),
// onTap: () {
// widget.onCartClick(widget.itemModel);
// },
// ),
// ],
// ),
// ),
// ],
// ),
// ],
// ),
// );
}
}