You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
492 lines
19 KiB
Dart
492 lines
19 KiB
Dart
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.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;
|
|
}
|
|
});
|
|
},
|
|
),
|
|
),
|
|
!widget.isAvailble && widget.price > 0 ||
|
|
widget.price > widget.quantityLimit ||
|
|
widget.item.rxMessage != null
|
|
? Container(
|
|
width: 190,
|
|
height: 46,
|
|
color: Colors.grey,
|
|
child: Align(
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
TranslationBase.of(context).addToCart,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 15),
|
|
),
|
|
),
|
|
)
|
|
: InkWell(
|
|
onTap: () {
|
|
widget.addToCartFunction(widget.price, widget.item.id, context);
|
|
},
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
width: 190,
|
|
height: 46,
|
|
color: Colors.green,
|
|
child: Text(
|
|
TranslationBase.of(context).addToCart,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 15),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 5,
|
|
),
|
|
!widget.isAvailble && widget.price > 0 ||
|
|
widget.price > widget.quantityLimit ||
|
|
widget.item.rxMessage != null
|
|
? Container(
|
|
width: 120,
|
|
height: 46,
|
|
color: Colors.grey,
|
|
child: Align(
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
TranslationBase.of(context).buyNow,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 15),
|
|
),
|
|
),
|
|
)
|
|
: InkWell(
|
|
onTap: () {
|
|
print('buy now');
|
|
widget.addToCartFunction(widget.price, widget.item.id, context);
|
|
Navigator.push(
|
|
context,
|
|
FadePage(page: CartOrderPage()),
|
|
);
|
|
},
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
width: 120,
|
|
height: 46,
|
|
color: Colors.blue,
|
|
child: Text(
|
|
TranslationBase.of(context).buyNow,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 15),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |