Merge branch 'nov_fixes' into 'development_new_design_2.0'

Nov fixes

See merge request Cloud_Solution/diplomatic-quarter!502
merge-update-with-lab-changes
Elham Ali 4 years ago
commit 47c2c80b36

@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.dart';
import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -22,7 +23,6 @@ import 'package:provider/provider.dart';
import 'cart-order-preview.dart';
class CartOrderPage extends StatefulWidget {
final Function(int) changeTab;
const CartOrderPage({Key key, this.changeTab}) : super(key: key);
@ -38,7 +38,6 @@ class _CartOrderPageState extends State<CartOrderPage> {
void initState() {
super.initState();
getData();
}
@override
@ -47,212 +46,216 @@ class _CartOrderPageState extends State<CartOrderPage> {
OrderPreviewViewModel model = Provider.of(context);
final height = mediaQuery.size.height - 60 - mediaQuery.padding.top;
AppScaffold appScaffold;
return NetworkBaseView(
isLoading: isLoading,
isLocalLoader: true,
child: appScaffold = AppScaffold(
appBarTitle: TranslationBase.of(context).shoppingCart,
isShowAppBar: true,
isPharmacy: true,
showHomeAppBarIcon: false,
isShowDecPage: false,
isMainPharmacyPages: true,
showPharmacyCart: false,
baseViewModel: model,
backgroundColor: Colors.white,
body: !(model.cartResponse.shoppingCarts == null ||
model.cartResponse.shoppingCarts.length == 0)
return AppScaffold(
appBarTitle: TranslationBase.of(context).shoppingCart,
isShowAppBar: true,
isPharmacy: true,
showHomeAppBarIcon: false,
isShowDecPage: false,
isMainPharmacyPages: true,
showPharmacyCart: false,
baseViewModel: model,
backgroundColor: Colors.white,
body: NetworkBaseView(
isLoading: isLoading,
isLocalLoader: true,
child: !(model.cartResponse.shoppingCarts == null ||
model.cartResponse.shoppingCarts.length == 0)
? Container(
height: height * 0.85,
width: double.infinity,
child: SingleChildScrollView(
child: Container(
margin: EdgeInsets.all(10),
height: height * 0.85,
width: double.infinity,
child: SingleChildScrollView(
child: Container(
margin: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureIconButton(
TranslationBase.of(context).deleteAllItems,
Icon(
Icons.delete_outline_sharp,
color: Colors.grey.shade700,
),
onTap: () => {model.deleteShoppingCart()},
),
const Divider(
color: Color(0xFFD6D6D6),
height: 20,
thickness: 1,
indent: 0,
endIndent: 0,
),
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureIconButton(
TranslationBase.of(context).deleteAllItems,
Icon(
Icons.delete_outline_sharp,
color: Colors.grey.shade700,
),
onTap: () => {model.deleteShoppingCart()},
),
const Divider(
color: Color(0xFFD6D6D6),
height: 20,
thickness: 1,
indent: 0,
endIndent: 0,
),
Container(
child: Column(
children: [
...List.generate(
model.cartResponse.shoppingCarts != null
? model.cartResponse.shoppingCarts.length
: 0,
(index) => ProductOrderItem(
model.cartResponse
.shoppingCarts[index], () {
print(model.cartResponse
.shoppingCarts[index].quantity);
model
.changeProductQuantity(model
.cartResponse
.shoppingCarts[index])
.then((value) {
if (model.state != ViewState.Error) {
// appScaffold.appBar.badgeUpdater(
// '${value.quantityCount ?? 0}');
}
if (model.state ==
ViewState.ErrorLocal) {
Utils.showErrorToast(model.error);
}
});
}, () {
model
.deleteProduct(model.cartResponse
.shoppingCarts[index])
.then((value) {
if (model.state != ViewState.Error) {
// appScaffold.appBar.badgeUpdater(
// '${value.quantityCount ?? 0}');
}
});
}))
],
),
),
const Divider(
color: Color(0xFFD6D6D6),
height: 20,
thickness: 2,
indent: 0,
endIndent: 0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
TranslationBase.of(context).subtotal,
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
),
Texts(
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
),
],
),
const Divider(
color: Color(0xFFD6D6D6),
height: 20,
thickness: 1,
indent: 0,
endIndent: 0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
"${TranslationBase.of(context).vat}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
),
Texts(
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
),
],
),
const Divider(
color: Color(0xFFD6D6D6),
height: 20,
thickness: 1,
indent: 0,
endIndent: 0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
TranslationBase.of(context).total,
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.bold,
),
Texts(
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.bold,
),
],
),
const Divider(
color: Color(0xFFD6D6D6),
height: 20,
thickness: 1,
indent: 0,
endIndent: 0,
),
Image.asset(
"assets/images/pharmacy_module/payment.png",
width: mediaQuery.size.width - 20,
height: 30.0,
fit: BoxFit.scaleDown,
),
SizedBox(
height: 120,
)
...List.generate(
model.cartResponse.shoppingCarts != null
? model
.cartResponse.shoppingCarts.length
: 0,
(index) => ProductOrderItem(
model.cartResponse
.shoppingCarts[index], () {
print(model.cartResponse
.shoppingCarts[index].quantity);
model
.changeProductQuantity(model
.cartResponse
.shoppingCarts[index])
.then((value) {
if (model.state !=
ViewState.Error) {
// appScaffold.appBar.badgeUpdater(
// '${value.quantityCount ?? 0}');
}
if (model.state ==
ViewState.ErrorLocal) {
Utils.showErrorToast(
model.error);
}
});
}, () {
model
.deleteProduct(model
.cartResponse
.shoppingCarts[index])
.then((value) {
if (model.state !=
ViewState.Error) {
// appScaffold.appBar.badgeUpdater(
// '${value.quantityCount ?? 0}');
}
});
}))
],
),
),
),
)
: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Image.asset(
'assets/images/new-design/empty_box.png',
width: 100,
height: 100,
fit: BoxFit.cover,
const Divider(
color: Color(0xFFD6D6D6),
height: 20,
thickness: 2,
indent: 0,
endIndent: 0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
TranslationBase.of(context).subtotal,
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
TranslationBase.of(context).noData,
// 'There is no data',
style: TextStyle(fontSize: 30),
Texts(
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
),
)
],
],
),
const Divider(
color: Color(0xFFD6D6D6),
height: 20,
thickness: 1,
indent: 0,
endIndent: 0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
"${TranslationBase.of(context).vat}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
),
Texts(
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
),
],
),
const Divider(
color: Color(0xFFD6D6D6),
height: 20,
thickness: 1,
indent: 0,
endIndent: 0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
TranslationBase.of(context).total,
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.bold,
),
Texts(
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.bold,
),
],
),
const Divider(
color: Color(0xFFD6D6D6),
height: 20,
thickness: 1,
indent: 0,
endIndent: 0,
),
Image.asset(
"assets/images/pharmacy_module/payment.png",
width: mediaQuery.size.width - 20,
height: 30.0,
fit: BoxFit.scaleDown,
),
SizedBox(
height: 120,
)
],
),
),
),
)
: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Image.asset(
'assets/images/new-design/empty_box.png',
width: 100,
height: 100,
fit: BoxFit.cover,
),
),
bottomSheet: Container(
height: !(model.cartResponse.shoppingCarts == null ||
model.cartResponse.shoppingCarts.length == 0)
? height * 0.15
: 0,
color: Colors.white,
child: OrderBottomWidget(model.addresses, height),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
TranslationBase.of(context).noData,
// 'There is no data',
style: TextStyle(fontSize: 30),
),
)
],
),
),
),
bottomSheet: Container(
height: !(model.cartResponse.shoppingCarts == null ||
model.cartResponse.shoppingCarts.length == 0)
? height * 0.15
: 0,
color: Colors.white,
child: OrderBottomWidget(model.addresses, height, model),
),
);
}
@ -268,8 +271,9 @@ class _CartOrderPageState extends State<CartOrderPage> {
class OrderBottomWidget extends StatefulWidget {
final List<Addresses> addresses;
final double height;
final OrderPreviewViewModel model;
OrderBottomWidget(this.addresses, this.height);
OrderBottomWidget(this.addresses, this.height, this.model);
@override
_OrderBottomWidgetState createState() => _OrderBottomWidgetState();
@ -281,9 +285,9 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
@override
Widget build(BuildContext context) {
ProjectViewModel projectProvider = Provider.of(context);
OrderPreviewViewModel cart = Provider.of(context);
return !(cart.cartResponse.shoppingCarts == null ||
cart.cartResponse.shoppingCarts.length == 0)
return !(widget.model.cartResponse.shoppingCarts == null ||
widget.model.cartResponse.shoppingCarts.length == 0)
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -373,7 +377,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
child: Row(
children: [
Texts(
"${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotalWithVat).toStringAsFixed(2)}",
"${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotalWithVat).toStringAsFixed(2)}",
fontSize: projectProvider.isArabic ? 12 : 14,
fontWeight: FontWeight.bold,
),
@ -391,7 +395,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
),
),
Texts(
"${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}",
"${widget.model.cartResponse.quantityCount} ${TranslationBase.of(context).items}",
fontSize: 10,
color: Colors.grey,
fontWeight: FontWeight.bold,
@ -403,50 +407,35 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
onPressed: isAgree
// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0
? () => {
if(cart.isCartItemsOutOfStock()){
// Toast msg
AppToast.showErrorToast(message: TranslationBase.of(context).outOfStockMsg)
}else {
Navigator.push(
context,
FadePage(
page:
OrderPreviewPage(widget.addresses)))
}
}
if (widget.model.isCartItemsOutOfStock())
{
// Toast msg
AppToast.showErrorToast(
message: TranslationBase.of(context)
.outOfStockMsg)
}
else
{
_navigateToAddressPage(widget
.model.user.patientIdentificationNo)
// Navigator.push(
// context,
// FadePage(
// page:
// OrderPreviewPage(widget.addresses)))
}
}
: null,
child: new Text(
"${TranslationBase.of(context).checkOut}",
style: new TextStyle(
color:
isAgree ? Colors.white : Colors.grey.shade300,
isAgree ? Colors.white : Colors.grey.shade300,
fontSize: 14),
),
color: Color(0xFF4CAF50),
disabledColor:Color(0xFF848484),
// disabledColor: Color(0xff005aff),
disabledColor: Color(0xFF848484),
)
// RaisedButton(
// onPressed: isAgree
//// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0
// ? () => {
// Navigator.push(
// context,
// FadePage(
// page:
// OrderPreviewPage(widget.addresses)))
// }
// : null,
// child: new Text(
// "${TranslationBase.of(context).checkOut}",
// style: new TextStyle(
// color:
// isAgree ? Colors.white : Colors.grey.shade300,
// fontSize: 14),
// ),
// color: Color(0xff005aff),
// disabledColor: Color(0xff005aff),
// )
],
),
),
@ -454,4 +443,24 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
)
: Container();
}
_navigateToAddressPage(String identificationNo) {
Navigator.push(
context,
FadePage(
page: PharmacyAddressesPage(
orderPreviewViewModel: widget.model,
))).then((result) async {
if (result != null) {
GifLoaderDialogUtils.showMyDialog(context);
var address = result;
widget.model.paymentCheckoutData.address =
Addresses.fromJson(address.toJson());
await widget.model.getInformationsByAddress(identificationNo);
await widget.model.getShoppingCart();
// widget.changeMainState();
GifLoaderDialogUtils.hideDialog(context);
}
});
}
}

@ -15,8 +15,9 @@ import 'lakum_widget.dart';
class OrderPreviewPage extends StatefulWidget {
final List<Addresses> addresses;
final OrderPreviewViewModel model;
OrderPreviewPage(this.addresses);
OrderPreviewPage({this.addresses, this.model});
@override
_OrderPreviewPageState createState() => _OrderPreviewPageState();
@ -43,7 +44,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
final height = mediaQuery.size.height - 60 - mediaQuery.padding.top;
OrderPreviewViewModel model = Provider.of(context);
// OrderPreviewViewModel widget.model = Provider.of(context);
return AppScaffold(
appBarTitle: "${TranslationBase.of(context).checkOut}",
isShowAppBar: true,
@ -52,7 +53,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
isLoading: isLoading,
isLocalLoader: true,
backgroundColor: Colors.white,
// baseViewModel: model,
// baseViewModel: widget.model,
body: Container(
color: Color(0xFFF1F1F1),
height: height * 0.90,
@ -61,19 +62,19 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
color: Color(0xFFF1F1F1),
child: Column(
children: [
SelectAddressWidget(model, widget.addresses, changeMainState),
SelectAddressWidget(widget.model, widget.addresses, changeMainState, isUpdating: true,),
SizedBox(
height: 10,
),
SelectPaymentOptionWidget(model, changeMainState),
SelectPaymentOptionWidget(widget.model, changeMainState,isUpdating: true,),
SizedBox(
height: 10,
),
model.paymentCheckoutData.lacumInformation != null
widget.model.paymentCheckoutData.lacumInformation != null
? Container(
child: Column(
children: [
LakumWidget(model),
LakumWidget(widget.model),
SizedBox(
height: 10,
),
@ -95,8 +96,8 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
color: Colors.black,
),
...List.generate(
model.cartResponse.shoppingCarts != null ? model.cartResponse.shoppingCarts.length : 0,
(index) => ProductOrderPreviewItem(model.cartResponse.shoppingCarts[index]),
widget.model.cartResponse.shoppingCarts != null ? widget.model.cartResponse.shoppingCarts.length : 0,
(index) => ProductOrderPreviewItem(widget.model.cartResponse.shoppingCarts[index]),
),
],
),
@ -104,7 +105,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
Container(
width: double.infinity,
padding: EdgeInsets.all(8),
child: model.cartResponse.subtotal != null
child: widget.model.cartResponse.subtotal != null
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -127,7 +128,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
fontWeight: FontWeight.w500,
),
Texts(
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}",
"${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotal).toStringAsFixed(2)}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
@ -151,7 +152,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
fontWeight: FontWeight.w500,
),
Texts(
"${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).toStringAsFixed(2)}",
"${TranslationBase.of(context).sar} ${(widget.model.totalAdditionalShippingCharge).toStringAsFixed(2)}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
@ -175,7 +176,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
fontWeight: FontWeight.w500,
),
Texts(
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}",
"${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
@ -199,7 +200,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
fontWeight: FontWeight.bold,
),
Texts(
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}",
"${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotal).toStringAsFixed(2)}",
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.bold,
@ -214,7 +215,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
: Container(),
),
SizedBox(
height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0,
height: widget.model.cartResponse.shoppingCarts != null ? height * 0.10 : 0,
)
],
),
@ -222,9 +223,9 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
),
),
bottomSheet: Container(
height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0,
height: widget.model.cartResponse.shoppingCarts != null ? height * 0.10 : 0,
color: Colors.white,
child: PaymentBottomWidget(model),
child: PaymentBottomWidget(widget.model),
),
);
}

@ -13,8 +13,10 @@ class SelectAddressWidget extends StatefulWidget {
final OrderPreviewViewModel model;
final List<Addresses> addresses;
final Function changeMainState;
final bool isUpdating;
SelectAddressWidget(this.model, this.addresses, this.changeMainState);
SelectAddressWidget(this.model, this.addresses, this.changeMainState,
{this.isUpdating = false});
@override
_SelectAddressWidgetState createState() => _SelectAddressWidgetState();
@ -24,7 +26,7 @@ class _SelectAddressWidgetState extends State<SelectAddressWidget> {
AddressInfo address;
_navigateToAddressPage(String identificationNo) {
Navigator.push(context, FadePage(page: PharmacyAddressesPage())).then((result) async {
Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,isUpdate: widget.isUpdating,changeMainState: widget.changeMainState,))).then((result) async {
if (result != null) {
GifLoaderDialogUtils.showMyDialog(context);
address = result;
@ -39,15 +41,15 @@ class _SelectAddressWidgetState extends State<SelectAddressWidget> {
@override
void initState() {
if (widget.model.paymentCheckoutData.address != null) {
address = AddressInfo.fromJson(widget.model.paymentCheckoutData.address.toJson());
}
super.initState();
}
@override
Widget build(BuildContext context) {
OrderPreviewViewModel model = Provider.of(context);
if (widget.model.paymentCheckoutData.address != null) {
address = AddressInfo.fromJson(widget.model.paymentCheckoutData.address.toJson());
}
return Container(
color: Colors.white,
child: address == null

@ -9,8 +9,10 @@ import 'package:flutter/material.dart';
class SelectPaymentOptionWidget extends StatefulWidget {
final OrderPreviewViewModel model;
final Function changeMainState;
final bool isUpdating;
SelectPaymentOptionWidget(this.model, this.changeMainState);
SelectPaymentOptionWidget(this.model, this.changeMainState, {this.isUpdating = false});
@override
_SelectPaymentOptionWidgetState createState() => _SelectPaymentOptionWidgetState();
@ -20,7 +22,7 @@ class _SelectPaymentOptionWidgetState extends State<SelectPaymentOptionWidget> {
PaymentOption paymentOption;
_navigateToPaymentOption() {
Navigator.push(context, FadePage(page: PaymentMethodSelectPage()))
Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.model,changeMainState:widget.changeMainState,isUpdating: widget.isUpdating,)))
.then((result) => {
setState(() {
if (result != null) {
@ -35,14 +37,14 @@ class _SelectPaymentOptionWidgetState extends State<SelectPaymentOptionWidget> {
@override
void initState() {
if (widget.model.paymentCheckoutData.paymentOption != null) {
paymentOption = widget.model.paymentCheckoutData.paymentOption;
}
super.initState();
}
@override
Widget build(BuildContext context) {
if (widget.model.paymentCheckoutData.paymentOption != null) {
paymentOption = widget.model.paymentCheckoutData.paymentOption;
}
return Container(
color: Colors.white,
child: paymentOption == null

@ -1,48 +0,0 @@
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/GestureIconButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
class OrderPreviewPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BaseView<OrderPreviewViewModel>(
builder: (_, model, wi) => AppScaffold(
title: TranslationBase.of(context).shoppingCart,
isShowAppBar: true,
isShowDecPage: false,
baseViewModel: model,
backgroundColor: Colors.white,
body: Container(
width: double.infinity,
child: SingleChildScrollView(
child: Container(
margin: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureIconButton(
TranslationBase.of(context).deleteAllItems,
Icon(Icons.delete_outline_sharp, color: Colors.grey.shade800,),
onTap: () => {},
),
const Divider(
color: Colors.grey,
height: 20,
thickness: 1,
indent: 0,
endIndent: 0,
),
],
),
),
),
),
),
);
}
}

@ -6,11 +6,23 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'cart-page/cart-order-preview.dart';
class PaymentMethodSelectPage extends StatefulWidget {
final OrderPreviewViewModel model;
final bool isUpdating;
final Function changeMainState;
const PaymentMethodSelectPage(
{Key key, this.model, this.isUpdating = false, this.changeMainState})
: super(key: key);
@override
_PaymentMethodSelectPageState createState() => _PaymentMethodSelectPageState();
_PaymentMethodSelectPageState createState() =>
_PaymentMethodSelectPageState();
}
class _PaymentMethodSelectPageState extends State<PaymentMethodSelectPage> {
@ -79,7 +91,8 @@ class _PaymentMethodSelectPageState extends State<PaymentMethodSelectPage> {
PaymentOption.installments,
() => {
setState(() {
selectedPaymentOption = PaymentOption.installments;
selectedPaymentOption =
PaymentOption.installments;
})
}),
if (Platform.isIOS)
@ -103,7 +116,27 @@ class _PaymentMethodSelectPageState extends State<PaymentMethodSelectPage> {
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 20),
child: DefaultButton(
TranslationBase.of(context).next,
selectedPaymentOption != null ? () => {Navigator.pop(context, selectedPaymentOption)} : null,
selectedPaymentOption != null
? () {
widget.model.paymentCheckoutData.paymentOption =
selectedPaymentOption;
if (widget.isUpdating) {
widget.changeMainState();
Navigator.pop(context);
return;
} else {
Navigator.push(
context,
FadePage(
page: OrderPreviewPage(
model: widget.model,
),
),
);
}
// Navigator.pop(context, selectedPaymentOption);
}
: null,
color: Color(0xff5AB154),
),
),
@ -117,12 +150,14 @@ class PaymentMethodCard extends StatelessWidget {
final PaymentOption paymentOption;
final Function selectMethod;
PaymentMethodCard(this.cardWidth, this.selectedPaymentOption, this.paymentOption, this.selectMethod);
PaymentMethodCard(this.cardWidth, this.selectedPaymentOption,
this.paymentOption, this.selectMethod);
@override
Widget build(BuildContext context) {
bool isSelected = false;
if (selectedPaymentOption != null && selectedPaymentOption == paymentOption) {
if (selectedPaymentOption != null &&
selectedPaymentOption == paymentOption) {
isSelected = true;
}
@ -136,7 +171,9 @@ class PaymentMethodCard extends StatelessWidget {
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: isSelected ? BorderSide(color: Colors.green, width: 2.0) : BorderSide(color: Colors.transparent, width: 0.0),
side: isSelected
? BorderSide(color: Colors.green, width: 2.0)
: BorderSide(color: Colors.transparent, width: 0.0),
),
child: Padding(
padding: const EdgeInsets.all(12.0),
@ -145,7 +182,13 @@ class PaymentMethodCard extends StatelessWidget {
Container(
width: 24,
height: 24,
decoration: containerColorRadiusBorderWidth(isSelected ? CustomColors.accentColor : Colors.transparent, 100, Colors.grey, 0.5),
decoration: containerColorRadiusBorderWidth(
isSelected
? CustomColors.accentColor
: Colors.transparent,
100,
Colors.grey,
0.5),
),
mWidth(12),
Container(
@ -157,7 +200,8 @@ class PaymentMethodCard extends StatelessWidget {
if (isSelected)
Container(
decoration: containerRadius(CustomColors.green, 200),
padding: EdgeInsets.only(top: 6, bottom: 6, left: 12, right: 12),
padding:
EdgeInsets.only(top: 6, bottom: 6, left: 12, right: 12),
child: Text(
TranslationBase.of(context).paymentSelected,
style: TextStyle(
@ -170,40 +214,6 @@ class PaymentMethodCard extends StatelessWidget {
),
),
),
// Container(
// margin: EdgeInsets.symmetric(horizontal: 2, vertical: 0),
// child: Stack(
// children: [
// Container(
// padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8),
// margin: EdgeInsets.symmetric(horizontal: 14, vertical: 8),
// decoration: new BoxDecoration(
// color: Colors.grey.shade100,
// shape: BoxShape.rectangle,
// borderRadius: BorderRadius.circular(8),
// border: Border.fromBorderSide(BorderSide(
// color: isSelected ? Color(0xff20BC11) : Colors.grey.shade300,
// width: 0.8,
// )),
// ),
// width: cardWidth,
// child: Image.asset(
// getPaymentOptionImage(paymentOption),
// fit: BoxFit.cover,
// ),
// ),
// if (isSelected)
// Positioned(
// right: 1,
// child: Icon(
// Icons.check_circle,
// color: Color(0xff20BC11),
// size: 30,
// ),
// ),
// ],
// ),
// ),
),
);
}

@ -209,13 +209,7 @@ class _FooterWidgetState extends State<FooterWidget> {
);
} else {
await widget.addToShoppingCartFunction(quantity: widget.quantity, itemID: widget.item.id, model: widget.model);
// Navigator.of(context).pushNamed(
// CART_ORDER_PAGE,
// );
Navigator.push(
context,
FadePage(page: CartOrderPage()),
);
}
},
fontWeight: FontWeight.w600,

@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-name-and-price.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/recommended_products.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/reviews_info.dart';
@ -14,6 +15,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@ -113,8 +115,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
isInWishList: isInWishList,
addToCartFunction: addToCartFunction,
),
body: model.state == ViewState.Idle
? SingleChildScrollView(
body: SingleChildScrollView(
child: Column(
children: [
Container(
@ -311,9 +312,9 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
)
],
),
)
: AppCircularProgressIndicator(),
bottomSheet: model.state == ViewState.Idle
),
// : AppCircularProgressIndicator(),
bottomSheet: model.state == ViewState.Idle || model.state == ViewState.ErrorLocal
? FooterWidget(
model.isStockAvailable,
widget.product.orderMaximumQuantity,
@ -334,6 +335,11 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
GifLoaderDialogUtils.showMyDialog(context);
await model.addToCartData(quantity, itemID, context);
GifLoaderDialogUtils.hideDialog(context);
if(model.state != ViewState.ErrorLocal)
Navigator.push(
context,
FadePage(page: CartOrderPage()),
);
}
addToWishlistFunction({itemID, ProductDetailViewModel model}) async {

@ -1,7 +1,9 @@
import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart';
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/AddAddress.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -13,13 +15,24 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
///TODO Elham* split this to tow files
class PharmacyAddressesPage extends StatefulWidget {
final OrderPreviewViewModel orderPreviewViewModel;
final Function changeMainState;
final bool isUpdate;
const PharmacyAddressesPage(
{Key key, this.orderPreviewViewModel, this.isUpdate = false, this.changeMainState})
: super(key: key);
@override
_PharmacyAddressesState createState() => _PharmacyAddressesState();
}
class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
void navigateToAddressPage(BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) {
void navigateToAddressPage(
BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) {
Navigator.push(
ctx,
FadePage(
@ -35,7 +48,7 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
return BaseView<PharmacyAddressesViewModel>(
onModelReady: (model) => model.getAddressesList(),
builder: (_, model, wi) => AppScaffold(
appBarTitle: TranslationBase.of(context).changeAddress,
appBarTitle: widget.isUpdate?TranslationBase.of(context).changeAddress:"Add Address",
isShowAppBar: true,
isPharmacy: true,
baseViewModel: model,
@ -78,8 +91,9 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
},
),
),
SizedBox(height: height * 0.10,)
SizedBox(
height: height * 0.10,
)
],
),
),
@ -108,8 +122,14 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
fontSize: 14,
vPadding: 8,
handler: () {
model.saveSelectedAddressLocally(model.addresses[model.selectedAddressIndex]);
Navigator.pop(context, model.addresses[model.selectedAddressIndex]);
//TODO Elham*
widget.orderPreviewViewModel.paymentCheckoutData
.address =
Addresses.fromJson(
model.addresses[model.selectedAddressIndex].toJson());
model.saveSelectedAddressLocally(
model.addresses[model.selectedAddressIndex]);
_navigateToPaymentOption(model);
},
),
),
@ -119,6 +139,33 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
),
);
}
_navigateToPaymentOption(model) {
if(widget.isUpdate) {
print("sfsf");
widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson());
widget.changeMainState();
Navigator.pop(context);
return;
}
Navigator.push(
context,
FadePage(
page: PaymentMethodSelectPage(
model: widget.orderPreviewViewModel,
))).then((result) => {
setState(() {
if (result != null) {
var paymentOption = result;
widget.orderPreviewViewModel.paymentCheckoutData.paymentOption =
paymentOption;
}
// widget.changeMainState();
})
});
}
}
class AddressItemWidget extends StatelessWidget {
@ -128,7 +175,8 @@ class AddressItemWidget extends StatelessWidget {
final bool isSelected;
final Function(AddressInfo) onTabEditAddress;
AddressItemWidget(this.model, this.address, this.selectAddress, this.isSelected, this.onTabEditAddress);
AddressItemWidget(this.model, this.address, this.selectAddress,
this.isSelected, this.onTabEditAddress);
@override
Widget build(BuildContext context) {
@ -154,13 +202,18 @@ class AddressItemWidget extends StatelessWidget {
decoration: new BoxDecoration(
color: !isSelected ? Colors.white : Colors.green,
shape: BoxShape.circle,
border: Border.all(color: Colors.grey, style: BorderStyle.solid, width: 1.0),
border: Border.all(
color: Colors.grey,
style: BorderStyle.solid,
width: 1.0),
),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Icon(
Icons.check,
color: isSelected ? Colors.white : Colors.transparent,
color: isSelected
? Colors.white
: Colors.transparent,
size: 25,
),
),
@ -173,7 +226,8 @@ class AddressItemWidget extends StatelessWidget {
Expanded(
child: Container(
child: Container(
margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
margin:
EdgeInsets.symmetric(vertical: 12, horizontal: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -236,7 +290,8 @@ class AddressItemWidget extends StatelessWidget {
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding:
const EdgeInsets.symmetric(horizontal: 8),
child: SizedBox(
child: Container(
width: 1,
@ -254,13 +309,21 @@ class AddressItemWidget extends StatelessWidget {
ConfirmDialog dialog = new ConfirmDialog(
context: context,
title: "Are you sure want to delete",
confirmMessage: "${address.address1} ${address.address2}",
okText: TranslationBase.of(context).delete,
cancelText: TranslationBase.of(context).cancel_nocaps,
confirmMessage:
"${address.address1} ${address.address2}",
okText:
TranslationBase.of(context).delete,
cancelText: TranslationBase.of(context)
.cancel_nocaps,
okFunction: () => {
model.deleteAddresses(address).then((_) {
ConfirmDialog.closeAlertDialog(context);
AppToast.showErrorToast(message: "Address has been deleted");
model
.deleteAddresses(address)
.then((_) {
ConfirmDialog.closeAlertDialog(
context);
AppToast.showErrorToast(
message:
"Address has been deleted");
})
},
cancelFunction: () => {});

Loading…
Cancel
Save