From e4256d6874688d71eb01172ae5f60602ba8eb5c8 Mon Sep 17 00:00:00 2001 From: Zohaib Iqbal Kambrani <> Date: Thu, 5 Aug 2021 19:05:31 +0300 Subject: [PATCH] RRT in progress (Service implementations) --- lib/config/config.dart | 1 + lib/core/viewModels/er/rrt-view-model.dart | 73 ++++++++-- .../AmbulanceRequestIndexPages/Summary.dart | 2 +- lib/pages/ErService/ErOptions.dart | 2 +- .../rrt-pickup-address-page.dart | 133 +++++++++++++++--- .../rapid-response-team/rrt-request-page.dart | 16 +-- lib/uitl/translations_delegate_base.dart | 16 +-- lib/widgets/dialogs/selection-dailog.dart | 56 ++++++++ 8 files changed, 252 insertions(+), 47 deletions(-) create mode 100644 lib/widgets/dialogs/selection-dailog.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index f4d5ac91..d25dc616 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -125,6 +125,7 @@ const INSERT_ER_INERT_PRES_ORDER = /// ER RRT const GET_ALL_RC_TRANSPORTATION = 'rc/api/Transportation/getalltransportation'; const GET_ALL_RRT_QUESTIONS = 'Services/Patients.svc/REST/PatientER_RRT_GetAllQuestions'; +const GET_RRT_SERVICE_PRICE = 'Services/Patients.svc/REST/PatientE_RealRRT_GetServicePrice'; ///FindUs const GET_FINDUS_REQUEST = 'Services/Lists.svc/REST/Get_HMG_Locations'; diff --git a/lib/core/viewModels/er/rrt-view-model.dart b/lib/core/viewModels/er/rrt-view-model.dart index a0ce7d07..975b01a1 100644 --- a/lib/core/viewModels/er/rrt-view-model.dart +++ b/lib/core/viewModels/er/rrt-view-model.dart @@ -1,4 +1,6 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/prescriptions_order.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import '../base_view_model.dart'; @@ -7,42 +9,91 @@ import '../base_view_model.dart'; class RRTService extends BaseService{ } - +class _RRTServiceOrders{ + List pendingOrders = []; + List completedOrders = []; +} class RRTViewModel extends BaseViewModel{ var _service = RRTService(); + _RRTServiceOrders rrtOrders = _RRTServiceOrders(); - Future createRequest(){ - - return null; + Future getRequiredData() async{ + getServicePrice(); + getAllOrders(); } + Future createOrder(){ + var body = {"Latitude":24.828170776367188,"Longitude":46.63229029757938,"IdentificationNo":"2344670985","NationalityID":"JOR","CreatedBy":1231755,"OrderServiceID":5,"Notes":""}; + _service.baseAppClient.post(PATIENT_ER_INSERT_PRES_ORDER, body: body, onSuccess: (response, statusCode){ + print(response); + }, onFailure: (error, statusCode){ - Future getAllRequest(){ - + }); return null; } + // Service ID: 4 == RRT + Future<_RRTServiceOrders> getAllOrders() async{ + await _service.baseAppClient.post(GET_PRESCRIPTIONS_ALL_ORDERS, body: {}, onSuccess: (response, statusCode){ + var data = response["PatientER_GetPatientAllPresOrdersList"]; + if(data != null && data is List){ + data.forEach((json){ + if(json["ServiceID"] == 4){ + if(json["Status"] == 1){ // Pending + rrtOrders.pendingOrders.clear(); + rrtOrders.pendingOrders.add(PrescriptionsOrder.fromJson(json)); + }else if (json["Status"] == 3){ // Completed + rrtOrders.completedOrders.clear(); + rrtOrders.completedOrders.add(PrescriptionsOrder.fromJson(json)); + } + } + }); + } + }, onFailure: (error, statusCode){ + print(error); + }); + return rrtOrders; + } + - Future getRequestDetails(){ + Future getOrderDetails(){ return null; } Future getAllQuestions(){ - + _service.baseAppClient.post(GET_ALL_RRT_QUESTIONS, body: {}, onSuccess: (response, statusCode){ + print(response); + }, onFailure: (error, statusCode){ + print(error); + }); return null; } - Future getCancelReasons(){ + Future getServicePrice(){ + var body = {"IdentificationNo":user.patientIdentificationNo}; + _service.baseAppClient.post(GET_RRT_SERVICE_PRICE, body: body, onSuccess: (response, statusCode){ + print(response); + }, onFailure: (error, statusCode){ + print(error); + }); + return null; + } + Future cancelOrder(){ + var body = {"PresOrderID":"2318","PresOrderStatus":4,"EditedBy":3,"RejectionReason":""}; + _service.baseAppClient.post(PATIENT_ER_UPDATE_PRES_ORDER, body: body, onSuccess: (response, statusCode){ + print(response); + }, onFailure: (error, statusCode){ + print(error); + }); return null; } - Future cancelRequest(){ - return null; + Future getCancelReasons(){ } } \ No newline at end of file diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart index 4ddfaaa3..d6d4372e 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart @@ -31,7 +31,7 @@ class _SummaryState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(TranslationBase.of(context).RRTSummary), + Texts(TranslationBase.of(context).rrtSummary), SizedBox(height: 5,), Container( width: double.infinity, diff --git a/lib/pages/ErService/ErOptions.dart b/lib/pages/ErService/ErOptions.dart index 05121f0f..d80d6566 100644 --- a/lib/pages/ErService/ErOptions.dart +++ b/lib/pages/ErService/ErOptions.dart @@ -116,7 +116,7 @@ class _ErOptionsState extends State { locked: rrtLocked, image: 'assets/images/new-design/AM.PNG', text: TranslationBase.of(context).rrtService, - subText: TranslationBase.of(context).RapidResponseTeam, + subText: TranslationBase.of(context).rapidResponseTeam, onTap:(){ Navigator.push( context, diff --git a/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart b/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart index 91e9cbd2..5b6bf6f6 100644 --- a/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart +++ b/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart @@ -3,9 +3,12 @@ import 'dart:async'; import 'package:diplomaticquarterapp/core/viewModels/er/rrt-view-model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/RadioStringDialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_material_pickers/flutter_material_pickers.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; class RRTRequestPickupAddressPage extends StatefulWidget{ @@ -14,15 +17,26 @@ class RRTRequestPickupAddressPage extends StatefulWidget{ State createState() => RRTRequestPickupAddressPageState(); } -class RRTRequestPickupAddressPageState extends State{ +class RRTRequestPickupAddressPageState extends State with SingleTickerProviderStateMixin{ bool acceptTerms = false; - Completer mapController = Completer(); - static final CameraPosition mapCamera = CameraPosition( - target: LatLng(37.42796133580664, -122.085749655962), + bool mapIdle = true; + Completer mapController = Completer(); + CameraPosition mapCameraPosition = CameraPosition( + target: LatLng(24.7114693, 46.67469582), zoom: 14.4746, ); + + List myAdresses = ["One","Two","Three",]; + dynamic selectedAddress; + + @override + void initState(){ + super.initState(); + goToCurrentLocation(); + } + @override Widget build(BuildContext context) { return BaseView( @@ -37,15 +51,31 @@ class RRTRequestPickupAddressPageState extends State Container(height: 0.25, color: Colors.grey.withOpacity(0.7),) + ) + ); + } + + moveToLocation(LatLng location, {bool animate = true}) async{ + await Future.delayed(Duration(milliseconds: 200)); + mapCameraPosition = CameraPosition(target: location, zoom: 16.4746,); + if(animate) + (await mapController.future).animateCamera(CameraUpdate.newCameraPosition(mapCameraPosition),); + else + (await mapController.future).moveCamera(CameraUpdate.newCameraPosition(mapCameraPosition),); + } + + goToCurrentLocation() async{ + var location = await Geolocator.getLastKnownPosition(); + if(location == null){ + Geolocator.getCurrentPosition().then((value){ + moveToLocation(LatLng(value.latitude, value.longitude)); + }); + return; + } + + moveToLocation(LatLng(location.latitude, location.longitude), animate: false); + } } \ No newline at end of file diff --git a/lib/pages/ErService/rapid-response-team/rrt-request-page.dart b/lib/pages/ErService/rapid-response-team/rrt-request-page.dart index 9fb0a2f5..14a244d5 100644 --- a/lib/pages/ErService/rapid-response-team/rrt-request-page.dart +++ b/lib/pages/ErService/rapid-response-team/rrt-request-page.dart @@ -18,8 +18,8 @@ class RRTRequestPageState extends State{ @override Widget build(BuildContext context) { return BaseView( - onModelReady: (viewModel){ - + onModelReady: (viewModel) async{ + await viewModel.getRequiredData(); }, builder: (ctx, vm, widget) => Column( children: [ @@ -38,7 +38,7 @@ class RRTRequestPageState extends State{ Container( padding: EdgeInsets.only(top: 20, bottom: 5), alignment: Alignment.center, - child: Text(TranslationBase.of(context).YouCanPayByTheFollowingOptions, style: TextStyle(fontSize: 13, color: Theme.of(context).appBarTheme.color, fontWeight: FontWeight.w500), maxLines: 2) + child: Text(TranslationBase.of(context).youCanPayByTheFollowingOptions, style: TextStyle(fontSize: 13, color: Theme.of(context).appBarTheme.color, fontWeight: FontWeight.w500), maxLines: 2) ), paymentOptions(), @@ -56,7 +56,7 @@ class RRTRequestPageState extends State{ Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Text( - TranslationBase.of(context).RRTDDetails, + TranslationBase.of(context).rrtDDetails, textAlign: TextAlign.justify, style: TextStyle(color: Theme.of(context).appBarTheme.color, fontSize: 15, height: 1.5, fontWeight: FontWeight.w300), ), @@ -70,16 +70,16 @@ class RRTRequestPageState extends State{ Container( height: 30, decoration: BoxDecoration(color: Theme.of(context).appBarTheme.color, borderRadius: BorderRadius.only(topLeft: radius, topRight: radius)), - child: Center(child: Text(TranslationBase.of(context).ApproximateServiceFee, style: TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w500, letterSpacing: 1))), + child: Center(child: Text(TranslationBase.of(context).approximateServiceFee, style: TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w500, letterSpacing: 1))), ), - pricingRow(label: TranslationBase.of(context).AmountBeforeTax, value: '500 SAR'), + pricingRow(label: TranslationBase.of(context).amountBeforeTax, value: '500 SAR'), Container(height: 0.5, color: Theme.of(context).appBarTheme.color), - pricingRow(label: TranslationBase.of(context).TaxAmount, value: '50 SAR'), + pricingRow(label: TranslationBase.of(context).taxAmount, value: '50 SAR'), Container(height: 0.5, color: Theme.of(context).appBarTheme.color), - pricingRow(label: TranslationBase.of(context).TotalAmountPayable, value: '550 SAR', labelBold: true), + pricingRow(label: TranslationBase.of(context).totalAmountPayable, value: '550 SAR', labelBold: true), Container(height: 0.5, color: Theme.of(context).appBarTheme.color), ], ); diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 6610a6af..9127f582 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1158,15 +1158,15 @@ class TranslationBase { String get walker => localizedValues['walker'][locale.languageCode]; String get stretcher => localizedValues['stretcher'][locale.languageCode]; String get none => localizedValues['none'][locale.languageCode]; - String get RRTSummary => localizedValues['RRT-Summary'][locale.languageCode]; - String get RapidResponseTeam => localizedValues['Rapid-Response-Team'][locale.languageCode]; - String get RRTDDetails => localizedValues['RRTDDetails'][locale.languageCode]; - String get ApproximateServiceFee => localizedValues['ApproximateServiceFee'][locale.languageCode]; - String get AmountBeforeTax => localizedValues['AmountBeforeTax'][locale.languageCode]; - String get TaxAmount => localizedValues['TaxAmount'][locale.languageCode]; - String get TotalAmountPayable => localizedValues['TotalAmountPayable'][locale.languageCode]; + String get rrtSummary => localizedValues['RRT-Summary'][locale.languageCode]; + String get rapidResponseTeam => localizedValues['Rapid-Response-Team'][locale.languageCode]; + String get rrtDDetails => localizedValues['RRTDDetails'][locale.languageCode]; + String get approximateServiceFee => localizedValues['ApproximateServiceFee'][locale.languageCode]; + String get amountBeforeTax => localizedValues['AmountBeforeTax'][locale.languageCode]; + String get taxAmount => localizedValues['TaxAmount'][locale.languageCode]; + String get totalAmountPayable => localizedValues['TotalAmountPayable'][locale.languageCode]; String get iAcceptTermsConditions => localizedValues['iAcceptTermsConditions'][locale.languageCode]; - String get YouCanPayByTheFollowingOptions => localizedValues['YouCanPayByTheFollowingOptions'][locale.languageCode]; + String get youCanPayByTheFollowingOptions => localizedValues['YouCanPayByTheFollowingOptions'][locale.languageCode]; String get rrtService => localizedValues['rrtService'][locale.languageCode]; String get billAmount => localizedValues['bill-amount'][locale.languageCode]; String get transportMethod => diff --git a/lib/widgets/dialogs/selection-dailog.dart b/lib/widgets/dialogs/selection-dailog.dart new file mode 100644 index 00000000..a1f4c66d --- /dev/null +++ b/lib/widgets/dialogs/selection-dailog.dart @@ -0,0 +1,56 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class SelectionDialog extends StatefulWidget{ + @override + State createState() => SelectionDialogState(); + + String title; + List items; + show({@required String title, @required List items}){ + this.title = title; + } +} + +class SelectionDialogState extends State{ + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15)), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(15), + child: Text(widget.title,), + ), + + Container(height: 0.5, color: Colors.grey,), + + ListView.separated( + padding: EdgeInsets.all(10), + itemCount: widget.items.length, + itemBuilder: (ctx,idx) => item(idx), + separatorBuilder: (ctx,idx) => Container(height: 0.25, color: Colors.grey.withOpacity(0.7),)) + ], + ), + ) + ], + ); + } + + Widget item(int idx){ + var model = widget.items[idx]; + return Container( + padding: EdgeInsets.all(10), + height: 20, + color: Colors.blue, + child: Text(model.toString()), + ); + } + +} \ No newline at end of file