|
|
|
|
@ -30,13 +30,8 @@ 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();
|
|
|
|
|
@ -47,15 +42,16 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
bool showUI = false;
|
|
|
|
|
|
|
|
|
|
static final GlobalKey<FormState> _key = GlobalKey<FormState>();
|
|
|
|
|
AuthenticatedUserObject authenticatedUserObject =
|
|
|
|
|
locator<AuthenticatedUserObject>();
|
|
|
|
|
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
|
|
|
|
|
AppSharedPreferences sharedPref = new AppSharedPreferences();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
quantityUI = 160;
|
|
|
|
|
showUI = true;
|
|
|
|
|
if (!isBuyNowDisable() || !isAddToCartDisable()) {
|
|
|
|
|
quantityUI = 160;
|
|
|
|
|
showUI = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -100,11 +96,7 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Texts(
|
|
|
|
|
TranslationBase.of(context).productQuantity,
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
color: Color(0xFF575757)),
|
|
|
|
|
child: Texts(TranslationBase.of(context).productQuantity, fontSize: 15, fontWeight: FontWeight.bold, color: Color(0xFF575757)),
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
child: Icon(Icons.close, color: Colors.black),
|
|
|
|
|
@ -126,11 +118,7 @@ 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(
|
|
|
|
|
@ -141,16 +129,14 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
key: _key,
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
decoration:
|
|
|
|
|
InputDecoration(hintText: ' Quantity # '),
|
|
|
|
|
decoration: InputDecoration(hintText: ' 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;
|
|
|
|
|
@ -247,16 +233,12 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
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,
|
|
|
|
|
borderRadius: 6,
|
|
|
|
|
disableColor: Color(0xFFD6D6D6),
|
|
|
|
|
textColor:
|
|
|
|
|
isAddToCartDisable() ? Color(0xFFACACAC) : Colors.white,
|
|
|
|
|
textColor: isAddToCartDisable() ? Color(0xFFACACAC) : Colors.white,
|
|
|
|
|
color: Color(0xFF535353),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -274,14 +256,10 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
textColor:
|
|
|
|
|
isBuyNowDisable() ? Color(0xFFACACAC) : Colors.white,
|
|
|
|
|
textColor: isBuyNowDisable() ? Color(0xFFACACAC) : Colors.white,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
borderRadius: 6,
|
|
|
|
|
disableColor: Color(0xFFD6D6D6),
|
|
|
|
|
@ -297,15 +275,11 @@ class _FooterWidgetState extends State<FooterWidget> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isBuyNowDisable() {
|
|
|
|
|
return (!widget.isAvailable && widget.quantity > 0) ||
|
|
|
|
|
(widget.quantity > widget.quantityLimit) ||
|
|
|
|
|
widget.item.isRx;
|
|
|
|
|
return (!widget.isAvailable && widget.quantity > 0) || (widget.quantity > widget.quantityLimit) || widget.item.isRx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isAddToCartDisable() {
|
|
|
|
|
return (!widget.isAvailable && widget.quantity > 0) ||
|
|
|
|
|
widget.quantity > widget.quantityLimit ||
|
|
|
|
|
widget.item.isRx;
|
|
|
|
|
return (!widget.isAvailable && widget.quantity > 0) || widget.quantity > widget.quantityLimit || widget.item.isRx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setUserValues(value) async {
|
|
|
|
|
@ -320,9 +294,7 @@ 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);
|
|
|
|
|
|