|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.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';
|
|
|
|
|
@ -10,6 +11,7 @@ import 'package:hexcolor/hexcolor.dart';
|
|
|
|
|
import '../../../../../locator.dart';
|
|
|
|
|
import '../../../../../routes.dart';
|
|
|
|
|
import '../../cart-order-page.dart';
|
|
|
|
|
import '../product-detail.dart';
|
|
|
|
|
|
|
|
|
|
class FooterWidget extends StatefulWidget {
|
|
|
|
|
final bool isAvailable;
|
|
|
|
|
@ -18,13 +20,17 @@ class FooterWidget extends StatefulWidget {
|
|
|
|
|
final int quantityLimit;
|
|
|
|
|
final PharmacyProduct item;
|
|
|
|
|
final Function addToCartFunction;
|
|
|
|
|
final ProductDetailViewModel model;
|
|
|
|
|
|
|
|
|
|
int quantity;
|
|
|
|
|
bool isOverQuantity;
|
|
|
|
|
|
|
|
|
|
FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity,
|
|
|
|
|
this.quantityLimit, this.item,
|
|
|
|
|
{this.quantity, this.isOverQuantity = false, this.addToCartFunction});
|
|
|
|
|
{this.quantity,
|
|
|
|
|
this.isOverQuantity = false,
|
|
|
|
|
this.addToCartFunction,
|
|
|
|
|
this.model});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_FooterWidgetState createState() => _FooterWidgetState();
|
|
|
|
|
@ -98,38 +104,31 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
label: i,
|
|
|
|
|
onTapFunc: onChangeValue,
|
|
|
|
|
isSelected: widget.quantity == 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.quantity);
|
|
|
|
|
print(widget.quantityLimit);
|
|
|
|
|
if (int.tryParse(text) == null) {
|
|
|
|
|
text = '';
|
|
|
|
|
Container(
|
|
|
|
|
width: 100,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border.all(color: Colors.grey[300]),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
child: TextField(
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
labelText: ' Quantity # '),
|
|
|
|
|
onChanged: (text) {
|
|
|
|
|
if (int.tryParse(text) == null) {
|
|
|
|
|
text = '';
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.quantity = int.parse(text);
|
|
|
|
|
if (widget.quantity >=
|
|
|
|
|
widget.quantityLimit) {
|
|
|
|
|
widget.isOverQuantity = true;
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.quantity = int.parse(text);
|
|
|
|
|
if (widget.quantity >=
|
|
|
|
|
widget.quantityLimit) {
|
|
|
|
|
widget.isOverQuantity = true;
|
|
|
|
|
} else {
|
|
|
|
|
widget.isOverQuantity = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
widget.isOverQuantity = false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -175,7 +174,7 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
quantityUI = 80;
|
|
|
|
|
showUI = false;
|
|
|
|
|
} else {
|
|
|
|
|
quantityUI = 150;
|
|
|
|
|
quantityUI = 160;
|
|
|
|
|
showUI = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
@ -197,10 +196,13 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
);
|
|
|
|
|
} else
|
|
|
|
|
await widget.addToCartFunction(
|
|
|
|
|
widget.quantity, widget.item.id, context);
|
|
|
|
|
quantity: widget.quantity,
|
|
|
|
|
itemID: widget.item.id,
|
|
|
|
|
model: widget.model);
|
|
|
|
|
},
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
borderColor: Color(0xFF4CAF50),
|
|
|
|
|
borderRadius: 5,
|
|
|
|
|
borderRadius: 3,
|
|
|
|
|
color: Color(0xFF4CAF50),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -215,14 +217,18 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
widget.quantity > widget.quantityLimit ||
|
|
|
|
|
widget.item.rxMessage != null,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
await widget.addToCartFunction(
|
|
|
|
|
widget.quantity, widget.item.id, context);
|
|
|
|
|
await widget.addToCartFunction(
|
|
|
|
|
quantity: widget.quantity,
|
|
|
|
|
itemID: widget.item.id,
|
|
|
|
|
model: widget.model);
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
FadePage(page: CartOrderPage()),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
borderRadius: 5,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
borderColor: Colors.grey[800],
|
|
|
|
|
borderRadius: 3,
|
|
|
|
|
disableColor: Colors.grey[700],
|
|
|
|
|
color: !widget.isAvailable && widget.quantity > 0 ||
|
|
|
|
|
widget.quantity > widget.quantityLimit ||
|
|
|
|
|
|