From 9b8103bfd6ebfcaac57fc0e981255eb71e57a406 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Mon, 7 Dec 2020 10:21:34 +0300 Subject: [PATCH 1/2] fixe order and order details --- assets/images/pharmacy/compare.png | Bin 0 -> 704 bytes lib/config/config.dart | 3 +- lib/config/localized_values.dart | 5 + .../PharmacyAddressesViewModel.dart | 16 +- .../order_model_view_model.dart | 23 +- lib/pages/landing/home_page.dart | 2 +- lib/pages/pharmacy/order/Order.dart | 753 +++++++++++------- lib/pages/pharmacy/order/OrderDetails.dart | 334 +++++--- lib/pages/pharmacy/order/ProductReview.dart | 93 ++- .../pharmacyAddresses/PharmacyAddresses.dart | 34 +- lib/pages/pharmacy/profile/profile.dart | 685 ++++++++-------- .../cancelOrder_service.dart | 39 + .../pharmacy_services/order_service.dart | 22 +- .../pharmacyAddress_service.dart | 10 +- lib/uitl/translations_delegate_base.dart | 5 + lib/widgets/pharmacy/product_tile.dart | 117 +-- 16 files changed, 1318 insertions(+), 823 deletions(-) create mode 100644 assets/images/pharmacy/compare.png create mode 100644 lib/services/pharmacy_services/cancelOrder_service.dart diff --git a/assets/images/pharmacy/compare.png b/assets/images/pharmacy/compare.png new file mode 100644 index 0000000000000000000000000000000000000000..11a49dfbf18881a724bae6e3ba9698ac4bd98eba GIT binary patch literal 704 zcmeAS@N?(olHy`uVBq!ia0vp^N!KqY3LE{-7{yi2FNExm2P z80zAbU2&bP`mqLqi*5E)hY|PEhLnm&f-@L zcK*|rAJBed&eA0r?5~VHrBq~-=7);^*j~V{y<^EFU*5z8Z6R##w%aldw%R|kuxOlg zL_EV`)q*LF(-KlkGMwM2SNvdPl~H`v@Gz0}{DTFmyhW_>lQWv%KIB`M$UiCPXkBA_ zNcJ4}6_XYmzt@oGbN#}+R$YxU{`5?NlY9UD`)@eId_z04i9+TB)rb>IWu~)!{~`C~ zoW+fUR%_NeK01Bsp7h*~jum(MKQ0U{wVJqMOL~v)qs}?Z2UkRX<#@!Yk#nH&UDg_% zPPQ%o8o6vt!~-`Nxr_2Yv&~$e`2KQ)UB|2!7oP;x ztoc>7z(_cFT^cK$OSR%gArva4o-DepSASuYGt#fwUmV*9^)?0L8PG`ptf6@%#^ z8*kp8u$L)nep<$}i0ap$97`sCKXv(lPp%OA&UsND`~LlyH`&Vel4WgN^b2mwhQ8vy iGLe<{8d`VW`oo;=**tObr%78uDaq5-&t;ucLK6Ti>MnNx literal 0 HcmV?d00001 diff --git a/lib/config/config.dart b/lib/config/config.dart index e7341682..5b03e49f 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -349,7 +349,8 @@ const GET_CUSTOMERS_ADDRESSES = "epharmacy/api/Customers/"; const GET_WISHLIST = "epharmacy/api/shopping_cart_items/"; const GET_ORDER = "orders?"; const GET_ORDER_DETAILS ="epharmacy/api/orders/"; -const GET_ADDRESS ="epharmacy/api/Customers/272843?fields=addresses"; +const GET_ADDRESS ="Customers/"; +const GET_Cancel_ORDER ="cancelorder/"; // Home Health Care const HHC_GET_ALL_SERVICES = "Services/Patients.svc/REST/PatientER_HHC_GetAllServices"; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index c2a81962..a7358d90 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -642,6 +642,11 @@ const Map> localizedValues = { "cancelled": {"en": "Cancelled", "ar": " ملغي"}, "writeReview": {"en": "Write Review", "ar": " اكتب تقييمك"}, "shareReview": {"en": "SHARE REVIEW", "ar": " اكتب تقييمك"}, + "review": {"en": " reviews", "ar": " تقييمات"}, + "deliveredOrder": {"en": " DELIVERED", "ar": " تم التوصيل"}, + "compare": {"en": " Compare", "ar": "مقارنه"}, + "medicationsRefill": {"en": " Medication Refill", "ar": "اعادة تعبئة الدواء"}, + "myPrescription": {"en": " My Prescriptions", "ar": "وصفاتي"}, "backMyAccount": { "en": "BACK TO MY ACCOUNT ", "ar": " الرجوع لحسابي الشخصي" diff --git a/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart b/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart index 75a178fa..a2e3b924 100644 --- a/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart @@ -6,19 +6,19 @@ import '../../../locator.dart'; import '../base_view_model.dart'; class PharmacyAddressesViewModel extends BaseViewModel { - PharmacyAddressService _PharmacyAddressService = locator(); + PharmacyAddressService _pharmacyAddressService = locator(); + List get address => _pharmacyAddressService.address; - List get address => _PharmacyAddressService.address; - - Future getAddress() async { + Future getAddress(address) async { setState(ViewState.Busy); - await _PharmacyAddressService.getAddress(); - if (_PharmacyAddressService.hasError) { - error = _PharmacyAddressService.error; + await _pharmacyAddressService.getAddress(address); + if (_pharmacyAddressService.hasError) { + error = _pharmacyAddressService.error; setState(ViewState.Error); } else { - + print(address.length); } } + } \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart index beb62a53..04cbe8e3 100644 --- a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart @@ -1,3 +1,5 @@ +//import 'dart:html'; + import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/orderDetails_service.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/order_service.dart'; @@ -6,6 +8,7 @@ import '../../../locator.dart'; import '../base_view_model.dart'; class OrderModelViewModel extends BaseViewModel { + OrderService _orderService = locator(); List get order => _orderService.orderList; @@ -22,7 +25,9 @@ class OrderModelViewModel extends BaseViewModel { error = _orderService.error; setState(ViewState.Error); } else { - + //order = _orderService.orderList; + print(order.length); + setState(ViewState.Idle); } } @@ -36,4 +41,20 @@ class OrderModelViewModel extends BaseViewModel { } } + + Future getProductReview(orderId) async { + setState(ViewState.Busy); + await _orderService.getProductReview(orderId); + if (_orderService.hasError) { + error = _orderService.error; + setState(ViewState.Error); + } else { + //order = _orderService.orderList; + print(order.length); + setState(ViewState.Idle); + } + } + + + } \ No newline at end of file diff --git a/lib/pages/landing/home_page.dart b/lib/pages/landing/home_page.dart index 57fc074a..3cde289c 100644 --- a/lib/pages/landing/home_page.dart +++ b/lib/pages/landing/home_page.dart @@ -489,7 +489,7 @@ class _HomePageState extends State { ), DashboardItem( onTap: () => Navigator.push( - context, FadePage(page: OrderPage())), + context, FadePage(page: PharmacyProfilePage())), child: Center( child: Padding( diff --git a/lib/pages/pharmacy/order/Order.dart b/lib/pages/pharmacy/order/Order.dart index 17849c47..f46eb08f 100644 --- a/lib/pages/pharmacy/order/Order.dart +++ b/lib/pages/pharmacy/order/Order.dart @@ -8,11 +8,13 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/order_service.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/order/OrderDetails.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart'; +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; class OrderPage extends StatefulWidget { // orderList({this.customerId, this.pageId}); - + var languageID ; @override _OrderPageState createState() => _OrderPageState(); } @@ -21,17 +23,19 @@ class _OrderPageState extends State with SingleTickerProviderStateMix String customerId=""; String page_id=""; - List delivered = [] ; - List processing = []; - List cancelled = []; - List pending = []; + List orderList = [] ; + List deliveredOrderList = [] ; + List processingOrderList = []; + List cancelledOrderList = []; + List pendingOrderList = []; + TabController _tabController; AppSharedPreferences sharedPref = AppSharedPreferences(); @override void initState() { // WidgetsBinding.instance.addPostFrameCallback((_) => getOrder()); - + getLanguageID(); super.initState(); _tabController = new TabController(length: 4, vsync: this,); } @@ -41,11 +45,8 @@ class _OrderPageState extends State with SingleTickerProviderStateMix return BaseView( onModelReady: (model) => model.getOrder(customerId, page_id), builder: (_,model, wi )=> AppScaffold( - appBarTitle:(TranslationBase.of(context).order), -// backgroundColor: Colors.green , -// centerTitle: true, -// title: Text(TranslationBase.of(context).order, style: TextStyle(color:Colors.white)), -// backgroundColor: Colors.green, + appBarTitle:TranslationBase.of(context).order, + baseViewModel: model, isShowAppBar: true, isPharmacy:true , body: Container( @@ -54,7 +55,6 @@ class _OrderPageState extends State with SingleTickerProviderStateMix TabBar( tabs: [ Tab(text: TranslationBase.of(context).delivered), -// Tab(text: model.order.length.toString()), Tab(text: TranslationBase.of(context).processing), Tab(text: TranslationBase.of(context).pending), Tab(text: TranslationBase.of(context).cancelled), @@ -87,10 +87,19 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ); } + + Widget getDeliveredOrder(OrderModelViewModel model){ + for(int i=0 ; i< model.order.length; i++){ + if( model.order[i].orderStatusId == 30 || model.order[i].orderStatusId == 997 + || model.order[i].orderStatusId == 994 + ){ + deliveredOrderList.add(model.order[i]); + } + } return Container( width: MediaQuery.of(context).size.width, - child: model.order.length != 0 && model.order[0].orderStatusId == 30 + child: model.order.length != 0 ? SingleChildScrollView( child: Column( children: [ @@ -98,7 +107,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), - itemCount: 2 , + itemCount: deliveredOrderList.length, itemBuilder: (context, index){ return Container( child: Column( @@ -121,7 +130,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ), ), Container( - child: Text(model.order[0].id.toString(), + child: Text(deliveredOrderList[index].id.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), @@ -140,7 +149,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ), ), Container( - child: Text(model.order[0].createdOnUtc.toString(), + child: Text(deliveredOrderList[index].createdOnUtc.toString().substring(0,11), style: TextStyle(fontSize: 14.0, ), ), @@ -155,7 +164,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix child: InkWell( onTap: () { Navigator.push(context, - MaterialPageRoute(builder: (context) => OrderDetailsPage())); + MaterialPageRoute(builder: (context) => OrderDetailsPage(orderModel:deliveredOrderList[index]))); }, child: SvgPicture.asset( 'assets/images/pharmacy/arrow_right.svg', @@ -175,27 +184,25 @@ class _OrderPageState extends State with SingleTickerProviderStateMix Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded( - child: Container( - margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), - padding: EdgeInsets.only(left: 13.0, right: 13.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.blue[700], - style: BorderStyle.solid, - width: 5.0, - ), + Container( + margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), + padding: EdgeInsets.only(left: 13.0, right: 13.0), + decoration: BoxDecoration( + border: Border.all( color: Colors.blue[700], - borderRadius: BorderRadius.circular(30.0) - ), - child: Text( - model.order[0].orderStatus.toString(), -// TranslationBase.of(context).delivered, - style: TextStyle( - color: Colors.white, - fontSize: 15.0, - fontWeight: FontWeight.bold, + style: BorderStyle.solid, + width: 5.0, ), + color: Colors.blue[700], + borderRadius: BorderRadius.circular(30.0) + ), + child: Text( +// deliveredOrderList[0].orderStatus.toString().substring(12), + TranslationBase.of(context).deliveredOrder, + style: TextStyle( + color: Colors.white, + fontSize: 15.0, + fontWeight: FontWeight.bold, ), ), ), @@ -208,7 +215,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix children: [ Container( margin: EdgeInsets.only(left: 5), - child: Text(model.order[0].orderTotal.toString(), + child: Text(deliveredOrderList[index].orderTotal.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), @@ -227,7 +234,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix Row( children: [ Container( - child: Text('12', + child: Text(deliveredOrderList[index].orderItems.length.toString(), style: TextStyle(fontSize: 14.0, ), ), @@ -267,7 +274,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Image.asset( + SvgPicture.asset( 'assets/images/pharmacy/empty_box.svg'), Container( margin: EdgeInsets.only(top: 10.0), @@ -284,189 +291,391 @@ class _OrderPageState extends State with SingleTickerProviderStateMix } Widget getProcessingOrder(OrderModelViewModel model){ + for(int i=0 ; i< model.order.length; i++){ + if( model.order[i].orderStatusId == 20 || model.order[i].orderStatusId == 995 || + model.order[i].orderStatusId == 998 || model.order[i].orderStatusId == 999){ + processingOrderList.add(model.order[i]); + } + } return Container( - child: model.order.length != 0 && model.order[0].orderStatusId == 20 - ? SingleChildScrollView( - child: Column( + width: MediaQuery.of(context).size.width, + child: model.order.length != 0 + ? SingleChildScrollView( + child: Column( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - margin: EdgeInsets.all(8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - margin: EdgeInsets.only(right: 5), - child: Text(TranslationBase.of(context).orderNumber, - style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, - ), - ), - ), - Container( - child: Text(model.order[0].id.toString(), - style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - SizedBox( - height: 5,), - Row( - children: [ - Container( - margin: EdgeInsets.only(right: 5), - child: Text(TranslationBase.of(context).orderDate, - style: TextStyle(fontSize: 14.0, + ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount: processingOrderList.length, + itemBuilder: (context, index){ + return Container( + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + margin: EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + margin: EdgeInsets.only(right: 5), + child: Text(TranslationBase.of(context).orderNumber, + style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, + ), + ), + ), + Container( + child: Text(processingOrderList[index].id.toString(), + style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + SizedBox( + height: 5,), + Row( + children: [ + Container( + margin: EdgeInsets.only(right: 5), + child: Text(TranslationBase.of(context).orderDate, + style: TextStyle(fontSize: 14.0, + ), + ), + ), + Container( + child: Text(processingOrderList[index].createdOnUtc.toString().substring(0,11), + style: TextStyle(fontSize: 14.0, + ), + ), + ), + ], + ), + ], ), ), - ), - Container( - child: Text(model.order[0].createdOnUtc.toString(), - style: TextStyle(fontSize: 14.0, + Container( + margin: EdgeInsets.all(8.0), + child: InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => OrderDetailsPage(orderModel:processingOrderList[index]))); + }, + child: SvgPicture.asset( + 'assets/images/pharmacy/arrow_right.svg', + height: 20, + width: 20,), ), ), - ), - ], - ), - ], - ), - ), - Container( - margin: EdgeInsets.all(8), - child: InkWell( - onTap: () { - Navigator.push(context, - MaterialPageRoute(builder: (context) => OrderDetailsPage())); - }, - child: SvgPicture.asset( - 'assets/images/pharmacy/arrow_right.svg', - height: 20, - width: 20,), - ), - ), - ], - ), - Divider( - color: Colors.grey[350], - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Container( - margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), - padding: EdgeInsets.only(left: 13.0, right: 13.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.green, - style: BorderStyle.solid, - width: 5.0, + ], ), - color: Colors.green, - borderRadius: BorderRadius.circular(30.0) - ), - child: Text( - model.order[0].orderStatus.toString(), -// TranslationBase.of(context).processing, - style: TextStyle( - color: Colors.white, - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), - ), - ), - ), - Container( - margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), - child: Column( -// crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Row( - children: [ - Container( - margin: EdgeInsets.only(left: 5), - child: Text(model.order[0].orderTotal.toString(), - style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, - ), - ), - ), - Container( - margin: EdgeInsets.only(left: 5), - child: Text(TranslationBase.of(context).sar, - style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, + Divider( + color: Colors.grey[350], + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), + padding: EdgeInsets.only(left: 13.0, right: 13.0), + decoration: BoxDecoration( + border: Border.all( + color: Colors.green, + style: BorderStyle.solid, + width: 5.0, + ), + color: Colors.green, + borderRadius: BorderRadius.circular(30.0) ), - ), - ), - ], - ), - SizedBox( - height: 5,), - Row( - children: [ - Container( - child: Text('12', - style: TextStyle(fontSize: 14.0, + child: Text( + processingOrderList[index].orderStatus.toString().substring(12), + style: TextStyle( + color: Colors.white, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), ), ), - ), - Container( - margin: EdgeInsets.only(left: 5), - child: Text(TranslationBase.of(context).itemsNo, - style: TextStyle(fontSize: 14.0, + Container( + margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), + child: Column( +// crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Row( + children: [ + Container( + margin: EdgeInsets.only(left: 5), + child: Text(processingOrderList[index].orderTotal.toString(), + style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, + ), + ), + ), + Container( + margin: EdgeInsets.only(left: 5), + child: Text(TranslationBase.of(context).sar, + style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + SizedBox( + height: 5,), + Row( + children: [ + Container( + child: Text(processingOrderList[index].orderItems.length.toString(), + style: TextStyle(fontSize: 14.0, + ), + ), + ), + Container( + margin: EdgeInsets.only(left: 5), + child: Text(TranslationBase.of(context).itemsNo, + style: TextStyle(fontSize: 14.0, + ), + ), + ), + ], + ), + ], ), ), - ), - ], - ), - ], - ), - ), - ], - ), - Divider( - color: Colors.grey[350], - height: 20, - thickness: 8, - indent: 0, - endIndent: 0, - ), + ], + ), + Divider( + color: Colors.grey[350], + height: 20, + thickness: 8, + indent: 0, + endIndent: 0, + ), + ], + ), + ); + } + ) ], ), ) : Container( - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset( - 'assets/images/pharmacy/empty_box.svg'), - Container( - margin: EdgeInsets.only(top: 10.0), - child: Text(TranslationBase.of(context).noOrder, - style: TextStyle( - fontSize: 16.0, - )), + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SvgPicture.asset( + 'assets/images/pharmacy/empty_box.svg'), + Container( + margin: EdgeInsets.only(top: 10.0), + child: Text(TranslationBase.of(context).noOrder, + style: TextStyle( + fontSize: 16.0, + )), + ), + ], + ), ), - ], - ), - ), - ), + ), ); +// return Container( +// child: model.order.length != 0 +// ? SingleChildScrollView( +// child: Column( +// children: [ +// ListView.builder( +// child: Row( +// mainAxisAlignment: MainAxisAlignment.spaceBetween, +// children: [ +// Container( +// margin: EdgeInsets.all(8), +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Row( +// children: [ +// Container( +// margin: EdgeInsets.only(right: 5), +// child: Text(TranslationBase.of(context).orderNumber, +// style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, +// ), +// ), +// ), +// Container( +// child: Text(processingOrderList[0].id.toString(), +// style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, +// ), +// ), +// ), +// ], +// ), +// SizedBox( +// height: 5,), +// Row( +// children: [ +// Container( +// margin: EdgeInsets.only(right: 5), +// child: Text(TranslationBase.of(context).orderDate, +// style: TextStyle(fontSize: 14.0, +// ), +// ), +// ), +// Container( +// child: Text(processingOrderList[0].createdOnUtc.toString().substring(0,11), +// style: TextStyle(fontSize: 14.0, +// ), +// ), +// ), +// ], +// ), +// ], +// ), +// ), +// Container( +// margin: EdgeInsets.all(8), +// child: InkWell( +// onTap: () { +// Navigator.push(context, +// MaterialPageRoute(builder: (context) => OrderDetailsPage(orderModel:processingOrderList[0]))); +// }, +// child: SvgPicture.asset( +// 'assets/images/pharmacy/arrow_right.svg', +// height: 20, +// width: 20,), +// ), +// ), +// ], +// ), +// ), +// Divider( +// color: Colors.grey[350], +// height: 20, +// thickness: 1, +// indent: 0, +// endIndent: 0, +// ), +// Row( +// mainAxisAlignment: MainAxisAlignment.spaceBetween, +// children: [ +// Container( +// margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), +// padding: EdgeInsets.only(left: 13.0, right: 13.0), +// decoration: BoxDecoration( +// border: Border.all( +// color: Colors.green, +// style: BorderStyle.solid, +// width: 5.0, +// ), +// color: Colors.green, +// borderRadius: BorderRadius.circular(30.0) +// ), +// child: Text( widget.languageID == "ar" +// ? processingOrderList[0].orderStatusn.toString() +// : processingOrderList[0].orderStatus.toString().substring(12), +//// TranslationBase.of(context).processing, +// style: TextStyle( +// color: Colors.white, +// fontSize: 15.0, +// fontWeight: FontWeight.bold, +// ), +// ), +// ), +// Container( +// margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), +// child: Column( +//// crossAxisAlignment: CrossAxisAlignment.end, +// children: [ +// Row( +// children: [ +// Container( +// margin: EdgeInsets.only(left: 5), +// child: Text(processingOrderList[0].orderTotal.toString(), +// style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, +// ), +// ), +// ), +// Container( +// margin: EdgeInsets.only(left: 5), +// child: Text(TranslationBase.of(context).sar, +// style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, +// ), +// ), +// ), +// ], +// ), +// SizedBox( +// height: 5,), +// Row( +// children: [ +// Container( +// child: Text(processingOrderList[0].orderItems[0].quantity.toString(), +// style: TextStyle(fontSize: 14.0, +// ), +// ), +// ), +// Container( +// margin: EdgeInsets.only(left: 5), +// child: Text(TranslationBase.of(context).itemsNo, +// style: TextStyle(fontSize: 14.0, +// ), +// ), +// ), +// ], +// ), +// ], +// ), +// ), +// ], +// ), +// Divider( +// color: Colors.grey[350], +// height: 20, +// thickness: 8, +// indent: 0, +// endIndent: 0, +// ), +// ], +// ), +// ) +// : Container( +// child: Center( +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// crossAxisAlignment: CrossAxisAlignment.center, +// children: [ +// SvgPicture.asset( +// 'assets/images/pharmacy/empty_box.svg'), +// Container( +// margin: EdgeInsets.only(top: 10.0), +// child: Text(TranslationBase.of(context).noOrder, +// style: TextStyle( +// fontSize: 16.0, +// )), +// ), +// ], +// ), +// ), +// ), +// ); } Widget getPendingOrder(OrderModelViewModel model){ + for(int i=0 ; i< model.order.length; i++){ + if( model.order[i].orderStatusId == 10){ + pendingOrderList.add(model.order[i]); + } + } return Container( - child: model.order.length != 0 && model.order[0].orderStatusId == 10 + child: model.order.length != 0 ? SingleChildScrollView( child: Column( children: [ @@ -474,7 +683,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), - itemCount: 2 , + itemCount: pendingOrderList.length , itemBuilder: (context, index){ return Container( child: SingleChildScrollView( @@ -498,7 +707,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ), ), Container( - child: Text(model.order[0].id.toString(), + child: Text(pendingOrderList[index].id.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), @@ -517,7 +726,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ), ), Container( - child: Text(model.order[0].createdOnUtc.toString(), + child: Text(pendingOrderList[index].createdOnUtc.toString().substring(0,11), style: TextStyle(fontSize: 14.0, ), ), @@ -532,7 +741,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix child: InkWell( onTap: () { Navigator.push(context, - MaterialPageRoute(builder: (context) => OrderDetailsPage())); + MaterialPageRoute(builder: (context) => OrderDetailsPage(orderModel:pendingOrderList[index]))); }, child: SvgPicture.asset( 'assets/images/pharmacy/arrow_right.svg', @@ -552,28 +761,29 @@ class _OrderPageState extends State with SingleTickerProviderStateMix Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded( - child:Container( - margin: EdgeInsets.all(8.0), - padding: EdgeInsets.only(left: 13.0, right: 13.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.orange[300], - style: BorderStyle.solid, - width: 5.0, - ), - color: Colors.orange[300], - borderRadius: BorderRadius.circular(30.0) - ), - child: Text( - model.order[0].orderStatus.toString(), - style: TextStyle( - color: Colors.white, - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), + Container( + margin: EdgeInsets.all(8.0), + padding: EdgeInsets.only(left: 13.0, right: 13.0), + decoration: BoxDecoration( + border: Border.all( + color: Colors.orange[300], + style: BorderStyle.solid, + width: 5.0, ), - ), ), + color: Colors.orange[300], + borderRadius: BorderRadius.circular(30.0) + ), + child: Text( + widget.languageID == "ar" + ? pendingOrderList[index].orderStatusn.toString() + : pendingOrderList[index].orderStatus.toString().substring(12), + style: TextStyle( + color: Colors.white, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ), Container( margin: EdgeInsets.all(8.0), child: Column( @@ -583,7 +793,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix children: [ Container( margin: EdgeInsets.only(left: 5), - child: Text(model.order[0].orderTotal.toString(), + child: Text(pendingOrderList[index].orderTotal.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), @@ -602,7 +812,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix Row( children: [ Container( - child: Text('12', + child: Text(pendingOrderList[index].orderItems.length.toString(), style: TextStyle(fontSize: 14.0, ), ), @@ -644,7 +854,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Image.asset( + SvgPicture.asset( 'assets/images/pharmacy/empty_box.svg'), Container( margin: EdgeInsets.only(top: 10.0), @@ -662,8 +872,14 @@ class _OrderPageState extends State with SingleTickerProviderStateMix } Widget getCancelledOrder(OrderModelViewModel model){ + for(int i=0 ; i< model.order.length; i++){ + if( model.order[i].orderStatusId == 40 || model.order[i].orderStatusId == 996 + || model.order[i].orderStatusId == 200){ + cancelledOrderList.add(model.order[i]); + } + } return Container( - child: model.order.length != 0 && model.order[0].orderStatusId == 40 + child: model.order.length != 0 ? SingleChildScrollView( child: Column( children: [ @@ -671,7 +887,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), - itemCount: 2 , + itemCount: cancelledOrderList.length, itemBuilder: (context, index){ return Container( child: SingleChildScrollView( @@ -695,7 +911,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ), ), Container( - child: Text(model.order[0].id.toString(), + child: Text(cancelledOrderList[index].id.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), @@ -714,7 +930,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ), ), Container( - child: Text(model.order[0].createdOnUtc.toString(), + child: Text(cancelledOrderList[index].createdOnUtc.toString().substring(0,11), style: TextStyle(fontSize: 14.0, ), ), @@ -729,7 +945,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix child: InkWell( onTap: () { Navigator.push(context, - MaterialPageRoute(builder: (context) => OrderDetailsPage())); + MaterialPageRoute(builder: (context) => OrderDetailsPage(orderModel:cancelledOrderList[index]))); }, child: SvgPicture.asset( 'assets/images/pharmacy/arrow_right.svg', @@ -749,28 +965,28 @@ class _OrderPageState extends State with SingleTickerProviderStateMix Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded( - child:Container( - margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), - padding: EdgeInsets.only(left: 10.0, right: 10.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.red[900], - style: BorderStyle.solid, - width: 5.0, - ), - color: Colors.red[900], - borderRadius: BorderRadius.circular(30.0) - ), - child: Text( - model.order[0].orderStatus.toString(), - style: TextStyle( - color: Colors.white, - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), + Container( + margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), + padding: EdgeInsets.only(left: 10.0, right: 10.0), + decoration: BoxDecoration( + border: Border.all( + color: Colors.red[900], + style: BorderStyle.solid, + width: 5.0, ), - ), ), + color: Colors.red[900], + borderRadius: BorderRadius.circular(30.0) + ), + child: Text( widget.languageID == "ar" + ? cancelledOrderList[index].orderStatusn.toString() + : cancelledOrderList[index].orderStatus.toString().substring(12), + style: TextStyle( + color: Colors.white, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ), Container( margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), child: Column( @@ -780,7 +996,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix children: [ Container( margin: EdgeInsets.only(left: 5), - child: Text(model.order[0].orderTotal.toString(), + child: Text(cancelledOrderList[index].orderTotal.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), @@ -799,7 +1015,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix Row( children: [ Container( - child: Text('12', + child: Text(cancelledOrderList[index].orderItems.length.toString(), style: TextStyle(fontSize: 14.0, ), ), @@ -841,7 +1057,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Image.asset( + SvgPicture.asset( 'assets/images/pharmacy/empty_box.svg'), Container( margin: EdgeInsets.only(top: 10.0), @@ -856,26 +1072,17 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ), ); } -} + getLanguageID() async { + var languageID = await sharedPref.getString(APP_LANGUAGE); + setState(() { + widget.languageID = languageID; + }); + } +} -// filterOrders() { -// for () { -// if (order.order_status_id === 30 || order.order_status_id === 997 || order.order_status_id === 994) { // complete -// this.delivered.push(order); -// } else if (order.order_status_id === 40 || order.order_status_id === 200 || order.order_status_id === 996) { // cancelled & order refunded -// this.cancelled.push(order); -// } else if (order.order_status_id === 10) { // Pending -// this.pending.push(order); -// } else if (order.order_status_id === 20 || order.order_status_id === 995 || order.order_status_id === 998 || order.order_status_id === 999) { // Processing -// this.processing.push(order); -// } else { // Processing & other all other status -// this.other.push(order); -// } -// } -//} diff --git a/lib/pages/pharmacy/order/OrderDetails.dart b/lib/pages/pharmacy/order/OrderDetails.dart index d406e7f5..3c6e62b1 100644 --- a/lib/pages/pharmacy/order/OrderDetails.dart +++ b/lib/pages/pharmacy/order/OrderDetails.dart @@ -1,6 +1,8 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/order/Order.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -9,11 +11,24 @@ import 'package:diplomaticquarterapp/widgets//pharmacy/product_tile.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/orderDetails_service.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart'; +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; + class OrderDetailsPage extends StatefulWidget { + var languageID ; + + + OrderModel orderModel; + OrderDetailsPage({ + @required this.orderModel +}); + @override _OrderDetailsPageState createState() => _OrderDetailsPageState(); } @@ -23,20 +38,28 @@ class _OrderDetailsPageState extends State { String customerId=""; String page_id=""; String orderId="3516"; + var model; + var isCancel = false; + var isRefund = false; + var dataIsCancel; + var dataIsRefund; + + @override void initState() { - WidgetsBinding.instance.addPostFrameCallback((_) => getOrderDetails()); super.initState(); + getLanguageID(); + + getCancelOrder(widget.orderModel.id); +// cancelOrderDetail(widget.orderModel.id); } @override Widget build(BuildContext context) { return BaseView( - onModelReady:(model) => model.getOrderDetails(orderId), + onModelReady:(model) => model.getOrderDetails(widget.orderModel.id), builder: (_,model, wi )=> AppScaffold( - appBarTitle: (TranslationBase.of(context).orderDetail), -// title: Text(TranslationBase.of(context).orderDetail, style: TextStyle(color:Colors.white)), -// backgroundColor: Colors.green, + appBarTitle: TranslationBase.of(context).orderDetail, isShowAppBar: true, isPharmacy:true , body: Container( @@ -62,39 +85,43 @@ class _OrderDetailsPageState extends State { ], ), ), - Container( - margin: EdgeInsets.only(top: 15.0, right: 10.0), - padding: EdgeInsets.only(left: 11.0, right: 11.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.blue, - style: BorderStyle.solid, - width: 5.0, + Container( + + margin: EdgeInsets.only(top: 15.0, right: 10.0), + padding: EdgeInsets.only(left: 11.0, right: 11.0), + decoration: BoxDecoration( + border: Border.all( + color: getStatusBackgroundColor(), + style: BorderStyle.solid, + width: 5.0, + ), + color: getStatusBackgroundColor(), + borderRadius: BorderRadius.circular(30.0) + ), + child: Text(widget.orderModel.orderStatus.toString().substring(12), +// widget.languageID == "ar" +// ? widget.orderModel.orderStatusn.toString() +// : widget.orderModel.orderStatus.toString().substring(12) , +// TranslationBase.of(context).delivered, + style: TextStyle( + color: Colors.white, + fontSize: 13.0, + fontWeight: FontWeight.bold, ), - color: Colors.blue, - borderRadius: BorderRadius.circular(30.0) - ), - child: Text( - TranslationBase.of(context).delivered, - style: TextStyle( - color: Colors.white, - fontSize: 13.0, - fontWeight: FontWeight.bold, ), ), - ), ], ), Container( margin: EdgeInsets.only(left: 10.0, top: 13.0), child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('NAME', - style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold, - ), + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(model.order[0].shippingAddress.firstName.toString().substring(10) + ' ' +model.order[0].shippingAddress.lastName.toString().substring(9), + style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold, ), - ], + ), + ] ), ), Container( @@ -102,7 +129,7 @@ class _OrderDetailsPageState extends State { child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text('Cloud Solutions', + Text(model.order[0].shippingAddress.address1.toString().substring(9), style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold, color: Colors.grey, ), @@ -110,22 +137,37 @@ class _OrderDetailsPageState extends State { ], ), ), - Row( - children: [ - Container( - margin: EdgeInsets.fromLTRB(10.0, 5.0, 8.0, 5.0), - child: SvgPicture.asset( - 'assets/images/pharmacy/mobile_number_icon.svg', - height: 13,), + Container( + margin: EdgeInsets.fromLTRB(10.0, 5.0, 1.0, 5.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(model.order[0].shippingAddress.address2.toString().substring(9), + style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold, + color: Colors.grey, + ), ), - Container( - margin: EdgeInsets.only(top: 5.0, bottom: 5.0), - child: Text('588888778', - style: TextStyle(fontSize: 15.0, + ] + ), + ), + Container( + child: Row( + children: [ + Container( + margin: EdgeInsets.fromLTRB(10.0, 5.0, 8.0, 5.0), + child: SvgPicture.asset( + 'assets/images/pharmacy/mobile_number_icon.svg', + height: 13,), + ), + Container( + margin: EdgeInsets.only(top: 5.0, bottom: 5.0), + child: Text(model.order[0].shippingAddress.phoneNumber.toString(), + style: TextStyle(fontSize: 15.0, + ), ), ), - ), - ], + ], + ), ), Divider( color: Colors.grey[350], @@ -151,11 +193,21 @@ class _OrderDetailsPageState extends State { ), ), Container( - margin: EdgeInsets.only(bottom: 10.0, top: 10.0), - child: SvgPicture.asset( - 'assets/images/pharmacy/hmg_shipping_logo.svg', - height: 25, - width: 25,), + child: model.order[0].shippingRateComputationMethodSystemName == "Shipping.FixedOrByWeight" + ? Container( + margin: EdgeInsets.only(bottom: 10.0, top: 10.0), + child: SvgPicture.asset( + 'assets/images/pharmacy/hmg_shipping_logo.svg', + height: 25, + width: 25,), + ) + : Container( + margin: EdgeInsets.only(bottom: 10.0, top: 10.0), + child: SvgPicture.asset( + 'assets/images/pharmacy/aramex_shipping_logo.svg', + height: 25, + width: 25,), + ), ), ], ), @@ -184,7 +236,7 @@ class _OrderDetailsPageState extends State { ), Container( margin: EdgeInsets.only(bottom: 10.0, top: 10.0), - child:Text('Mada', + child:Text(model.order[0].paymentName.toString().substring(12), style: TextStyle(fontSize: 13.0, fontWeight: FontWeight.bold, ), ), @@ -211,10 +263,23 @@ class _OrderDetailsPageState extends State { ], ), ), - Container( - child: productTile(productName: 'Panadol Extra 500 MG', productPrice: '10.00', productRate: 3.00, - productReviews:4, totalPrice: '10.00', qyt: '3',), + ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount:widget.orderModel.orderItems.length, + itemBuilder: (context, index){ + return Container( + child: productTile(productName: widget.orderModel.orderItems[index].product.name.toString(), + productPrice: widget.orderModel.orderItems[index].product.price.toString(), + productRate: widget.orderModel.orderItems[index].product.approvedRatingSum.toDouble(), + productReviews:widget.orderModel.orderItems[index].product.approvedTotalReviews, + totalPrice: widget.orderModel.orderItems[index].priceExclTax.toString(), + qyt: widget.orderModel.orderItems[index].quantity.toString(),), + ); + } ), + Container( padding: EdgeInsets.only(bottom: 10.0), margin: EdgeInsets.only(left: 10.0, top: 5.0), @@ -253,7 +318,7 @@ class _OrderDetailsPageState extends State { ), ), ), - Text('343.55', + Text(model.order[0].orderSubtotalExclTax.toString(), style: TextStyle(fontSize: 13.0, ), ), @@ -287,7 +352,7 @@ class _OrderDetailsPageState extends State { ), ), ), - Text('343.55', + Text(model.order[0].orderShippingExclTax.toString(), style: TextStyle(fontSize: 13.0, ), ), @@ -321,7 +386,7 @@ class _OrderDetailsPageState extends State { ), ), ), - Text('343.55', + Text(model.order[0].orderTax.toString(), style: TextStyle(fontSize: 13.0, ), ), @@ -353,7 +418,7 @@ class _OrderDetailsPageState extends State { ), ), ), - Text('343.55', + Text(model.order[0].orderTotal.toString(), style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold, ), ), @@ -362,14 +427,16 @@ class _OrderDetailsPageState extends State { ), ], ), - InkWell( + widget.orderModel.orderStatusId == 10 ? InkWell( onTap: (){ - }, + // payOnline link + }, child: Container( - margin: EdgeInsets.only(top: 20.0), +// margin: EdgeInsets.only(top: 20.0), height: 50.0, color: Colors.transparent, child: Container( + padding: EdgeInsets.only(left: 150.0, right: 150.0), decoration: BoxDecoration( border: Border.all( color: Colors.green, @@ -390,27 +457,30 @@ class _OrderDetailsPageState extends State { ), ), ), - ), - InkWell( + ) : Container(), + +// getCancelOrder(canCancel, canRefund), + isCancel ? InkWell( onTap: () { -// confirmDelete(snapshot.data[index]["id"]); - cancelOrder("id"); + Navigator.push(context, + MaterialPageRoute(builder: (context) => presentConfirmDialog())); }, child: Container( +// padding: EdgeInsets.only(left: 13.0, right: 13.0, top: 5.0), height: 50.0, color: Colors.transparent, - child: Center( - child: Text( - TranslationBase.of(context).cancelOrder, - style: TextStyle( + child: Center( + child: Text( + TranslationBase.of(context).cancelOrder, + style: TextStyle( color: Colors.red[900], fontWeight: FontWeight.bold, decoration: TextDecoration.underline - ), ), ), ), - ), + ), + ) : Container(), ], ), ), @@ -418,58 +488,88 @@ class _OrderDetailsPageState extends State { ), ); } - cancelOrder(id){ - showDialog( + + + + Color getStatusBackgroundColor() { + print(widget.orderModel.orderStatusId); +// if(orderStatus == 'delivered') + if(widget.orderModel.orderStatusId == 30 ||widget.orderModel.orderStatusId == 997 + ||widget.orderModel.orderStatusId == 994) + return Colors.blue[700]; + else if (widget.orderModel.orderStatusId == 20 ||widget.orderModel.orderStatusId == 995 + ||widget.orderModel.orderStatusId == 998 ||widget.orderModel.orderStatusId == 999) + return Colors.green; + else if (widget.orderModel.orderStatusId == 10) + return Colors.orange[300]; + else if (widget.orderModel.orderStatusId == 40 ||widget.orderModel.orderStatusId == 996 + ||widget.orderModel.orderStatusId == 200) + return Colors.red[900]; + } + + + getCancelOrder(dataIsCancel){ + if(widget.orderModel.canCancel && widget.orderModel.canRefund) + { + setState(() { + isCancel = true; + isRefund = false; + }); + } + else if (widget.orderModel.canCancel ){ + setState(() { + isCancel = true; + isRefund = false; + }); + + } + else if (widget.orderModel.canRefund){ + setState(() { + isCancel = false; + isRefund = true; + }); + } + else { + setState(() { + isCancel = false; + isRefund = false; + }); + } +} + + presentConfirmDialog(){ + ConfirmDialog dialog = new ConfirmDialog( context: context, - builder: (BuildContext context)=> AlertDialog( - title: Text(TranslationBase.of(context).confirm, - style: TextStyle( - fontWeight: FontWeight.bold, - ),), - content: Text(TranslationBase.of(context).confirmCancellation, - style: TextStyle( - color: Colors.grey, - ),), - actions:[ - FlatButton( - child: Text(TranslationBase.of(context).cancel, - style: TextStyle( - color: Colors.red, - fontWeight: FontWeight.bold, - fontSize: 16, - ),), - onPressed: (){ - Navigator.pop(context); - }, - ), - FlatButton( - child: Text(TranslationBase.of(context).ok, - style: TextStyle( - color: Colors.grey, - fontWeight: FontWeight.bold, - fontSize: 16, - ),), - onPressed: (){ -// http.delete(""https://uat.hmgwebservices.com/epharmacy/api/orders/$id"); - Navigator.push(context, - MaterialPageRoute(builder: (context)=> OrderDetailsPage())); - }, - ), - ], - ) - ); + confirmMessage: TranslationBase.of(context).confirmCancellation, + okText: TranslationBase.of(context).confirm, + cancelText: TranslationBase.of(context).cancel_nocaps, + okFunction: () => { + cancelOrderDetail(widget.orderModel.id), + ConfirmDialog.closeAlertDialog(context) + }, + cancelFunction: () => {}); + dialog.showAlertDialog(context); + } + + cancelOrderDetail(order){ + if(widget.orderModel.canCancel && widget.orderModel.canRefund == false){ +// setState(() { + cancelOrderDetail(order); + AppToast.showSuccessToast(message: "Request Sent Successfully"); +// }); +// return OrderPage(); + } + else{} + } + + getLanguageID() async { + var languageID = await sharedPref.getString(APP_LANGUAGE); + setState(() { + widget.languageID = languageID; + }); } } - getOrderDetails() { - print("getOrderDetails 5466"); - OrderDetailsService service = new OrderDetailsService(); - service.getOrderDetails(AppGlobal.context).then((res) { - print(res); - }); - } - getPayOrder(){ - } diff --git a/lib/pages/pharmacy/order/ProductReview.dart b/lib/pages/pharmacy/order/ProductReview.dart index 9de67849..0f9217b7 100644 --- a/lib/pages/pharmacy/order/ProductReview.dart +++ b/lib/pages/pharmacy/order/ProductReview.dart @@ -1,3 +1,6 @@ +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -6,6 +9,7 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/order_service.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart'; import 'package:rating_bar/rating_bar.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart'; import 'package:diplomaticquarterapp/widgets//pharmacy/product_tile.dart'; class ProductReviewPage extends StatefulWidget { @@ -15,35 +19,45 @@ class ProductReviewPage extends StatefulWidget { } class _ProductReviewPageState extends State { + String orderId ="3516"; + var pharmacyUser =""; + var product =""; + var CustomerId =""; + String submitTxt =""; + var doctorRating= ""; + var reviewObj = {}; + AppSharedPreferences sharedPref = AppSharedPreferences(); + @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - centerTitle: true, - title: Text(TranslationBase.of(context).writeReview, style: TextStyle(color:Colors.white)), - backgroundColor: Colors.green, - ), + return BaseView( + onModelReady: (model)=>model.getProductReview(orderId), + builder: (_,model, wi )=> AppScaffold( + appBarTitle: TranslationBase.of(context).writeReview, + isShowAppBar: true, + isPharmacy:true , body: Container( color: Colors.white, child: SingleChildScrollView( - child: Column( - children: [ -// Container( + child: Column( + children: [ +// Container( // child: productTile(productName: 'Panadol Extra 500 MG', productPrice: '10.00', productRate: 3.00, // productReviews:4, ), // ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - margin: EdgeInsets.only(left: 10), - child: Image( - image: - AssetImage('assets/images/al-habib_onlne_pharmacy_bg.png'), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + margin: EdgeInsets.only(left: 10), + child: SvgPicture.asset( +// model.order[0].orderItems[0].product.images[0].src.toString(), + 'assets/images/al-habib_onlne_pharmacy_bg.png', fit: BoxFit.cover, width: 80, height: 80, ), + ),] ), Container( margin: EdgeInsets.only(top :15.0, bottom: 15.0), @@ -51,7 +65,7 @@ class _ProductReviewPageState extends State { children: [ Row( children: [ - Text('medication name', + Text(model.order[0].orderItems[0].product.name.toString(), style: TextStyle(fontSize: 16.0, ), ), @@ -61,14 +75,14 @@ class _ProductReviewPageState extends State { children: [ Container( margin: EdgeInsets.only(left: 5), - child: Text('90.00', + child: Text(model.order[0].orderItems[0].product.price.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), Container( margin: EdgeInsets.only(left: 5), - child: Text('SAR', + child: Text(TranslationBase.of(context).sar, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), @@ -94,14 +108,15 @@ class _ProductReviewPageState extends State { ), ), Container( - child: Text('4.9', + child: Text(model.order[0].orderItems[0].product.approvedRatingSum.toString(), style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold, ), ), ), Container( margin: EdgeInsets.only(left: 5), - child: Text('10 (reviews)', + child: Text("(" + model.order[0].orderItems[0].product.approvedTotalReviews.toString() + + ' ' + TranslationBase.of(context).review +")", style: TextStyle(fontSize: 12.0, ), ), @@ -111,8 +126,6 @@ class _ProductReviewPageState extends State { ], ), ), - ], - ), Divider( color: Colors.grey[350], height: 20, @@ -165,7 +178,8 @@ class _ProductReviewPageState extends State { ), InkWell( onTap: () { - +// Navigator.push(context, +// MaterialPageRoute(builder: (context) => )); }, child: Container( height: 50.0, @@ -196,11 +210,14 @@ class _ProductReviewPageState extends State { ), ], ), - ), - ), - ); + ), + ),), + ); } + + + //new screen is showing after submitting the review Widget getReviewedProduct(){ return Column( @@ -309,4 +326,24 @@ class _ProductReviewPageState extends State { ], ); } + +// submit(){ +// this.orderId.id = "0"; +// this.reviewObj.position = 0; +// this.reviewObj.customerId = this.pharmacyUser.CustomerId; +// this.reviewObj.productId = this.product.id; +// this.reviewObj.storeId = 2; +// this.reviewObj.isApproved = false; +// this.reviewObj.title =''; +// this.reviewObj.reviewText = this.submitTxt; +// this.reviewObj.rating = this.doctorRating; +// this.reviewObj.replyText = null; +// this.reviewObj.helpfulYesTotal = 0; +// this.reviewObj.helpfulNoTotal = 0; +// this.reviewObj.createdOnUtc = new Date().toString(); +// this.submitProductReview(); +// } + submitProductReview(){ + + } } diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 44df964d..07862645 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -7,9 +7,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/AddAddress.dart'; -import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/pharmacyAddress_service.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyAddressesModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart'; class PharmacyAddressesPage extends StatefulWidget{ @override @@ -17,13 +19,11 @@ class PharmacyAddressesPage extends StatefulWidget{ } class _PharmacyAddressesState extends State{ - + String address=""; int selectedRadio; bool _value = false; AppSharedPreferences sharedPref = AppSharedPreferences(); - - @override void initState(){ // WidgetsBinding.instance.addPostFrameCallback((_) => getAllAddress()); @@ -39,12 +39,10 @@ class _PharmacyAddressesState extends State{ Widget build (BuildContext context){ return BaseView( - onModelReady: (model) => model.getAddress(), + onModelReady: (model) => model.getAddress(address), builder: (_,model, wi )=> AppScaffold( - appBarTitle: "", -// centerTitle: true, -// title: Text(TranslationBase.of(context).changeAddress, style: TextStyle(color:Colors.white)), -// backgroundColor: Colors.green, + appBarTitle:TranslationBase.of(context).changeAddress, + baseViewModel: model, isShowAppBar: true, isPharmacy:true , body: Container( @@ -55,7 +53,7 @@ class _PharmacyAddressesState extends State{ scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), - itemCount: 5 , + itemCount: model.address.length, itemBuilder: (context, index){ return Container( child: Padding( @@ -111,14 +109,19 @@ class _PharmacyAddressesState extends State{ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text('NAME', + Text('name', +// model.address[0].customers[0].addresses[0].firstName, style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold, ), ), SizedBox( height: 5,), - Text('Address', - style: TextStyle(fontSize: 15.0, color: Colors.grey, + Expanded( + child: Text(model.address[0].customers[0].addresses[0].address1+ ''+ + model.address[0].customers[0].addresses[0].address2+ '' + + model.address[0].customers[0].addresses[0].zipPostalCode, + style: TextStyle(fontSize: 15.0, color: Colors.grey, + ), ), ), SizedBox( @@ -354,11 +357,6 @@ class _PharmacyAddressesState extends State{ } getAllAddress() { -// print("ADDRESSES"); -// PharmacyAddressService service = new PharmacyAddressService(); -// service.getAddress(AppGlobal.context).then((res) { -// print(res); -// }); } diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index 272ef0d4..ec19ae8d 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -1,7 +1,21 @@ +import 'package:diplomaticquarterapp/pages/ContactUs/LiveChat/livechat_page.dart'; +import 'package:diplomaticquarterapp/pages/ContactUs/findus/findus_page.dart'; +import 'package:diplomaticquarterapp/pages/family/my-family.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/wishlist.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/order/Order.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart'; import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; + class PharmacyProfilePage extends StatefulWidget { @override @@ -9,370 +23,411 @@ class PharmacyProfilePage extends StatefulWidget { } class _ProfilePageState extends State { + AppSharedPreferences sharedPref = AppSharedPreferences(); + String customerId=""; + String page_id=""; + @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - centerTitle: true, - title: Text(TranslationBase.of(context).myAccount, style: TextStyle(color:Colors.white)), - backgroundColor: Colors.green, - ), - body: Container( - child:SingleChildScrollView( - child: Column( - children:[ - Container( - child:Row( - children: [ - Container( - padding:EdgeInsets.only(top:20.0, left:10.0, right:10.0, bottom:10.0,), - child: LargeAvatar(name: "profile", url:'' ,), - ), - Container( - child: Column( - children: [ - Text( - TranslationBase.of(context).welcome, - style: TextStyle(fontSize: 14.0, - fontWeight: FontWeight.bold, - color:Colors.grey - ), - ), - Text( - 'NAME', - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold - ), - ), - ], - ), - ) - ], - ), - ), - Divider( - color: Colors.grey[350], - height: 20, - thickness: 5, - indent: 0, - endIndent: 0, - ), - SizedBox( - height: 15, - ), - Container( + return BaseView( + onModelReady: (model) => model.getOrder(customerId, page_id), + builder: (_,model, wi )=> AppScaffold( + appBarTitle: TranslationBase.of(context).myAccount, + isShowAppBar: true, + isPharmacy:true , + body: Container( + child:SingleChildScrollView( + child: Column( + children:[ + Container( child:Row( children: [ - Expanded( - child: InkWell( - child: Column( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/orders_icon.svg', - width: 50, - height: 50,), - SizedBox( - height: 5, + Container( + padding:EdgeInsets.only(top:20.0, left:10.0, right:10.0, bottom:10.0,), + child: LargeAvatar(name: "profile", url:'' ,), + ), + Container( + child: Column( + children: [ + Text( + TranslationBase.of(context).welcome, + style: TextStyle(fontSize: 14.0, + fontWeight: FontWeight.bold, + color:Colors.grey ), - Text( - TranslationBase.of(context).orders, - style: TextStyle(fontSize: 13.0, - fontWeight: FontWeight.bold,), + ), + Text("Name", +// model.order[0].customer.firstName.toString(), + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold ), - ], + ), + ], + ), + ) + ], + ), + ), + Divider( + color: Colors.grey[350], + height: 20, + thickness: 5, + indent: 0, + endIndent: 0, + ), + SizedBox( + height: 15, + ), + Container( + child:Row( + children: [ + Expanded( + child: InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => OrderPage())); + }, + child: Column( + children: [ + SvgPicture.asset( + 'assets/images/pharmacy/orders_icon.svg', + width: 50, + height: 50,), + SizedBox( + height: 5, + ), + Text( + TranslationBase.of(context).orders, + style: TextStyle(fontSize: 13.0, + fontWeight: FontWeight.bold,), + ), + ], + ), ), ), - ), - Expanded( - child: InkWell( - child: Column( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/lakum_icon.svg', - width: 50, - height: 50,), - SizedBox( - height: 5, - ), - Text( - TranslationBase.of(context).lakum, - style: TextStyle(fontSize: 13.0, - fontWeight: FontWeight.bold + Expanded( + child: InkWell( + child: Column( + children: [ + SvgPicture.asset( + 'assets/images/pharmacy/lakum_icon.svg', + width: 50, + height: 50,), + SizedBox( + height: 5, ), - ), - ], + Text( + TranslationBase.of(context).lakum, + style: TextStyle(fontSize: 13.0, + fontWeight: FontWeight.bold + ), + ), + ], + ), ), ), - ), - Expanded( - child: InkWell( - child: Column( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/wishlist_icon.svg', - width: 50, - height: 50,), - SizedBox( - height: 5, - ), - Text( - TranslationBase.of(context).wishlist, - style: TextStyle(fontSize: 13.0, - fontWeight: FontWeight.bold,), - ), - ], + Expanded( + child: InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => WishlistPage())); + }, + child: Column( + children: [ + SvgPicture.asset( + 'assets/images/pharmacy/wishlist_icon.svg', + width: 50, + height: 50,), + SizedBox( + height: 5, + ), + Text( + TranslationBase.of(context).wishlist, + style: TextStyle(fontSize: 13.0, + fontWeight: FontWeight.bold,), + ), + ], + ), ), ), + Expanded( + child: InkWell( + child: Column( + children: [ + SvgPicture.asset( + 'assets/images/pharmacy/review_icon.svg', + width: 50, + height: 50,), + SizedBox( + height: 5, + ), + Text( + TranslationBase.of(context).reviews, + style: TextStyle(fontSize: 13.0, + fontWeight: FontWeight.bold,), + ), + ], + ), + ), + ), + ], + ) + ), + SizedBox( + height: 15, + ), + Divider( + color: Colors.grey[350], + height: 20, + thickness: 5, + indent: 0, + endIndent: 0, + ), + SizedBox( + height: 10, + ), + Container( + padding: EdgeInsets.only(left: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).myAccount, + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold + ), ), - Expanded( - child: InkWell( - child: Column( + SizedBox( + height: 10, + ), + Divider( + color: Colors.grey, + height: 20, + ), + InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => HomePrescriptionsPage())); + }, + child: Row( children: [ SvgPicture.asset( - 'assets/images/pharmacy/review_icon.svg', - width: 50, - height: 50,), + 'assets/images/pharmacy/my_prescription_icon.svg', + width: 28, + height: 28,), SizedBox( - height: 5, - ), - Text( - TranslationBase.of(context).reviews, - style: TextStyle(fontSize: 13.0, - fontWeight: FontWeight.bold,), + width: 15, ), + Text(TranslationBase.of(context).myPrescription, + style: TextStyle(fontSize: 13.0, + ), + ), ], ), - ), - ), - ], - ) - ), - SizedBox( - height: 15, - ), - Divider( - color: Colors.grey[350], - height: 20, - thickness: 5, - indent: 0, - endIndent: 0, - ), - SizedBox( - height: 10, - ), - Container( - padding: EdgeInsets.only(left: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).myAccount, - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold ), - ), - SizedBox( - height: 10, - ), - Divider( - color: Colors.grey, - height: 20, - ), - InkWell( - child: Row( + SizedBox( + height: 5, + ), + Divider( + color: Colors.grey, + height: 20, + ), + InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => MyFamily())); + }, + child: Row( children: [ SvgPicture.asset( - 'assets/images/pharmacy/my_prescription_icon.svg', + 'assets/images/pharmacy/compare.png', width: 28, height: 28,), SizedBox( width: 15, ), - Text(TranslationBase.of(context).myPrescriptions, - style: TextStyle(fontSize: 13.0, - ), + Text(TranslationBase.of(context).compare, + style: TextStyle(fontSize: 13.0, ), + ), ], ), - ), - SizedBox( - height: 5, - ), - Divider( - color: Colors.grey, - height: 20, - ), - InkWell( - child: Row( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/medication_refill_icon.svg', - width: 28, - height: 28,), - SizedBox( - width: 15, - ), - Text(TranslationBase.of(context).medicationRefill, - style: TextStyle(fontSize: 13.0, - ), - ), - ], ), - ), - SizedBox( - height: 5, - ), - Divider( - color: Colors.grey, - height: 20, - ), - InkWell( - child: Row( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/pill_reminder_icon.svg', - width: 30, - height: 30,), - SizedBox( - width: 20, - ), - Text(TranslationBase.of(context).pillReminder, - style: TextStyle(fontSize: 13.0, - ), - ), - ], + SizedBox( + height: 5, ), - ), - SizedBox( - height: 5, - ), - Divider( - color: Colors.grey, - height: 20, - ), - InkWell( - child: Row( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/my_family_icon.svg', - width: 20, - height: 20,), - SizedBox( - width: 20, - ), - Text(TranslationBase.of(context).family, - style: TextStyle(fontSize: 13.0, - ), - ), - ], + Divider( + color: Colors.grey, + height: 20, ), - ), - SizedBox( - height: 5, - ), - Divider( - color: Colors.grey, - height: 20, - ), - InkWell( - child: Row( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/shipping_addresses_icon.svg', - width: 30, - height: 30,), - SizedBox( - width: 20, - ), - Text(TranslationBase.of(context).shippingAddresses, - style: TextStyle(fontSize: 13.0, + InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => HomePrescriptionsPage())); + }, + child: Row( + children: [ + SvgPicture.asset( + 'assets/images/pharmacy/medication_refill_icon.svg', + width: 30, + height: 30,), + SizedBox( + width: 20, ), - ), - ], + Text(TranslationBase.of(context).medicationsRefill, + style: TextStyle(fontSize: 13.0, + ), + ), + ], + ), ), - ), - ], - ), - ), - SizedBox( - height: 10, - ), - Divider( - color: Colors.grey[350], - height: 20, - thickness: 5, - indent: 0, - endIndent: 0, - ), - SizedBox( - height: 10, - ), - Container( - padding: EdgeInsets.only(left: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).reachUs, - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold + SizedBox( + height: 5, ), - ), - SizedBox( - height: 5, - ), - Divider( - color: Colors.grey, - height: 20, - ), - InkWell( - child: Row( + Divider( + color: Colors.grey, + height: 20, + ), + InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => MyFamily())); + }, + child: Row( children: [ SvgPicture.asset( - 'assets/images/pharmacy/contact_us_icon.svg', + 'assets/images/pharmacy/my_family_icon.svg', width: 20, height: 20,), SizedBox( width: 20, ), - Text( - TranslationBase.of(context).contactUs, - style: TextStyle(fontSize: 13.0), + Text(TranslationBase.of(context).family, + style: TextStyle(fontSize: 13.0, + ), ), ], ), - ), - SizedBox( - height: 5, - ), - Divider( - color: Colors.grey, - height: 20, - ), - InkWell( - child: Row( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/our_locations_icon.svg', - width: 30, - height: 30,), - SizedBox( - width: 20, - ), - Text( - TranslationBase.of(context).ourLocations, - style: TextStyle(fontSize: 13.0), - ), - ], ), - ) - ], + SizedBox( + height: 5, + ), + Divider( + color: Colors.grey, + height: 20, + ), + InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => PharmacyAddressesPage())); + }, + child: Row( + children: [ + SvgPicture.asset( + 'assets/images/pharmacy/shipping_addresses_icon.svg', + width: 30, + height: 30,), + SizedBox( + width: 20, + ), + Text(TranslationBase.of(context).shippingAddresses, + style: TextStyle(fontSize: 13.0, + ), + ), + ], + ), + ), + ], + ), ), - ) - ], + SizedBox( + height: 10, + ), + Divider( + color: Colors.grey[350], + height: 20, + thickness: 5, + indent: 0, + endIndent: 0, + ), + SizedBox( + height: 10, + ), + Container( + padding: EdgeInsets.only(left: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).reachUs, + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold + ), + ), + SizedBox( + height: 5, + ), + Divider( + color: Colors.grey, + height: 20, + ), + InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => LiveChatPage())); + }, + child: Row( + children: [ + SvgPicture.asset( + 'assets/images/pharmacy/contact_us_icon.svg', + width: 20, + height: 20,), + SizedBox( + width: 20, + ), + Text( + TranslationBase.of(context).contactUs, + style: TextStyle(fontSize: 13.0), + ), + ], + ), + ), + SizedBox( + height: 5, + ), + Divider( + color: Colors.grey, + height: 20, + ), + InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => FindUsPage())); + }, + child: Row( + children: [ + SvgPicture.asset( + 'assets/images/pharmacy/our_locations_icon.svg', + width: 30, + height: 30,), + SizedBox( + width: 20, + ), + Text( + TranslationBase.of(context).ourLocations, + style: TextStyle(fontSize: 13.0), + ), + ], + ), + ) + ], + ), + ) + ], + ), ), ), ), diff --git a/lib/services/pharmacy_services/cancelOrder_service.dart b/lib/services/pharmacy_services/cancelOrder_service.dart new file mode 100644 index 00000000..de80a473 --- /dev/null +++ b/lib/services/pharmacy_services/cancelOrder_service.dart @@ -0,0 +1,39 @@ + +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart'; +import 'package:diplomaticquarterapp/core/service/base_service.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:flutter/material.dart'; + + +class CancelOrderService extends BaseService{ + AppSharedPreferences sharedPref = AppSharedPreferences(); + AppGlobal appGlobal = new AppGlobal(); + + AuthenticatedUser authUser = new AuthenticatedUser(); + AuthProvider authProvider = new AuthProvider(); + + List get orderDetails => orderDetails; + List _orderList = List(); + List get orderList => _orderList; + String url =""; + + + Future cancelOrderDetail(order) async { + print("step 1"); + hasError = false; + await baseAppClient.getPharmacy(GET_Cancel_ORDER+order, + onSuccess: (dynamic response, int statusCode) { + _orderList.clear(); + response['orders'].forEach((item) { + _orderList.add(OrderModel.fromJson(item)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }); + } +} \ No newline at end of file diff --git a/lib/services/pharmacy_services/order_service.dart b/lib/services/pharmacy_services/order_service.dart index d43d417b..70523da1 100644 --- a/lib/services/pharmacy_services/order_service.dart +++ b/lib/services/pharmacy_services/order_service.dart @@ -16,7 +16,7 @@ class OrderService extends BaseService{ List _orderList = List(); List get orderList => _orderList; -String url =""; + String url =""; Future getOrder(custmerId, page_id) async { print("step 1"); @@ -30,6 +30,7 @@ String url =""; response['orders'].forEach((item) { _orderList.add(OrderModel.fromJson(item)); }); + print(_orderList.length); print(response); }, onFailure: (String error, int statusCode) { hasError = true; @@ -38,6 +39,25 @@ String url =""; } + Future getProductReview(orderId) async { + print("step 1"); + hasError = false; + url =GET_ORDER+"customer=1,fields=id,order_total,order_status,order_statusn,order_status_id,created_on_utc&page=1&limit=200&customer_id=1367368"; +// url =GET_ORDER+"customer=1,fields=id,order_total,order_status,order_statusn,order_status_id,created_on_utc&page=$page_id&limit=200&customer_id=$custmerId"; + print(url); + await baseAppClient.getPharmacy(url, + onSuccess: (dynamic response, int statusCode) { + _orderList.clear(); + response['orders'].forEach((item) { + _orderList.add(OrderModel.fromJson(item)); + }); + print(_orderList.length); + print(response); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }); + } // Future getOrder(BuildContext context ) async { // // if (await this.sharedPref.getObject(USER_PROFILE) != null) { diff --git a/lib/services/pharmacy_services/pharmacyAddress_service.dart b/lib/services/pharmacy_services/pharmacyAddress_service.dart index eae5ac8c..3ff2a2d3 100644 --- a/lib/services/pharmacy_services/pharmacyAddress_service.dart +++ b/lib/services/pharmacy_services/pharmacyAddress_service.dart @@ -9,21 +9,23 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyAddressesMode class PharmacyAddressService extends BaseService{ - List get address => address; AppSharedPreferences sharedPref = AppSharedPreferences(); AppGlobal appGlobal = new AppGlobal(); AuthenticatedUser authUser = new AuthenticatedUser(); AuthProvider authProvider = new AuthProvider(); + List get address => address; List _addressList = List(); List get reviewList => _addressList; + String url =""; - - Future getAddress() async { + Future getAddress(address) async { print("step 1"); hasError = false; - await baseAppClient.getPharmacy(GET_ORDER, + url =GET_ADDRESS+"272843?fields=addresses"; + print(url); + await baseAppClient.getPharmacy(url, onSuccess: (dynamic response, int statusCode) { _addressList.clear(); response['customers'].forEach((item) { diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 345592d7..b21558cd 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -764,6 +764,11 @@ class TranslationBase { String get orderDate => localizedValues['orderDate'][locale.languageCode]; String get itemsNo => localizedValues['itemsNo'][locale.languageCode]; String get noOrder => localizedValues['noOrder'][locale.languageCode]; + String get review => localizedValues['review'][locale.languageCode]; + String get deliveredOrder => localizedValues['deliveredOrder'][locale.languageCode]; + String get compare => localizedValues['compare'][locale.languageCode]; + String get medicationsRefill => localizedValues['medicationsRefill'][locale.languageCode]; + String get myPrescription => localizedValues['myPrescription'][locale.languageCode]; // pharmacy module // String get medicationRefill => localizedValues['medicationRefill'][locale.languageCode]; diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index e0182f08..f16ff7e5 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; + class productTile extends StatelessWidget { final String productName; final String productPrice; @@ -25,7 +26,7 @@ class productTile extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - height: 150, + height: 180, width: double.infinity, color: Colors.white, child: Column( @@ -115,7 +116,7 @@ class productTile extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( -// margin: EdgeInsets.all(5), + margin: EdgeInsets.only(bottom: 5.0), child: RichText( text: TextSpan( text: 'QYT: $qyt', @@ -161,68 +162,72 @@ class productTile extends StatelessWidget { ], ), ): Container(), - this.isOrderDetails == true ?Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Container( - margin: EdgeInsets.all(5), - child: Align( - alignment: Alignment.topLeft, - child: RatingBar.readOnly( - initialRating: productRate, - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, +// this.isOrderDetails == true && model.order[0].orderStatusId == 30? + this.isOrderDetails == true? + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Container( +// margin: EdgeInsets.all(5.0), + child: Align( + alignment: Alignment.topLeft, + child: RatingBar.readOnly( + initialRating: productRate, + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), ), ), - ), - Container( - margin: EdgeInsets.all(5), - child: Align( - alignment: Alignment.topLeft, - child: RichText( - text: TextSpan( - text: '($productReviews reviews)', - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.grey, - fontSize: 13), + Container( +// margin: EdgeInsets.all(5), + child: Align( +// alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: '($productReviews reviews)', + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.grey, + fontSize: 13), + ), ), ), ), - ), - InkWell( - onTap: () { - Navigator.push(context, - MaterialPageRoute(builder: (context) => ProductReviewPage())); - }, - child: Container( - padding: EdgeInsets.only(left: 13.0, right: 13.0, top: 5.0), - height: 30.0, - decoration: BoxDecoration( - border: Border.all( - color: Colors.orange, - style: BorderStyle.solid, - width: 1.0 + InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => ProductReviewPage())); + }, + child: Container( + padding: EdgeInsets.only(left: 13.0, right: 13.0, top: 5.0), + height: 30.0, + decoration: BoxDecoration( + border: Border.all( + color: Colors.orange, + style: BorderStyle.solid, + width: 1.0 + ), + color: Colors.transparent, + borderRadius: BorderRadius.circular(5.0) + ), + child: Text( + TranslationBase.of(context).writeReview, + style: TextStyle( + fontSize:12, + color: Colors.orange, + ), ), - color: Colors.transparent, - borderRadius: BorderRadius.circular(5.0) - ), - child: Text( - TranslationBase.of(context).writeReview, - style: TextStyle( - fontSize:12, - color: Colors.orange, ), - ), ), - ), - ], - ) : Container(), + ], + ), + ) : Container(), ], ), ); From ed68eed9dfcbd2e863d204551b3565b09312e11e Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Mon, 7 Dec 2020 12:18:57 +0300 Subject: [PATCH 2/2] added links for profile --- lib/pages/landing/landing_page_pharmcy.dart | 8 +++++--- lib/pages/pharmacy/order/OrderDetails.dart | 22 ++++++++++----------- lib/pages/pharmacy/profile/profile.dart | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 4308e186..59492370 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/parent_categorise_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart'; import 'package:diplomaticquarterapp/pages/pharmacy_categorise.dart'; import 'package:diplomaticquarterapp/pages/search_products_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -136,9 +137,10 @@ class _LandingPagePharmacyState extends State { PharmacyPage(), PharmacyCategorisePage(), OffersCategorisePage(), - Container( - child: Text('text'), - ), + PharmacyProfilePage(), +// Container( +// child: Text('text'), +// ), CartOrderPage(), ], // Please do not remove the BookingOptions from this array ), diff --git a/lib/pages/pharmacy/order/OrderDetails.dart b/lib/pages/pharmacy/order/OrderDetails.dart index 3c6e62b1..94b1aba2 100644 --- a/lib/pages/pharmacy/order/OrderDetails.dart +++ b/lib/pages/pharmacy/order/OrderDetails.dart @@ -544,23 +544,23 @@ class _OrderDetailsPageState extends State { okText: TranslationBase.of(context).confirm, cancelText: TranslationBase.of(context).cancel_nocaps, okFunction: () => { - cancelOrderDetail(widget.orderModel.id), +// cancelOrderDetail(widget.orderModel.id), ConfirmDialog.closeAlertDialog(context) }, cancelFunction: () => {}); dialog.showAlertDialog(context); } - cancelOrderDetail(order){ - if(widget.orderModel.canCancel && widget.orderModel.canRefund == false){ -// setState(() { - cancelOrderDetail(order); - AppToast.showSuccessToast(message: "Request Sent Successfully"); -// }); -// return OrderPage(); - } - else{} - } +// cancelOrderDetail(order){ +// if(widget.orderModel.canCancel && widget.orderModel.canRefund == false){ +//// setState(() { +// cancelOrderDetail(order); +// AppToast.showSuccessToast(message: "Request Sent Successfully"); +//// }); +//// return OrderPage(); +// } +// else{} +// } getLanguageID() async { var languageID = await sharedPref.getString(APP_LANGUAGE); diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index ec19ae8d..0336370c 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -1,6 +1,6 @@ import 'package:diplomaticquarterapp/pages/ContactUs/LiveChat/livechat_page.dart'; import 'package:diplomaticquarterapp/pages/ContactUs/findus/findus_page.dart'; -import 'package:diplomaticquarterapp/pages/family/my-family.dart'; +import 'package:diplomaticquarterapp/pages/DrawerPages/family/my-family.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/wishlist.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/order/Order.dart';