|
|
|
|
@ -28,8 +28,13 @@ class FooterWidget extends StatefulWidget {
|
|
|
|
|
int quantity;
|
|
|
|
|
bool isOverQuantity;
|
|
|
|
|
|
|
|
|
|
FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity, this.quantityLimit, this.item,
|
|
|
|
|
{this.quantity, this.isOverQuantity = false, this.addToCartFunction, this.addToShoppingCartFunction, this.model});
|
|
|
|
|
FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity,
|
|
|
|
|
this.quantityLimit, this.item,
|
|
|
|
|
{this.quantity,
|
|
|
|
|
this.isOverQuantity = false,
|
|
|
|
|
this.addToCartFunction,
|
|
|
|
|
this.addToShoppingCartFunction,
|
|
|
|
|
this.model});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_FooterWidgetState createState() => _FooterWidgetState();
|
|
|
|
|
@ -38,7 +43,8 @@ class FooterWidget extends StatefulWidget {
|
|
|
|
|
class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
double quantityUI = 80;
|
|
|
|
|
bool showUI = false;
|
|
|
|
|
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
|
|
|
|
|
AuthenticatedUserObject authenticatedUserObject =
|
|
|
|
|
locator<AuthenticatedUserObject>();
|
|
|
|
|
AppSharedPreferences sharedPref = new AppSharedPreferences();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -74,7 +80,8 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Text(
|
|
|
|
|
TranslationBase.of(context).quantity,
|
|
|
|
|
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 15, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
@ -97,7 +104,11 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 5,
|
|
|
|
|
),
|
|
|
|
|
for (int i = 1; i <= 10; i++) QuantityBox(label: i, onTapFunc: onChangeValue, isSelected: widget.quantity == i),
|
|
|
|
|
for (int i = 1; i <= 10; i++)
|
|
|
|
|
QuantityBox(
|
|
|
|
|
label: i,
|
|
|
|
|
onTapFunc: onChangeValue,
|
|
|
|
|
isSelected: widget.quantity == i),
|
|
|
|
|
Container(
|
|
|
|
|
width: 100,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
@ -105,14 +116,16 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
child: TextField(
|
|
|
|
|
decoration: InputDecoration(labelText: ' Quantity # '),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
labelText: ' Quantity # '),
|
|
|
|
|
onChanged: (text) {
|
|
|
|
|
if (int.tryParse(text) == null) {
|
|
|
|
|
text = '';
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.quantity = int.parse(text);
|
|
|
|
|
if (widget.quantity >= widget.quantityLimit) {
|
|
|
|
|
if (widget.quantity >=
|
|
|
|
|
widget.quantityLimit) {
|
|
|
|
|
widget.isOverQuantity = true;
|
|
|
|
|
} else {
|
|
|
|
|
widget.isOverQuantity = false;
|
|
|
|
|
@ -133,7 +146,7 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
height: 20,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
height: 55,
|
|
|
|
|
height: 58,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
@ -177,6 +190,7 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 10,
|
|
|
|
|
),
|
|
|
|
|
@ -184,17 +198,22 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.35,
|
|
|
|
|
child: SecondaryButton(
|
|
|
|
|
label: TranslationBase.of(context).addToCart.toUpperCase(),
|
|
|
|
|
disabled: (!widget.isAvailable && widget.quantity > 0) || widget.quantity > widget.quantityLimit || widget.item.isRx,
|
|
|
|
|
disabled: (!widget.isAvailable && widget.quantity > 0) ||
|
|
|
|
|
widget.quantity > widget.quantityLimit ||
|
|
|
|
|
widget.item.isRx,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
if (!authenticatedUserObject.isLogin) {
|
|
|
|
|
login();
|
|
|
|
|
} else
|
|
|
|
|
await widget.addToCartFunction(quantity: widget.quantity, itemID: widget.item.id, model: widget.model);
|
|
|
|
|
await widget.addToCartFunction(
|
|
|
|
|
quantity: widget.quantity,
|
|
|
|
|
itemID: widget.item.id,
|
|
|
|
|
model: widget.model);
|
|
|
|
|
},
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
borderColor: Color(0xFF4CAF50),
|
|
|
|
|
borderRadius: 3,
|
|
|
|
|
color: Color(0xFF4CAF50),
|
|
|
|
|
borderColor: Color(0xFF4CAF50).withOpacity(0.7),
|
|
|
|
|
borderRadius: 6,
|
|
|
|
|
color: Color(0xFF5AB145).withOpacity(0.7),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
@ -204,19 +223,28 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.35,
|
|
|
|
|
child: SecondaryButton(
|
|
|
|
|
label: TranslationBase.of(context).buyNow.toUpperCase(),
|
|
|
|
|
disabled: (!widget.isAvailable && widget.quantity > 0) || (widget.quantity > widget.quantityLimit) || widget.item.isRx,
|
|
|
|
|
disabled: (!widget.isAvailable && widget.quantity > 0) ||
|
|
|
|
|
(widget.quantity > widget.quantityLimit) ||
|
|
|
|
|
widget.item.isRx,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
if (!authenticatedUserObject.isLogin) {
|
|
|
|
|
login();
|
|
|
|
|
} else {
|
|
|
|
|
await widget.addToShoppingCartFunction(quantity: widget.quantity, itemID: widget.item.id, model: widget.model);
|
|
|
|
|
await widget.addToShoppingCartFunction(
|
|
|
|
|
quantity: widget.quantity,
|
|
|
|
|
itemID: widget.item.id,
|
|
|
|
|
model: widget.model);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
borderColor: Colors.grey[800],
|
|
|
|
|
borderRadius: 3,
|
|
|
|
|
borderColor: Colors.grey[800].withOpacity(0.7),
|
|
|
|
|
borderRadius: 6,
|
|
|
|
|
disableColor: Colors.grey[700],
|
|
|
|
|
color: !widget.isAvailable && widget.quantity > 0 || widget.quantity > widget.quantityLimit || widget.item.isRx ? Colors.grey : Colors.grey[800],
|
|
|
|
|
color: !widget.isAvailable && widget.quantity > 0 ||
|
|
|
|
|
widget.quantity > widget.quantityLimit ||
|
|
|
|
|
widget.item.isRx
|
|
|
|
|
? Color(0xFF535353).withOpacity(0.7)
|
|
|
|
|
: Colors.grey[800],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -239,7 +267,9 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
Navigator.of(context).pushNamed(CONFIRM_LOGIN);
|
|
|
|
|
} else {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
authService.selectDeviceImei(DEVICE_TOKEN).then((SelectDeviceIMEIRES value) {
|
|
|
|
|
authService
|
|
|
|
|
.selectDeviceImei(DEVICE_TOKEN)
|
|
|
|
|
.then((SelectDeviceIMEIRES value) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (value != null) {
|
|
|
|
|
setUserValues(value);
|
|
|
|
|
|