diff --git a/assets/images/png/ambulance_section.png b/assets/images/png/ambulance_section.png new file mode 100644 index 00000000..62ca1716 Binary files /dev/null and b/assets/images/png/ambulance_section.png differ diff --git a/assets/images/png/rrt_section.png b/assets/images/png/rrt_section.png new file mode 100644 index 00000000..b28d5993 Binary files /dev/null and b/assets/images/png/rrt_section.png differ diff --git a/lib/core/app_assets.dart b/lib/core/app_assets.dart index 8c57598e..37683ecc 100644 --- a/lib/core/app_assets.dart +++ b/lib/core/app_assets.dart @@ -400,6 +400,11 @@ class AppAssets { static const String fullBodyFrontFemale = '$pngBasePath/full_body_front_female.png'; static const String fullBodyBackFemale = '$pngBasePath/full_body_back_female.png'; static const String bmiFullBody = '$pngBasePath/bmi_image_1.png'; + + + + static const String ambulance_section = '$pngBasePath/ambulance_section.png'; + static const String rrt_section = '$pngBasePath/rrt_section.png'; } class AppAnimations { diff --git a/lib/core/utils/utils.dart b/lib/core/utils/utils.dart index ac7af39d..8929c7f5 100644 --- a/lib/core/utils/utils.dart +++ b/lib/core/utils/utils.dart @@ -820,6 +820,28 @@ class Utils { // return Image.asset(icon, width: width, height: height, fit: fit, ); } + static Widget buildImgWithAssetsWithBorderRadius({ + required String icon, + Color? iconColor, + bool isDisabled = false, + double? width, + double? height, + BoxFit fit = BoxFit.cover, + double? border, + double? borderRadius, + }) { + final iconH = height ?? 24.h; + final iconW = width ?? 24.w; + return Container( + width: iconW, height: iconH, + decoration: BoxDecoration( + border: border != null ? Border.all(color: AppColors.whiteColor, width: border) : null, + borderRadius: borderRadius != null ? BorderRadius.circular(borderRadius ?? 12.r) : null, + image: DecorationImage(image: AssetImage(icon,), fit: fit) + ), + ); + } + /// Widget to build an SVG from network static Widget buildImgWithNetwork({ required String url, diff --git a/lib/features/emergency_services/emergency_services_view_model.dart b/lib/features/emergency_services/emergency_services_view_model.dart index 8c2dd6ba..255f4892 100644 --- a/lib/features/emergency_services/emergency_services_view_model.dart +++ b/lib/features/emergency_services/emergency_services_view_model.dart @@ -310,17 +310,21 @@ class EmergencyServicesViewModel extends ChangeNotifier { } void updateBottomSheetState(BottomSheetType sheetType) { - if (sheetType == BottomSheetType.EXPANDED && selectedHospital == null) { - dialogService.showErrorBottomSheet(message: LocaleKeys.selectHospital.tr()); - return; - } + // if (sheetType == BottomSheetType.EXPANDED && selectedHospital == null) { + // dialogService.showErrorBottomSheet(message: LocaleKeys.selectHospital.tr()); + // return; + // } bottomSheetType = sheetType; - if (sheetType == BottomSheetType.EXPANDED) { - clearAppointmentData(); - } + // if (sheetType == BottomSheetType.FIXED) { + // clearAppointmentData(); + // } notifyListeners(); } + void showError(String message) { + dialogService.showErrorBottomSheet(message: message); + } + void setIsGMSAvailable(bool value) { notifyListeners(); } @@ -732,6 +736,10 @@ class EmergencyServicesViewModel extends ChangeNotifier { } FutureOr submitAmbulanceRequest(GeocodeResult? result, PlaceDetails? place, PlacePrediction? placePrediction) async { + if (false == haveAnAppointment && null == selectedHospital) { + dialogService.showErrorBottomSheet(message: LocaleKeys.selectHospital.tr()); + return; + } PatientER_RC request = createRequest(result, place, placePrediction); navServices.push(CustomPageRoute(page: RequestingServicesPage())); @@ -802,19 +810,19 @@ class EmergencyServicesViewModel extends ChangeNotifier { request.patientERTransportationMethod = selectedTransportOption; transportationDetails.pickupUrgency = 1; switch (callingPlace) { - case AmbulanceCallingPlace.FROM_HOSPITAL: - transportationDetails.dropoffLatitude = selectedHospital!.latitude; - transportationDetails.dropoffLongitude = selectedHospital!.longitude; - transportationDetails.dropoffLocationName = selectedHospital!.name; + case AmbulanceCallingPlace.TO_HOSPITAL: + transportationDetails.dropoffLatitude = selectedHospital?.latitude; + transportationDetails.dropoffLongitude = selectedHospital?.longitude; + transportationDetails.dropoffLocationName = selectedHospital?.name; transportationDetails.pickupLatitude = ((result?.geometry.location.lat) ?? place?.lat)?.toStringAsFixed(6); transportationDetails.pickupLongitude = ((result?.geometry.location.lng) ?? place?.lng)?.toStringAsFixed(6); transportationDetails.pickupLocationName = result?.formattedAddress ?? placePrediction?.description; transportationDetails.direction = 1; break; - case AmbulanceCallingPlace.TO_HOSPITAL: - transportationDetails.pickupLatitude = selectedHospital!.latitude; - transportationDetails.pickupLongitude = selectedHospital!.longitude; - transportationDetails.pickupLocationName = selectedHospital!.name; + case AmbulanceCallingPlace.FROM_HOSPITAL: + transportationDetails.pickupLatitude = selectedHospital?.latitude; + transportationDetails.pickupLongitude = selectedHospital?.longitude; + transportationDetails.pickupLocationName = selectedHospital?.name; transportationDetails.dropoffLatitude = ((result?.geometry.location.lat) ?? place?.lat)?.toStringAsFixed(6); transportationDetails.dropoffLongitude = ((result?.geometry.location.lng) ?? place?.lng)?.toStringAsFixed(6); transportationDetails.dropoffLocationName = result?.formattedAddress ?? placePrediction?.description; diff --git a/lib/presentation/emergency_services/call_ambulance/call_ambulance_page.dart b/lib/presentation/emergency_services/call_ambulance/call_ambulance_page.dart index 55958048..3ac19814 100644 --- a/lib/presentation/emergency_services/call_ambulance/call_ambulance_page.dart +++ b/lib/presentation/emergency_services/call_ambulance/call_ambulance_page.dart @@ -53,8 +53,8 @@ class CallAmbulancePage extends StatelessWidget { ExpandableBottomSheet( bottomSheetType: context.watch().bottomSheetType, children: { - BottomSheetType.EXPANDED: ExpanedBottomSheet(context), - BottomSheetType.FIXED: FixedBottomSheet(context), + BottomSheetType.EXPANDED: ExpandedBottomSheet(context), + BottomSheetType.FIXED: pickUpDetailAndAppointementSection(context), }, ), ], @@ -92,7 +92,7 @@ class CallAmbulancePage extends StatelessWidget { ); } - Widget FixedBottomSheet(BuildContext context) { + Widget ExpandedBottomSheet(BuildContext context) { return GestureDetector( onVerticalDragUpdate: (details) { // if(details.delta.dy<0){ @@ -172,7 +172,11 @@ class CallAmbulancePage extends StatelessWidget { CustomButton( text: LocaleKeys.selectDetails.tr(context: context), onPressed: () { - context.read().updateBottomSheetState(BottomSheetType.EXPANDED); + LocationViewModel locationViewModel = context.read(); + GeocodeResponse? response = locationViewModel.geocodeResponse; + PlaceDetails? placeDetails = locationViewModel.placeDetails; + PlacePrediction? placePrediction = locationViewModel.selectedPrediction; + context.read().submitAmbulanceRequest(response?.results.first, placeDetails, placePrediction); }) ], ).paddingOnly(top: 24.h, bottom: 32.h, left: 24.h, right: 24.h), @@ -185,7 +189,7 @@ class CallAmbulancePage extends StatelessWidget { ); } - Widget ExpanedBottomSheet(BuildContext context) { + Widget pickUpDetailAndAppointementSection(BuildContext context) { return GestureDetector( onVerticalDragUpdate: (details) { if (details.delta.dy > 0) { @@ -324,28 +328,34 @@ class CallAmbulancePage extends StatelessWidget { ) ], ), + if(AmbulanceCallingPlace.TO_HOSPITAL == context.read().callingPlace) + Row( + children: [ + hospitalAndPickUpItemContent( + title: LocaleKeys.appointment.tr(context: context), + subTitle: LocaleKeys.haveAnyAppointment.tr(context: context), + leadingIcon: AppAssets.appointment_calendar_icon, + ), + CustomSwitch( + value: context.watch().haveAnAppointment, + onChanged: (value) async { + // if (value) { + // openAppointmentList(context); + // } + await context.read().updateAppointment(value); + if (context.read().appointments?.isNotEmpty == true) { + openAppointmentList(context); + } + }, + ) + ], + ), - Row( - children: [ - hospitalAndPickUpItemContent( - title: LocaleKeys.appointment.tr(context: context), - subTitle: LocaleKeys.haveAnyAppointment.tr(context: context), - leadingIcon: AppAssets.appointment_calendar_icon, - ), - CustomSwitch( - value: context.watch().haveAnAppointment, - onChanged: (value) async { - // if (value) { - // openAppointmentList(context); - // } - await context.read().updateAppointment(value); - if (context.read().appointments?.isNotEmpty == true) { - openAppointmentList(context); - } - }, - ) - ], - ), + + // Visibility( + // visible: , + // child: + // ), ], ).paddingAll(16.h), ); @@ -460,12 +470,8 @@ class CallAmbulancePage extends StatelessWidget { CustomButton( text: LocaleKeys.submitRequest.tr(context: context), onPressed: () { - LocationViewModel locationViewModel = context.read(); - GeocodeResponse? response = locationViewModel.geocodeResponse; - PlaceDetails? placeDetails = locationViewModel.placeDetails; - PlacePrediction? placePrediction = locationViewModel.selectedPrediction; - context.read().submitAmbulanceRequest(response?.results.first, placeDetails, placePrediction); - }) + context.read().updateBottomSheetState(BottomSheetType.EXPANDED); + }) ], ).paddingOnly(top: 24.h, bottom: 12.h, left: 24.h, right: 24.h), ), @@ -582,21 +588,24 @@ class CallAmbulancePage extends StatelessWidget { } hospitalField(BuildContext context) { - return DecoratedBox( - decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 12.h), - child: Row( - children: [ - hospitalAndPickUpItemContent( - title: LocaleKeys.selectHospital.tr(context: context), - subTitle: context.read().getSelectedHospitalName() ?? LocaleKeys.selectHospital.tr(context: context), - leadingIcon: AppAssets.hospital, - ), - Utils.buildSvgWithAssets(icon: AppAssets.down_cheveron, width: 24.h, height: 24.h).paddingAll(16.h) - ], - ).onPress(() { - showHospitalBottomSheet(context); - }).paddingSymmetrical( - 10.w, 12.h), + return Visibility( + visible: false == context.watch().haveAnAppointment, + child: DecoratedBox( + decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 12.h), + child: Row( + children: [ + hospitalAndPickUpItemContent( + title: LocaleKeys.selectHospital.tr(context: context), + subTitle: context.read().getSelectedHospitalName() ?? LocaleKeys.selectHospital.tr(context: context), + leadingIcon: AppAssets.hospital, + ), + Utils.buildSvgWithAssets(icon: AppAssets.down_cheveron, width: 24.h, height: 24.h).paddingAll(16.h) + ], + ).onPress(() { + showHospitalBottomSheet(context); + }).paddingSymmetrical( + 10.w, 12.h), + ), ); } diff --git a/lib/presentation/emergency_services/call_ambulance/tracking_screen.dart b/lib/presentation/emergency_services/call_ambulance/tracking_screen.dart index 0f4c587b..7c7f5db6 100644 --- a/lib/presentation/emergency_services/call_ambulance/tracking_screen.dart +++ b/lib/presentation/emergency_services/call_ambulance/tracking_screen.dart @@ -73,7 +73,10 @@ class TrackingScreen extends StatelessWidget { child: SingleChildScrollView( child: Column( children: [ - animationSection(), + Padding( + padding: EdgeInsetsDirectional.only(top:16.h,start: 16.w,end: 16.w ), + child: animationSection(context), + ), Column( spacing: 16.h, children: [orderStatus(context), orderTrackingId(context), contactSection()], @@ -83,12 +86,12 @@ class TrackingScreen extends StatelessWidget { ); } - animationSection() { + animationSection(BuildContext context) { switch (state) { case OrderTrackingState.waitingForCall: case OrderTrackingState.dispactched: case OrderTrackingState.returning: - return Lottie.asset(AppAnimations.ambulance, repeat: true, reverse: false, width: 260.h, height: 200.h); + return showImage(order != null ? AppAssets.ambulance_section : AppAssets.rrt_section, context); case OrderTrackingState.ended: return Lottie.asset(AppAnimations.checkmark, repeat: true, width: 260.h, height: 200.h); case OrderTrackingState.failed: @@ -489,6 +492,18 @@ class TrackingScreen extends StatelessWidget { ); } + showImage(String imageUrl, BuildContext context) { + return Utils.buildImgWithAssetsWithBorderRadius( + icon: imageUrl, + iconColor: Colors.transparent, + width: MediaQuery.sizeOf(context).width, + height: 380.h, + borderRadius: 24.r, + border: 1.r/// did this as the function that is being called is wrongly coupled with the border radius and border, and in some cases like the ambulance and rrt section we don't need any + /// border or border radius + ); + } + // Widget rrtOrderData() { // return Row( // spacing: 8.h, diff --git a/lib/widgets/order_tracking/request_tracking.dart b/lib/widgets/order_tracking/request_tracking.dart index f07c0b19..519a41c2 100644 --- a/lib/widgets/order_tracking/request_tracking.dart +++ b/lib/widgets/order_tracking/request_tracking.dart @@ -26,12 +26,7 @@ class OrderTrackingWidget extends StatelessWidget { Widget? getBarAndDot(OrderTrackingState? state, BuildContext context, double width) { - print("the parent padding value is $parentPaddingValue"); - print("the parent padding value is ${(parentPaddingValue+24)}"); - print("the width - (parentPaddingValue+24) ${(width - (parentPaddingValue+24))}"); double widthOfOneState = (width/4) - (parentPaddingValue+8.h); - print("te width of one state is $widthOfOneState"); - print("the value of${width/4}"); if(state == null) { return Row( children: List.generate(4, (index) {