|
|
|
|
@ -12,30 +12,40 @@ import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/GestureIconButton.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class CartOrderPage extends StatelessWidget {
|
|
|
|
|
class CartOrderPage extends StatefulWidget {
|
|
|
|
|
const CartOrderPage({Key key}) : super(key: key);
|
|
|
|
|
@override
|
|
|
|
|
_CartOrderPageState createState() => _CartOrderPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
Provider.of<OrderPreviewViewModel>(context, listen: false).getShoppingCart();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final mediaQuery = MediaQuery.of(context);
|
|
|
|
|
OrderPreviewViewModel model = Provider.of(context);
|
|
|
|
|
|
|
|
|
|
final height = mediaQuery.size.height - 60 - mediaQuery.padding.top;
|
|
|
|
|
AppScaffold appScaffold;
|
|
|
|
|
return BaseView<OrderPreviewViewModel>(
|
|
|
|
|
onModelReady: (model) {
|
|
|
|
|
model.getShoppingCart().then((value) {
|
|
|
|
|
appScaffold.appBar
|
|
|
|
|
.badgeUpdater('${model.cartResponse.quantityCount ?? 0}');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
builder: (_, model, wi) => ChangeNotifierProvider.value(
|
|
|
|
|
value: model.cartResponse,
|
|
|
|
|
child: appScaffold = AppScaffold(
|
|
|
|
|
return NetworkBaseView(
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
child: AppScaffold(
|
|
|
|
|
appBarTitle: TranslationBase.of(context).shoppingCart,
|
|
|
|
|
isShowAppBar: true,
|
|
|
|
|
isPharmacy: true,
|
|
|
|
|
showHomeAppBarIcon: false,
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
body: !(model.cartResponse.shoppingCarts == null ||
|
|
|
|
|
@ -43,8 +53,6 @@ class CartOrderPage extends StatelessWidget {
|
|
|
|
|
? Container(
|
|
|
|
|
height: height * 0.85,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: Consumer<ShoppingCartResponse>(
|
|
|
|
|
builder: (ctx, cart, _) => Container(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: EdgeInsets.all(10),
|
|
|
|
|
@ -70,16 +78,16 @@ class CartOrderPage extends StatelessWidget {
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
...List.generate(
|
|
|
|
|
cart.shoppingCarts != null
|
|
|
|
|
? cart.shoppingCarts.length
|
|
|
|
|
model.cartResponse.shoppingCarts != null
|
|
|
|
|
? model.cartResponse.shoppingCarts.length
|
|
|
|
|
: 0,
|
|
|
|
|
(index) => ProductOrderItem(
|
|
|
|
|
cart.shoppingCarts[index], () {
|
|
|
|
|
print(cart.shoppingCarts[index]
|
|
|
|
|
model.cartResponse.shoppingCarts[index], () {
|
|
|
|
|
print(model.cartResponse.shoppingCarts[index]
|
|
|
|
|
.quantity);
|
|
|
|
|
model
|
|
|
|
|
.changeProductQuantity(
|
|
|
|
|
cart.shoppingCarts[index])
|
|
|
|
|
model.cartResponse.shoppingCarts[index])
|
|
|
|
|
.then((value) {
|
|
|
|
|
if (model.state !=
|
|
|
|
|
ViewState.Error) {
|
|
|
|
|
@ -95,7 +103,7 @@ class CartOrderPage extends StatelessWidget {
|
|
|
|
|
}, () {
|
|
|
|
|
model
|
|
|
|
|
.deleteProduct(
|
|
|
|
|
cart.shoppingCarts[index])
|
|
|
|
|
model.cartResponse.shoppingCarts[index])
|
|
|
|
|
.then((value) {
|
|
|
|
|
if (model.state !=
|
|
|
|
|
ViewState.Error) {
|
|
|
|
|
@ -125,7 +133,7 @@ class CartOrderPage extends StatelessWidget {
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
Texts(
|
|
|
|
|
"${TranslationBase.of(context).sar} ${(cart.subtotal).toStringAsFixed(2)}",
|
|
|
|
|
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}",
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
@ -150,7 +158,7 @@ class CartOrderPage extends StatelessWidget {
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
Texts(
|
|
|
|
|
"${TranslationBase.of(context).sar} ${(cart.subtotalVatAmount).toStringAsFixed(2)}",
|
|
|
|
|
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}",
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
@ -175,7 +183,7 @@ class CartOrderPage extends StatelessWidget {
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
Texts(
|
|
|
|
|
"${TranslationBase.of(context).sar} ${(cart.subtotal).toStringAsFixed(2)}",
|
|
|
|
|
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}",
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
@ -194,10 +202,9 @@ class CartOrderPage extends StatelessWidget {
|
|
|
|
|
width: mediaQuery.size.width - 20,
|
|
|
|
|
height: 30.0,
|
|
|
|
|
fit: BoxFit.scaleDown,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 120,)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -235,7 +242,6 @@ class CartOrderPage extends StatelessWidget {
|
|
|
|
|
child: OrderBottomWidget(model.addresses, height),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -256,12 +262,9 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
ProjectViewModel projectProvider = Provider.of(context);
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
|
|
|
|
|
child: Consumer<ShoppingCartResponse>(
|
|
|
|
|
builder: (ctx, cart, _) => !(cart.shoppingCarts == null ||
|
|
|
|
|
cart.shoppingCarts.length == 0)
|
|
|
|
|
OrderPreviewViewModel cart = Provider.of(context);
|
|
|
|
|
return !(cart.cartResponse.shoppingCarts == null ||
|
|
|
|
|
cart.cartResponse.shoppingCarts.length == 0)
|
|
|
|
|
? Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
@ -350,7 +353,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Texts(
|
|
|
|
|
"${TranslationBase.of(context).sar} ${(cart.subtotal).toStringAsFixed(2)}",
|
|
|
|
|
"${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotal).toStringAsFixed(2)}",
|
|
|
|
|
fontSize:
|
|
|
|
|
projectProvider.isArabic ? 12 : 14,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
@ -369,7 +372,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Texts(
|
|
|
|
|
"${cart.quantityCount} ${TranslationBase.of(context).items}",
|
|
|
|
|
"${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}",
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
@ -403,7 +406,6 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
));
|
|
|
|
|
: Container();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|