From 5b988dff4fde6836a6596b4a451fc4727a572be1 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Tue, 5 Oct 2021 11:15:56 +0300 Subject: [PATCH] BUG FIXES --- .../new_Home_health_care_step_one_page.dart | 4 +- .../rapid-response-team/rrt-logs-page.dart | 39 ++- .../rrt-order-list-item.dart | 224 ++++++++++++++---- .../rrt-pickup-address-page.dart | 141 +---------- .../rapid-response-team/rrt-place-order.dart | 40 ++-- .../rapid-response-team/rrt-request-page.dart | 1 + lib/pages/MyAppointments/SchedulePage.dart | 6 +- lib/widgets/app_map/google_huawei_map.dart | 75 +++--- 8 files changed, 269 insertions(+), 261 deletions(-) diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart index 3dae0fcd..c41ab952 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart @@ -66,7 +66,9 @@ class _NewHomeHealthCareStepOnePageState extends State orders; +class RRTLogPage extends StatefulWidget { + final List orders; const RRTLogPage({this.orders}); - - @override - State createState() => RRTLogPageState(); + @override + State createState() => RRTLogPageState(); } -class RRTLogPageState extends State{ +class RRTLogPageState extends State { RRTViewModel viewModel; @override Widget build(BuildContext context) { - return BaseView( - onModelReady: (vm) => viewModel = vm, - builder: (ctx, vm, widgetState){ - return ListView.builder( - itemCount: widget.orders.length, - itemBuilder: (ctx, idx) { - var order = widget.orders[idx]; - return RRTLogListItem(order, onCancel: deleteOrder); - } - ); - } - ); + onModelReady: (vm) => viewModel = vm, + builder: (ctx, vm, widgetState) { + return ListView.builder( + itemCount: widget.orders.length, + padding: EdgeInsets.all(21), + itemBuilder: (ctx, idx) { + var order = widget.orders[idx]; + return RRTLogListItem(order, onCancel: deleteOrder); + }); + }); } deleteOrder(PrescriptionsOrder order) async { GifLoaderDialogUtils.showMyDialog(context); var success = await viewModel.cancelOrder(order); GifLoaderDialogUtils.hideDialog(context); - if(success) + if (success) setState(() { widget.orders.remove(order); }); } - } - - diff --git a/lib/pages/ErService/rapid-response-team/rrt-order-list-item.dart b/lib/pages/ErService/rapid-response-team/rrt-order-list-item.dart index 565658d3..78f46185 100644 --- a/lib/pages/ErService/rapid-response-team/rrt-order-list-item.dart +++ b/lib/pages/ErService/rapid-response-team/rrt-order-list-item.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; final _item_content_seperator = Container(height: 0.25, padding: EdgeInsets.all(10), color: Colors.grey.withOpacity(0.5)); @@ -22,59 +23,188 @@ class RRTLogListItem extends StatelessWidget { ProjectViewModel projectViewModel = Provider.of(context); _context = context; localize = TranslationBase.of(context); - + int status = order.status; + String _statusDisp = projectViewModel.isArabic ? order.descriptionN : order.description; + Color _color; + if (status == 1) { + //pending + _color = Color(0xffCC9B14); + } else if (status == 2) { + //processing + _color = Color(0xff2E303A); + } else if (status == 3) { + //completed + _color = Color(0xff359846); + } else if (status == 4) { + //cancel // Rejected + _color = Color(0xffD02127); + } return Container( - padding: EdgeInsets.all(15), - margin: EdgeInsets.symmetric(horizontal: 15, vertical: 10), - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15), boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.25), spreadRadius: 1, blurRadius: 3)]), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - _contentItem(label: localize.reqId, value: order.iD.toString()), - _item_content_seperator, - _contentItem(label: localize.status, value: projectViewModel.isArabic ? order.descriptionN.toString() : order.description.toString()), //order.getStatusName(localize)), - _item_content_seperator, - _contentItem(label: localize.pickupDate, value: order.getFormattedDateTime()), - _item_content_seperator, - _contentItem(label: localize.location, value: order.getNearestProjectDescription()), - _item_content_seperator, - SizedBox(height: 10), - if (onCancel != null && order.status == 1 && order.status == 2) FractionallySizedBox(child: cancelButton()) + margin: EdgeInsets.all(5), + decoration: BoxDecoration( + color: _color, + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + boxShadow: [ + BoxShadow( + color: Color(0xff000000).withOpacity(.05), + blurRadius: 27, + offset: Offset(0, -3), + ), ], ), - ); - } - - Widget _contentItem({@required String label, String value}) { - return Container( - padding: EdgeInsets.symmetric(vertical: 10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - label, - style: TextStyle(color: Theme.of(_context).appBarTheme.color, fontSize: 9, letterSpacing: 1), - ), - SizedBox( - height: 5, + child: Container( + // decoration: containerColorRadiusLeft(Colors.white, 12), + margin: EdgeInsets.only(left: projectViewModel.isArabic ? 0 : 6, right: projectViewModel.isArabic ? 6 : 0), + padding: EdgeInsets.symmetric(vertical: 14, horizontal: 12), + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(color: Colors.white, width: 1), + borderRadius: BorderRadius.only( + bottomRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0), + topRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0), + bottomLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0), + topLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0), ), - Text( - value, - style: TextStyle(color: Theme.of(_context).appBarTheme.color, fontWeight: FontWeight.bold, fontSize: 14), - ), - ], + ), + // clipBehavior: Clip.antiAlias, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _statusDisp, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: _color, letterSpacing: -0.4, height: 16 / 10), + ), + SizedBox(height: 6), + Text( + '${TranslationBase.of(context).requestID}: ${order.iD}', + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16), + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).location + ": ", + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + ), + Expanded( + child: Text( + !projectViewModel.isArabic ? order.nearestProjectDescription.trim().toString() : order.nearestProjectDescriptionN.toString(), + style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.56), + ), + ), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + localize.pickupDate + ": ", + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + ), + Expanded( + child: Text( + order.getFormattedDateTime(), + style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.56), + ), + ), + ], + ), + ], + ), + ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + DateUtil.formatDateToDate(order.createdOn, projectViewModel.isArabic), + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.4, height: 16 / 10), + ), + SizedBox(height: 12), + if (order.status == 1 || order.status == 2) + InkWell( + onTap: () { + onCancel(order); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 8, horizontal: 14), + decoration: BoxDecoration( + color: Color(0xffD02127), + border: Border.all(color: Colors.white, width: 1), + borderRadius: BorderRadius.circular(10), + ), + child: Text( + TranslationBase.of(context).cancel_nocaps, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.4), + ), + ), + ), + ], + ), + ], + ), ), ); + + // return Container( + // padding: EdgeInsets.all(15), + // margin: EdgeInsets.symmetric(horizontal: 15, vertical: 10), + // decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15), boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.25), spreadRadius: 1, blurRadius: 3)]), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.stretch, + // children: [ + // _contentItem(label: localize.reqId, value: order.iD.toString()), + // _item_content_seperator, + // _contentItem(label: localize.status, value: projectViewModel.isArabic ? order.descriptionN.toString() : order.description.toString()), //order.getStatusName(localize)), + // _item_content_seperator, + // _contentItem(label: localize.pickupDate, value: order.getFormattedDateTime()), + // _item_content_seperator, + // _contentItem(label: localize.location, value: order.getNearestProjectDescription()), + // _item_content_seperator, + // SizedBox(height: 10), + // if (order.status == 1 || order.status == 2) Container(child: cancelButton()) + // ], + // ), + // ); } - Widget cancelButton() => MaterialButton( - height: 45, - color: Color(0xFFc5272d), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), - onPressed: () => onCancel(order), - child: Text( - localize.cancel, - style: TextStyle(color: Colors.white, fontSize: 13), - ), - ); + // Widget _contentItem({@required String label, String value}) { + // return Container( + // padding: EdgeInsets.symmetric(vertical: 10), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // label, + // style: TextStyle(color: Theme.of(_context).appBarTheme.color, fontSize: 9, letterSpacing: 1), + // ), + // SizedBox( + // height: 5, + // ), + // Text( + // value, + // style: TextStyle(color: Theme.of(_context).appBarTheme.color, fontWeight: FontWeight.bold, fontSize: 14), + // ), + // ], + // ), + // ); + // } + + // Widget cancelButton() => MaterialButton( + // height: 45, + // color: Color(0xFFc5272d), + // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + // onPressed: () => onCancel(order), + // child: Text( + // localize.cancel, + // style: TextStyle(color: Colors.white, fontSize: 13), + // ), + // ); } 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 d265bdce..b3d6e805 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 @@ -53,21 +53,21 @@ class RRTRequestPickupAddressPageState extends State addressStream; StreamController addressLoadingStreamController = StreamController(); Stream addressLoadingStream; - AddressInfo _selectedAddress; + // AddressInfo _selectedAddress; double latitude = 0; double longitude = 0; AppMap appMap; bool showCurrentLocation = false; @override void initState() { - super.initState(); goToCurrentLocation(); + super.initState(); + // addressStream = addressStreamController.stream; // addressLoadingStream = addressLoadingStreamController.stream; } setLatitudeAndLongitude({bool isSetState = false, String latLong}) async { - print("latLong " + latLong.toString()); if (latLong == null) { if (myAddresses.isEmpty) { setState(() { @@ -86,7 +86,6 @@ class RRTRequestPickupAddressPageState extends State( - // stream: addressStream, - // builder: (context, snapshot) { - // return selectAddressField(); - // }), - // StreamBuilder( - // stream: addressLoadingStream, - // builder: (context, snapshot) { - // return snapshot.hasData - // ? LinearProgressIndicator(backgroundColor: Colors.transparent) - // : Container( - // height: 4, - // ); - // }), - // Expanded( - // child: PlacePicker( - // apiKey: GOOGLE_API_KEY, - // enableMyLocationButton: true, - // automaticallyImplyAppBarLeading: false, - // autocompleteOnTrailingWhitespace: true, - // selectInitialPosition: true, - // autocompleteLanguage: projectViewModel.currentLanguage, - // enableMapTypeButton: true, - // searchForInitialValue: false, - // selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) { - // if (state == SearchingState.Idle) { - // addressLoadingStreamController.sink.add(null); - // if (selectedPlace != null) { - // var loc = selectedPlace.geometry.location; - // var address1 = selectedPlace.addressComponents.first.longName; - // var address2 = ""; - // if (selectedPlace.addressComponents.length > 1) address2 = selectedPlace.addressComponents[1].longName; - - // selectedAddress = Addresses(latLong: '${loc.lat},${loc.lng}', address1: address1, address2: address2); - // addressStreamController.sink.add(0); - // } - // } else { - // addressLoadingStreamController.sink.add(0); - // } - // return Container(); - // }, - // initialPosition: LatLng(24.7114693, 46.67469582), - // useCurrentLocation: false, - // ), - // ), - // continueButton() - // ], - // ) - - )); + ))); } void _updatePosition(CameraPosition _position) { latitude = _position.target.latitude; longitude = _position.target.longitude; - selectedAddress = AddressInfo(latLong: '${latitude},${longitude}', address1: "", address2: ""); } Widget centerTargetPoint() { @@ -296,30 +240,6 @@ class RRTRequestPickupAddressPageState extends State 1) { - // var cordinates = itm.latLong.split(','); - // var latlng = LatLng(double.parse(cordinates.first), double.parse(cordinates.last)); - // //moveToLocation(latlng); - // } else { - // AppToast.showErrorToast(message: 'Invalid address coordinates'); - // } - // }); - // }, - // ); - // }, - // separatorBuilder: (ctx, idx) => Container( - // height: 0.25, - // color: Colors.grey.withOpacity(0.7), - // ))); - // } - void confirmSelectLocationDialog(List addresses) { showDialog( context: context, child: SelectLocationDialog( addresses: addresses, - selectedAddress: _selectedAddress, + selectedAddress: selectedAddress, onValueSelected: (value) { showCurrentLocation = false; setLatitudeAndLongitude(latLong: value.latLong); setState(() { - _selectedAddress = value; + selectedAddress = value; }); }, ), @@ -388,8 +274,8 @@ class RRTRequestPickupAddressPageState extends State { var orders = widget.pendingOrders; return ListView.builder( itemCount: orders.length, + padding: EdgeInsets.all(21), itemBuilder: (ctx, idx) { var order = orders[idx]; return RRTLogListItem(order, onCancel: deleteOrder); diff --git a/lib/pages/MyAppointments/SchedulePage.dart b/lib/pages/MyAppointments/SchedulePage.dart index 5e7e478b..133f9a56 100644 --- a/lib/pages/MyAppointments/SchedulePage.dart +++ b/lib/pages/MyAppointments/SchedulePage.dart @@ -19,6 +19,7 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:provider/provider.dart'; +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; class SchedulePage extends StatefulWidget { DoctorList doctorList; @@ -61,11 +62,14 @@ class _SchedulePageState extends State { onModelReady: (model2) => model2.getFreeSlots(doctorList), allowAny: true, builder: (_, model2, widget2) { - if (model.freeSlots.length > 0 && isPageChange == false) { + if (model.freeSlots.length > 0 && isPageChange == false && model.state == ViewState.Idle) { this.freeSlots = model.freeSlots; this.doctorScheduleResponse = model.getDoctorScheduleList; this.generateWeeksSchedules(); + } else if (model.freeSlots.length == 0 && model.state == ViewState.Idle) { + AppToast.showErrorToast(message: TranslationBase.of(context).emptySchedule); + Navigator.pop(context); } return AppScaffold( appBarTitle: TranslationBase.of(context).schedule, diff --git a/lib/widgets/app_map/google_huawei_map.dart b/lib/widgets/app_map/google_huawei_map.dart index fe991ad8..dfcc187d 100644 --- a/lib/widgets/app_map/google_huawei_map.dart +++ b/lib/widgets/app_map/google_huawei_map.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter/cupertino.dart'; @@ -7,8 +6,7 @@ import 'package:flutter_hms_gms_availability/flutter_hms_gms_availability.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:huawei_map/map.dart' as hmsMap; - -class AppMap extends StatefulWidget{ +class AppMap extends StatefulWidget { CameraPositionCallback onCameraMove; Map initialCamera; @@ -17,22 +15,20 @@ class AppMap extends StatefulWidget{ AppMap(this.initialCamera, {this.onCameraMove}); @override - State createState() => _state = AppMapState(); - + State createState() => _state = AppMapState(); - moveTo({@required CameraPosition cameraPostion}){ - if(_state.isHuawei){ + moveTo({@required CameraPosition cameraPostion}) { + if (_state.isHuawei) { final cameraJson = cameraPostion.toMap(); final camera = hmsMap.CameraPosition.fromMap(cameraJson); _state._huaweiMapController.animateCamera(hmsMap.CameraUpdate.newCameraPosition(camera)); - }else{ + } else { _state.googleMapController.animateCamera(CameraUpdate.newCameraPosition(cameraPostion)); } } } -class AppMapState extends State{ - +class AppMapState extends State { bool isHuawei; Completer _googleMapControllerComp = Completer(); @@ -41,10 +37,11 @@ class AppMapState extends State{ Completer _huaweiMapControllerComp = Completer(); hmsMap.HuaweiMapController _huaweiMapController; - checkIsHuawei() async{ + checkIsHuawei() async { isHuawei = await FlutterHmsGmsAvailability.isHmsAvailable; setState(() {}); } + @override void initState() { checkIsHuawei(); @@ -52,43 +49,39 @@ class AppMapState extends State{ @override Widget build(BuildContext context) { - if(isHuawei == null) - return CircularProgressIndicator(); + if (isHuawei == null) return CircularProgressIndicator(); return map(); } Widget map() => isHuawei ? huaweiMap() : googleMap(); - - googleMap(){ - return - GoogleMap( - mapType: MapType.normal, - zoomControlsEnabled: false, - myLocationButtonEnabled: true, - myLocationEnabled: true, - initialCameraPosition: CameraPosition.fromMap(widget.initialCamera), - onCameraMove: widget.onCameraMove, - onMapCreated: (GoogleMapController controller) { - googleMapController = controller; - _googleMapControllerComp.complete(controller); - }, - ); + googleMap() { + return GoogleMap( + mapType: MapType.normal, + zoomControlsEnabled: false, + myLocationButtonEnabled: true, + myLocationEnabled: true, + initialCameraPosition: CameraPosition.fromMap(widget.initialCamera), + onCameraMove: widget.onCameraMove, + onMapCreated: (GoogleMapController controller) { + googleMapController = controller; + _googleMapControllerComp.complete(controller); + }, + ); } - Widget huaweiMap(){ + Widget huaweiMap() { return hmsMap.HuaweiMap( - mapType: hmsMap.MapType.normal, - zoomControlsEnabled: false, - myLocationButtonEnabled: true, - myLocationEnabled: true, - initialCameraPosition: hmsMap.CameraPosition.fromMap(widget.initialCamera), - onCameraMove: (camera) => widget.onCameraMove(CameraPosition.fromMap(camera.toMap())), - onMapCreated: (controller){ - _huaweiMapController = controller; - _huaweiMapControllerComp .complete(controller); - }, + mapType: hmsMap.MapType.normal, + zoomControlsEnabled: false, + myLocationButtonEnabled: true, + myLocationEnabled: true, + initialCameraPosition: hmsMap.CameraPosition.fromMap(widget.initialCamera), + onCameraMove: (camera) => widget.onCameraMove(CameraPosition.fromMap(camera.toMap())), + onMapCreated: (controller) { + _huaweiMapController = controller; + _huaweiMapControllerComp.complete(controller); + }, ); } - -} \ No newline at end of file +}