import 'package:diplomaticquarterapp/core/model/pharmacy_module/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class ProductTileItem extends StatelessWidget { final PharmacyProduct item; ProductTileItem(this.item); @override Widget build(BuildContext context) { ProjectViewModel projectProvider = Provider.of(context); return Card( elevation: 2, shape: Border(right: BorderSide(color: Colors.grey.shade300, width: 1)), margin: EdgeInsets.symmetric( horizontal: 8, vertical: 4, ), child: Container( padding: EdgeInsets.symmetric(horizontal: 0), width: MediaQuery.of(context).size.width / 3, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ Container( margin: EdgeInsets.fromLTRB(0, 16, 0, 0), alignment: Alignment.center, child: Image.network( item.images[0].src, fit: BoxFit.cover, height: 80, ), ), Container( width: item.rxMessage != null ? MediaQuery.of(context).size.width / 5 : 0, padding: EdgeInsets.all(4), decoration: BoxDecoration( color: Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), child: Texts( item.rxMessage != null ? item.rxMessage : "", color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w400, ), ) ], ), Container( margin: EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( projectProvider.isArabic ? item.name : item.namen, regular: true, fontSize: 12, fontWeight: FontWeight.w400, ), Padding( padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${item.price}", bold: true, fontSize: 14, ), ), Row( children: [ StarRating( totalAverage: item.approvedTotalReviews > 0 ? (item.approvedRatingSum.toDouble() / item.approvedTotalReviews.toDouble()) .toDouble() : 0, forceStars: true), Texts( "(${item.approvedTotalReviews})", regular: true, fontSize: 10, fontWeight: FontWeight.w400, ) ], ), ], ), ) ], ), ), ); } }