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.
159 lines
5.7 KiB
Dart
159 lines
5.7 KiB
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils.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';
|
|
|
|
|
|
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 Directionality(
|
|
textDirection: TextDirection.rtl,
|
|
child: Stack(
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.only(
|
|
left: widget.itemContentPadding,
|
|
right: widget.itemContentPadding,
|
|
top: widget.itemContentPadding + 5),
|
|
child: Container(
|
|
width: widget.itemWidth,
|
|
color: Colors.transparent,
|
|
child: 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);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
top: 0,
|
|
right: 0,
|
|
child: Visibility(
|
|
visible: false,
|
|
child: InkWell(
|
|
child: Icon(
|
|
Icons.favorite,
|
|
size: 40.0,
|
|
color: Colors.red,
|
|
),
|
|
onTap: () {
|
|
|
|
},
|
|
),
|
|
),
|
|
),
|
|
|
|
Positioned(
|
|
top: 7,
|
|
left: 2,
|
|
child: Image.asset(
|
|
'assets/images/discount_${'en'}.png',
|
|
height: 60,
|
|
width: 60,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|