fix quantity_box
parent
d5f1a162c0
commit
e20e90c20c
@ -1,456 +0,0 @@
|
|||||||
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
|
||||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
||||||
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
|
|
||||||
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import '../cart-order-page.dart';
|
|
||||||
|
|
||||||
class FooterWidget extends StatefulWidget {
|
|
||||||
final bool isAvailble;
|
|
||||||
final int maxQuantity;
|
|
||||||
final int minQuantity;
|
|
||||||
final int quantityLimit;
|
|
||||||
final PharmacyProduct item;
|
|
||||||
final Function addToCartFunction;
|
|
||||||
|
|
||||||
int price;
|
|
||||||
bool isOverQuantity;
|
|
||||||
|
|
||||||
FooterWidget(this.isAvailble, this.maxQuantity, this.minQuantity,
|
|
||||||
this.quantityLimit, this.item, {this.price, this.isOverQuantity = false, this.addToCartFunction});
|
|
||||||
|
|
||||||
@override
|
|
||||||
_FooterWidgetState createState() => _FooterWidgetState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FooterWidgetState extends State<FooterWidget> {
|
|
||||||
double quantityUI = 70;
|
|
||||||
bool showUI = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: quantityUI,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
showUI
|
|
||||||
? Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: 90,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Container(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
TranslationBase.of(context).quantity,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 15, fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
Container(
|
|
||||||
height: 50.0,
|
|
||||||
child: ListView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
children: <Widget>[
|
|
||||||
InkWell(
|
|
||||||
child: Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
width: 50.0,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
'1',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
widget.price = 1;
|
|
||||||
if (widget.price >= widget.quantityLimit) {
|
|
||||||
widget.isOverQuantity = true;
|
|
||||||
} else {
|
|
||||||
widget.isOverQuantity = false;
|
|
||||||
return widget.price;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
child: Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
width: 50.0,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
'2',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
widget.price = 2;
|
|
||||||
if (widget.price >= widget.quantityLimit) {
|
|
||||||
widget.isOverQuantity = true;
|
|
||||||
} else {
|
|
||||||
widget.isOverQuantity = false;
|
|
||||||
return widget.price;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
child: Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
width: 50.0,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
'3',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
widget.price = 3;
|
|
||||||
if (widget.price >= widget.quantityLimit) {
|
|
||||||
widget.isOverQuantity = true;
|
|
||||||
} else {
|
|
||||||
widget.isOverQuantity = false;
|
|
||||||
return widget.price;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
child: Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
width: 50.0,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
'4',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
widget.price = 4;
|
|
||||||
if (widget.price >= widget.quantityLimit) {
|
|
||||||
widget.isOverQuantity = true;
|
|
||||||
} else {
|
|
||||||
widget.isOverQuantity = false;
|
|
||||||
return widget.price;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
child: Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
width: 50.0,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
'5',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
widget.price = 5;
|
|
||||||
if (widget.price >= widget.quantityLimit) {
|
|
||||||
widget.isOverQuantity = true;
|
|
||||||
} else {
|
|
||||||
widget.isOverQuantity = false;
|
|
||||||
return widget.price;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
child: Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
width: 50.0,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
'6',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
widget.price = 6;
|
|
||||||
if (widget.price >= widget.quantityLimit) {
|
|
||||||
widget.isOverQuantity = true;
|
|
||||||
} else {
|
|
||||||
widget.isOverQuantity = false;
|
|
||||||
return widget.price;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
child: Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
width: 50.0,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
'7',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
widget.price = 7;
|
|
||||||
if (widget.price >= widget.quantityLimit) {
|
|
||||||
widget.isOverQuantity = true;
|
|
||||||
} else {
|
|
||||||
widget.isOverQuantity = false;
|
|
||||||
return widget.price;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
child: Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
width: 50.0,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
'8',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
widget.price = 8;
|
|
||||||
if (widget.price >= widget.quantityLimit) {
|
|
||||||
widget.isOverQuantity = true;
|
|
||||||
} else {
|
|
||||||
widget.isOverQuantity = false;
|
|
||||||
return widget.price;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
child: Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
width: 50.0,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
'9',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
widget.price = 9;
|
|
||||||
if (widget.price >= widget.quantityLimit) {
|
|
||||||
widget.isOverQuantity = true;
|
|
||||||
} else {
|
|
||||||
widget.isOverQuantity = false;
|
|
||||||
return widget.price;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
child: Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
width: 50.0,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
'10',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
widget.price = 10;
|
|
||||||
if (widget.price >= widget.quantityLimit) {
|
|
||||||
widget.isOverQuantity = true;
|
|
||||||
} else {
|
|
||||||
widget.isOverQuantity = false;
|
|
||||||
return widget.price;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: 50.0,
|
|
||||||
child: TextField(
|
|
||||||
decoration:
|
|
||||||
InputDecoration(labelText: 'quantity #'),
|
|
||||||
onChanged: (text) {
|
|
||||||
print(widget.price);
|
|
||||||
print(widget.quantityLimit);
|
|
||||||
if (int.tryParse(text) == null) {
|
|
||||||
text = '';
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
widget.price = int.parse(text);
|
|
||||||
if (widget.price >= widget.quantityLimit) {
|
|
||||||
widget.isOverQuantity = true;
|
|
||||||
} else {
|
|
||||||
widget.isOverQuantity = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: 70,
|
|
||||||
height: 50,
|
|
||||||
child: FlatButton(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
flex: 4,
|
|
||||||
child: Text(
|
|
||||||
widget.price.toString(),
|
|
||||||
style: TextStyle(fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 5,
|
|
||||||
child: Text(
|
|
||||||
TranslationBase.of(context).quantityShortcut,
|
|
||||||
style: TextStyle(fontSize: 16),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
if (showUI) {
|
|
||||||
quantityUI = 70;
|
|
||||||
showUI = false;
|
|
||||||
} else {
|
|
||||||
quantityUI = 150;
|
|
||||||
showUI = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
Container(
|
|
||||||
width: MediaQuery.of(context).size.width* 0.4,
|
|
||||||
child: SecondaryButton(
|
|
||||||
label: TranslationBase.of(context).addToCart.toUpperCase(),
|
|
||||||
disabled: !widget.isAvailble && widget.price > 0 ||
|
|
||||||
widget.price > widget.quantityLimit ||
|
|
||||||
widget.item.rxMessage != null,
|
|
||||||
onTap: () {
|
|
||||||
widget.addToCartFunction(widget.price, widget.item.id, context);
|
|
||||||
},
|
|
||||||
borderRadius: 5,
|
|
||||||
color:Colors.green,
|
|
||||||
|
|
||||||
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
|
|
||||||
Container(
|
|
||||||
width: MediaQuery.of(context).size.width* 0.3,
|
|
||||||
child: SecondaryButton(
|
|
||||||
label: TranslationBase.of(context).buyNow.toUpperCase(),
|
|
||||||
disabled: !widget.isAvailble && widget.price > 0 ||
|
|
||||||
widget.price > widget.quantityLimit ||
|
|
||||||
widget.item.rxMessage != null,
|
|
||||||
onTap: () {
|
|
||||||
widget.addToCartFunction(
|
|
||||||
widget.price, widget.item.id, context);
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
FadePage(page: CartOrderPage()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
borderRadius: 5,
|
|
||||||
color: !widget.isAvailble && widget.price > 0 ||
|
|
||||||
widget.price > widget.quantityLimit ||
|
|
||||||
widget.item.rxMessage != null?Colors.grey:Colors.grey[800],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,240 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/footor/quantity_box.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hexcolor/hexcolor.dart';
|
||||||
|
|
||||||
|
import '../../cart-order-page.dart';
|
||||||
|
|
||||||
|
class FooterWidget extends StatefulWidget {
|
||||||
|
final bool isAvailable;
|
||||||
|
final int maxQuantity;
|
||||||
|
final int minQuantity;
|
||||||
|
final int quantityLimit;
|
||||||
|
final PharmacyProduct item;
|
||||||
|
final Function addToCartFunction;
|
||||||
|
|
||||||
|
int price;
|
||||||
|
bool isOverQuantity;
|
||||||
|
|
||||||
|
FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity,
|
||||||
|
this.quantityLimit, this.item,
|
||||||
|
{this.price, this.isOverQuantity = false, this.addToCartFunction});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_FooterWidgetState createState() => _FooterWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FooterWidgetState extends State<FooterWidget> {
|
||||||
|
double quantityUI = 70;
|
||||||
|
bool showUI = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(0.0),
|
||||||
|
),
|
||||||
|
border: Border.all(color: HexColor('#707070'), width: 0),
|
||||||
|
),
|
||||||
|
width: double.infinity,
|
||||||
|
height: quantityUI,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
showUI
|
||||||
|
? Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 100,
|
||||||
|
color: Colors.white,
|
||||||
|
child: Container(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
"Quantity",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
child: Icon(Icons.close, color: Colors.black),
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
quantityUI = 70;
|
||||||
|
showUI = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 50.0,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
for (int i = 1; i <= 10; i++)
|
||||||
|
QuantityBox(
|
||||||
|
label: i,
|
||||||
|
onTapFunc: onChangeValue,
|
||||||
|
isSelected: widget.price == i),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 100,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border:
|
||||||
|
Border.all(color: Colors.grey[300]),
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
child: TextField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'quantity #'),
|
||||||
|
onChanged: (text) {
|
||||||
|
print(widget.price);
|
||||||
|
print(widget.quantityLimit);
|
||||||
|
if (int.tryParse(text) == null) {
|
||||||
|
text = '';
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
widget.price = int.parse(text);
|
||||||
|
if (widget.price >=
|
||||||
|
widget.quantityLimit) {
|
||||||
|
widget.isOverQuantity = true;
|
||||||
|
} else {
|
||||||
|
widget.isOverQuantity = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 70,
|
||||||
|
height: 50,
|
||||||
|
child: FlatButton(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 4,
|
||||||
|
child: Text(
|
||||||
|
widget.price.toString(),
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 5,
|
||||||
|
child: Text(
|
||||||
|
TranslationBase.of(context).quantityShortcut,
|
||||||
|
style: TextStyle(fontSize: 16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
if (showUI) {
|
||||||
|
quantityUI = 70;
|
||||||
|
showUI = false;
|
||||||
|
} else {
|
||||||
|
quantityUI = 150;
|
||||||
|
showUI = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.4,
|
||||||
|
child: SecondaryButton(
|
||||||
|
label: TranslationBase.of(context).addToCart.toUpperCase(),
|
||||||
|
disabled: !widget.isAvailable && widget.price > 0 ||
|
||||||
|
widget.price > widget.quantityLimit ||
|
||||||
|
widget.item.rxMessage != null,
|
||||||
|
onTap: () {
|
||||||
|
widget.addToCartFunction(
|
||||||
|
widget.price, widget.item.id, context);
|
||||||
|
},
|
||||||
|
borderRadius: 5,
|
||||||
|
color: Colors.green,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.3,
|
||||||
|
child: SecondaryButton(
|
||||||
|
label: TranslationBase.of(context).buyNow.toUpperCase(),
|
||||||
|
disabled: !widget.isAvailable && widget.price > 0 ||
|
||||||
|
widget.price > widget.quantityLimit ||
|
||||||
|
widget.item.rxMessage != null,
|
||||||
|
onTap: () {
|
||||||
|
widget.addToCartFunction(
|
||||||
|
widget.price, widget.item.id, context);
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
FadePage(page: CartOrderPage()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
borderRadius: 5,
|
||||||
|
color: !widget.isAvailable && widget.price > 0 ||
|
||||||
|
widget.price > widget.quantityLimit ||
|
||||||
|
widget.item.rxMessage != null
|
||||||
|
? Colors.grey
|
||||||
|
: Colors.grey[800],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onChangeValue(int i) {
|
||||||
|
setState(() {
|
||||||
|
///TODO Elham* Check this if its good
|
||||||
|
widget.price = i;
|
||||||
|
if (widget.price >= widget.quantityLimit) {
|
||||||
|
widget.isOverQuantity = true;
|
||||||
|
} else {
|
||||||
|
widget.isOverQuantity = false;
|
||||||
|
return widget.price;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class QuantityBox extends StatelessWidget {
|
||||||
|
final int label;
|
||||||
|
final bool isSelected;
|
||||||
|
final Function(int) onTapFunc;
|
||||||
|
|
||||||
|
QuantityBox({
|
||||||
|
Key key,
|
||||||
|
this.label,
|
||||||
|
this.onTapFunc, this.isSelected = false,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
InkWell(
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color:isSelected?Colors.green: Colors.grey[300]),
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
width: 50.0,
|
||||||
|
|
||||||
|
child: Text(
|
||||||
|
'$label',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap:(){
|
||||||
|
onTapFunc(label);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 5,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue