|
|
|
@ -23,10 +23,17 @@ class ProductNameAndPrice extends StatefulWidget {
|
|
|
|
|
final bool isStockAvailable;
|
|
|
|
|
final String stockAvailability;
|
|
|
|
|
|
|
|
|
|
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
|
|
|
|
|
AuthenticatedUserObject authenticatedUserObject =
|
|
|
|
|
locator<AuthenticatedUserObject>();
|
|
|
|
|
|
|
|
|
|
ProductNameAndPrice(this.context, this.item,
|
|
|
|
|
{this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable = true, this.stockAvailability});
|
|
|
|
|
{this.customerId,
|
|
|
|
|
this.isInWishList,
|
|
|
|
|
this.notifyMeWhenAvailable,
|
|
|
|
|
this.addToWishlistFunction,
|
|
|
|
|
this.deleteFromWishlistFunction,
|
|
|
|
|
this.isStockAvailable = true,
|
|
|
|
|
this.stockAvailability});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ProductNameAndPriceState createState() => _ProductNameAndPriceState();
|
|
|
|
@ -66,17 +73,19 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
projectViewModel.isArabic ? widget.item.rxMessagen.toString() : widget.item.rxMessage.toString(),
|
|
|
|
|
style: TextStyle(color: Colors.white,
|
|
|
|
|
projectViewModel.isArabic
|
|
|
|
|
? widget.item.rxMessagen.toString()
|
|
|
|
|
: widget.item.rxMessage.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
// regular: true,
|
|
|
|
|
fontSize: 17,
|
|
|
|
|
fontWeight: FontWeight.w600, letterSpacing:-0.68
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
letterSpacing:-0.68
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
))
|
|
|
|
|
: Container(),
|
|
|
|
|
FractionallySizedBox(
|
|
|
|
|
widthFactor: 0.93,
|
|
|
|
@ -84,9 +93,11 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
// Texts(widget.item.price.toString() + " " + TranslationBase.of(context).sar, fontWeight: FontWeight.bold, fontSize: 20),
|
|
|
|
|
if (widget.stockAvailability != null)
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.only(top: 10.0, right: 10.0),
|
|
|
|
|
padding: EdgeInsets.only(left: 11, right: 11,),
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
left: 11.0, right: 11.0, top: 0, bottom: 0),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: getStatusBackgroundColor(),
|
|
|
|
@ -95,32 +106,51 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
|
|
|
|
|
),
|
|
|
|
|
color: getStatusBackgroundColor(),
|
|
|
|
|
borderRadius: BorderRadius.circular(30.0)),
|
|
|
|
|
// child: Text(
|
|
|
|
|
// widget.stockAvailability,
|
|
|
|
|
// style: TextStyle(
|
|
|
|
|
// fontWeight: FontWeight.w600,
|
|
|
|
|
// fontSize: 11,
|
|
|
|
|
// color: Color(0xffFFFFFF),
|
|
|
|
|
// ),
|
|
|
|
|
// color: getStatusBackgroundColor(),
|
|
|
|
|
// borderRadius: BorderRadius.circular(30.0)),
|
|
|
|
|
child: Text(
|
|
|
|
|
widget.stockAvailability,
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 11, color: Color(0xffFFFFFF),letterSpacing:-0.44),
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 11, color: Color(0xffFFFFFF),letterSpacing:-0.44)),
|
|
|
|
|
//color: widget.isStockAvailable ? Colors.white : Colors.red,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
// SizedBox(width: 20),
|
|
|
|
|
if (widget.authenticatedUserObject.isLogin)
|
|
|
|
|
!widget.isStockAvailable && widget.customerId != null
|
|
|
|
|
// if (
|
|
|
|
|
widget.authenticatedUserObject.isLogin &&
|
|
|
|
|
widget.stockAvailability != null &&
|
|
|
|
|
!widget.isStockAvailable &&
|
|
|
|
|
widget.customerId != null
|
|
|
|
|
? IconButton(
|
|
|
|
|
iconSize: 25,
|
|
|
|
|
icon: Icon(Icons.notifications_active),
|
|
|
|
|
color: new Color(0xff2E303A),
|
|
|
|
|
onPressed: ()
|
|
|
|
|
{ widget.notifyMeWhenAvailable(context, widget.item.id);},
|
|
|
|
|
|
|
|
|
|
): IconButton(
|
|
|
|
|
icon: Icon(!widget.isInWishList ? Icons.favorite_border : Icons.favorite),
|
|
|
|
|
color: !widget.isInWishList ? Color(0xff2E303A) : Color(0xffD02127),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
widget.notifyMeWhenAvailable(
|
|
|
|
|
context, widget.item.id);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
: IconButton(
|
|
|
|
|
icon: Icon(!widget.isInWishList
|
|
|
|
|
? Icons.favorite_border
|
|
|
|
|
: Icons.favorite),
|
|
|
|
|
color: !widget.isInWishList
|
|
|
|
|
? Color(0xff2E303A)
|
|
|
|
|
: Color(0xffD02127),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
{
|
|
|
|
|
if (widget.customerId != null) {
|
|
|
|
|
if (!widget.isInWishList) {
|
|
|
|
|
await widget.addToWishlistFunction(widget.item.id);
|
|
|
|
|
await widget
|
|
|
|
|
.addToWishlistFunction(widget.item.id);
|
|
|
|
|
} else {
|
|
|
|
|
await widget.deleteFromWishlistFunction(widget.item.id);
|
|
|
|
|
await widget.deleteFromWishlistFunction(
|
|
|
|
|
widget.item.id);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return;
|
|
|
|
@ -177,31 +207,45 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 8,right: 8, top: 1, bottom: 12),
|
|
|
|
|
padding:
|
|
|
|
|
const EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 12),
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: EdgeInsets.only(left: 10, right: 10),
|
|
|
|
|
child: Align(
|
|
|
|
|
alignment: projectViewModel.isArabic ? Alignment.topRight : Alignment.topLeft,
|
|
|
|
|
alignment: projectViewModel.isArabic
|
|
|
|
|
? Alignment.topRight
|
|
|
|
|
: Alignment.topLeft,
|
|
|
|
|
child: Text(
|
|
|
|
|
projectViewModel.isArabic ? widget.item.namen : widget.item.name,
|
|
|
|
|
style: TextStyle( fontWeight: FontWeight.w600, fontSize: 16, letterSpacing:-0.96),
|
|
|
|
|
projectViewModel.isArabic
|
|
|
|
|
? widget.item.namen
|
|
|
|
|
: widget.item.name,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
letterSpacing: -0.96),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 8, right: 8),
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: EdgeInsets.only(left: 10, right: 10),
|
|
|
|
|
child: Align(
|
|
|
|
|
alignment: projectViewModel.isArabic ? Alignment.topRight : Alignment.topLeft,
|
|
|
|
|
child: Text( TranslationBase.of(context).sar+ " " +
|
|
|
|
|
alignment: projectViewModel.isArabic
|
|
|
|
|
? Alignment.topRight
|
|
|
|
|
: Alignment.topLeft,
|
|
|
|
|
child: Text(
|
|
|
|
|
TranslationBase.of(context).sar +
|
|
|
|
|
" " +
|
|
|
|
|
widget.item.price.toString(),
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 19, letterSpacing:-0.76),),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 19,
|
|
|
|
|
letterSpacing: -0.76),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
FractionallySizedBox(
|
|
|
|
|
widthFactor: 0.95,
|
|
|
|
@ -214,7 +258,8 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
RatingBar.readOnly(
|
|
|
|
|
initialRating: double.parse(widget.item.approvedRatingSum.toString()),
|
|
|
|
|
initialRating: double.parse(
|
|
|
|
|
widget.item.approvedRatingSum.toString()),
|
|
|
|
|
size: 18.0,
|
|
|
|
|
filledColor: Color(0XFFD02127),
|
|
|
|
|
emptyColor: Color(0XFFD02127),
|
|
|
|
@ -236,7 +281,8 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
|
|
|
|
|
// ),
|
|
|
|
|
Text(
|
|
|
|
|
"(${widget.item.approvedTotalReviews}${TranslationBase.of(context).review})",
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 12),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontWeight: FontWeight.w600, fontSize: 12),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 70,
|
|
|
|
@ -268,6 +314,7 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
|
|
|
|
|
Color getStatusBackgroundColor() {
|
|
|
|
|
if (widget.isStockAvailable)
|
|
|
|
|
return Color(0xFF5AB145);
|
|
|
|
|
else return Color(0xFFD02127);
|
|
|
|
|
else
|
|
|
|
|
return Color(0xFFD02127);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|