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:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.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: [ 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( projectViewModel.isArabic ? 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' && widget.customerId != null ? InkWell( onTap: () => widget.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: projectViewModel.isArabic ? 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(!widget.isInWishList ? Icons.favorite_border : Icons.favorite), color: !widget.isInWishList ? Colors.white : Colors.red, onPressed: () 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.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( 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(), ], ), ], ); } }