fix black screen which is appear in cart page

merge-requests/502/head
Elham Rababh 4 years ago
parent dc7a5d3dca
commit 8a168386da

@ -46,212 +46,216 @@ class _CartOrderPageState extends State<CartOrderPage> {
OrderPreviewViewModel model = Provider.of(context); OrderPreviewViewModel model = Provider.of(context);
final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; final height = mediaQuery.size.height - 60 - mediaQuery.padding.top;
AppScaffold appScaffold; return AppScaffold(
return NetworkBaseView( appBarTitle: TranslationBase.of(context).shoppingCart,
isLoading: isLoading, isShowAppBar: true,
isLocalLoader: true, isPharmacy: true,
child: appScaffold = AppScaffold( showHomeAppBarIcon: false,
appBarTitle: TranslationBase.of(context).shoppingCart, isShowDecPage: false,
isShowAppBar: true, isMainPharmacyPages: true,
isPharmacy: true, showPharmacyCart: false,
showHomeAppBarIcon: false, baseViewModel: model,
isShowDecPage: false, backgroundColor: Colors.white,
isMainPharmacyPages: true, body: NetworkBaseView(
showPharmacyCart: false, isLoading: isLoading,
baseViewModel: model, isLocalLoader: true,
backgroundColor: Colors.white, child: !(model.cartResponse.shoppingCarts == null ||
body: !(model.cartResponse.shoppingCarts == null || model.cartResponse.shoppingCarts.length == 0)
model.cartResponse.shoppingCarts.length == 0)
? Container( ? Container(
height: height * 0.85, height: height * 0.85,
width: double.infinity, width: double.infinity,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Container( child: Container(
margin: EdgeInsets.all(10), 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( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
GestureIconButton( ...List.generate(
TranslationBase.of(context).deleteAllItems, model.cartResponse.shoppingCarts != null
Icon( ? model
Icons.delete_outline_sharp, .cartResponse.shoppingCarts.length
color: Colors.grey.shade700, : 0,
), (index) => ProductOrderItem(
onTap: () => {model.deleteShoppingCart()}, model.cartResponse
), .shoppingCarts[index], () {
const Divider( print(model.cartResponse
color: Color(0xFFD6D6D6), .shoppingCarts[index].quantity);
height: 20, model
thickness: 1, .changeProductQuantity(model
indent: 0, .cartResponse
endIndent: 0, .shoppingCarts[index])
), .then((value) {
Container( if (model.state !=
child: Column( ViewState.Error) {
children: [ // appScaffold.appBar.badgeUpdater(
...List.generate( // '${value.quantityCount ?? 0}');
model.cartResponse.shoppingCarts != null }
? model.cartResponse.shoppingCarts.length if (model.state ==
: 0, ViewState.ErrorLocal) {
(index) => ProductOrderItem( Utils.showErrorToast(
model.cartResponse model.error);
.shoppingCarts[index], () { }
print(model.cartResponse });
.shoppingCarts[index].quantity); }, () {
model model
.changeProductQuantity(model .deleteProduct(model
.cartResponse .cartResponse
.shoppingCarts[index]) .shoppingCarts[index])
.then((value) { .then((value) {
if (model.state != ViewState.Error) { if (model.state !=
// appScaffold.appBar.badgeUpdater( ViewState.Error) {
// '${value.quantityCount ?? 0}'); // 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,
)
], ],
), ),
), ),
), const Divider(
) color: Color(0xFFD6D6D6),
: Center( height: 20,
child: Column( thickness: 2,
mainAxisAlignment: MainAxisAlignment.center, indent: 0,
children: [ endIndent: 0,
Padding( ),
padding: const EdgeInsets.all(8.0), Row(
child: Image.asset( mainAxisAlignment: MainAxisAlignment.spaceBetween,
'assets/images/new-design/empty_box.png', children: [
width: 100, Texts(
height: 100, TranslationBase.of(context).subtotal,
fit: BoxFit.cover, fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
), ),
), Texts(
Padding( "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}",
padding: const EdgeInsets.all(8.0), fontSize: 14,
child: Text( color: Colors.black,
TranslationBase.of(context).noData, fontWeight: FontWeight.w500,
// 'There is no data',
style: TextStyle(fontSize: 30),
), ),
) ],
], ),
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( Padding(
height: !(model.cartResponse.shoppingCarts == null || padding: const EdgeInsets.all(8.0),
model.cartResponse.shoppingCarts.length == 0) child: Text(
? height * 0.15 TranslationBase.of(context).noData,
: 0, // 'There is no data',
color: Colors.white, style: TextStyle(fontSize: 30),
child: OrderBottomWidget(model.addresses, height, model), ),
)
],
),
), ),
), ),
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),
),
); );
} }
@ -283,7 +287,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
ProjectViewModel projectProvider = Provider.of(context); ProjectViewModel projectProvider = Provider.of(context);
return !(widget.model.cartResponse.shoppingCarts == null || return !(widget.model.cartResponse.shoppingCarts == null ||
widget.model.cartResponse.shoppingCarts.length == 0) widget.model.cartResponse.shoppingCarts.length == 0)
? Column( ? Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -403,8 +407,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
onPressed: isAgree onPressed: isAgree
// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 // && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0
? () => { ? () => {
if (widget.model if (widget.model.isCartItemsOutOfStock())
.isCartItemsOutOfStock())
{ {
// Toast msg // Toast msg
AppToast.showErrorToast( AppToast.showErrorToast(
@ -413,8 +416,8 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
} }
else else
{ {
_navigateToAddressPage(widget.model _navigateToAddressPage(widget
.user.patientIdentificationNo) .model.user.patientIdentificationNo)
// Navigator.push( // Navigator.push(
// context, // context,
// FadePage( // FadePage(
@ -442,12 +445,17 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
} }
_navigateToAddressPage(String identificationNo) { _navigateToAddressPage(String identificationNo) {
Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,))) Navigator.push(
.then((result) async { context,
FadePage(
page: PharmacyAddressesPage(
orderPreviewViewModel: widget.model,
))).then((result) async {
if (result != null) { if (result != null) {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
var address = result; var address = result;
widget.model.paymentCheckoutData.address = Addresses.fromJson(address.toJson()); widget.model.paymentCheckoutData.address =
Addresses.fromJson(address.toJson());
await widget.model.getInformationsByAddress(identificationNo); await widget.model.getInformationsByAddress(identificationNo);
await widget.model.getShoppingCart(); await widget.model.getShoppingCart();
// widget.changeMainState(); // widget.changeMainState();

Loading…
Cancel
Save