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.
169 lines
6.5 KiB
Dart
169 lines
6.5 KiB
Dart
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
|
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/widgets/data_display/text.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';
|
|
|
|
import '../../../../locator.dart';
|
|
import 'shared/icon_with_bg.dart';
|
|
|
|
class ProductNameAndPrice extends StatefulWidget {
|
|
BuildContext context;
|
|
PharmacyProduct item;
|
|
final customerId;
|
|
final bool isInWishList;
|
|
final Function notifyMeWhenAvailable;
|
|
final Function addToWishlistFunction;
|
|
final Function deleteFromWishlistFunction;
|
|
final bool isStockAvailable;
|
|
|
|
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
|
|
|
|
ProductNameAndPrice(this.context, this.item,
|
|
{this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, @required this.isStockAvailable});
|
|
|
|
@override
|
|
_ProductNameAndPriceState createState() => _ProductNameAndPriceState();
|
|
}
|
|
|
|
class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
return Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
FractionallySizedBox(
|
|
widthFactor: 0.95,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Texts(widget.item.price.toString() + " " + TranslationBase.of(context).sar, fontWeight: FontWeight.bold, fontSize: 20),
|
|
Texts(
|
|
projectViewModel.isArabic ? widget.item.stockAvailabilityn : widget.item.stockAvailability,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 15,
|
|
color: widget.isStockAvailable ? Colors.green : Colors.red,
|
|
),
|
|
// SizedBox(width: 20),
|
|
if (widget.authenticatedUserObject.isLogin)
|
|
widget.isStockAvailable && widget.customerId != null
|
|
? InkWell(
|
|
onTap: () => widget.notifyMeWhenAvailable(context, widget.item.id),
|
|
child: Row(children: [
|
|
Texts(
|
|
TranslationBase.of(context).notifyMe,
|
|
decoration: TextDecoration.underline,
|
|
color: Colors.blue,
|
|
),
|
|
SizedBox(width: 4),
|
|
Icon(
|
|
FontAwesomeIcons.bell,
|
|
color: Colors.blue,
|
|
size: 15.0,
|
|
)
|
|
]),
|
|
)
|
|
: IconWithBg(
|
|
icon: !widget.isInWishList ? Icons.favorite_border : Icons.favorite,
|
|
color: !widget.isInWishList ? Colors.white : Colors.red[800],
|
|
onPress: () async {
|
|
{
|
|
if (widget.customerId != null) {
|
|
if (!widget.isInWishList) {
|
|
await widget.addToWishlistFunction(widget.item.id);
|
|
} 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.namen : widget.item.name,
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
FractionallySizedBox(
|
|
widthFactor: 0.95,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
child: Align(
|
|
alignment: Alignment.bottomLeft,
|
|
child: Row(
|
|
children: [
|
|
RatingBar.readOnly(
|
|
initialRating: double.parse(widget.item.approvedRatingSum.toString()),
|
|
size: 15.0,
|
|
filledColor: Colors.yellow[700],
|
|
emptyColor: Colors.grey[400],
|
|
isHalfAllowed: true,
|
|
halfFilledIcon: Icons.star_half,
|
|
filledIcon: Icons.star,
|
|
emptyIcon: Icons.star,
|
|
),
|
|
SizedBox(
|
|
width: 10,
|
|
),
|
|
Texts(
|
|
"${widget.item.approvedRatingSum}",
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 12,
|
|
),
|
|
SizedBox(
|
|
width: 30,
|
|
),
|
|
Texts(
|
|
"(${widget.item.approvedTotalReviews}${TranslationBase.of(context).review})",
|
|
fontSize: 12,
|
|
),
|
|
SizedBox(
|
|
width: 70,
|
|
),
|
|
if (widget.item.rxMessage != null)
|
|
Row(
|
|
children: [
|
|
Text(
|
|
projectViewModel.isArabic ? widget.item.rxMessagen.toString() : widget.item.rxMessage.toString(),
|
|
style: TextStyle(color: Colors.red, fontSize: 10),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|