@ -2,6 +2,7 @@ import 'dart:io';
import ' package:easy_localization/easy_localization.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:google_places_flutter/model/prediction.dart ' ;
import ' package:hmg_patient_app_new/core/app_assets.dart ' ;
import ' package:hmg_patient_app_new/core/app_export.dart ' ;
import ' package:hmg_patient_app_new/core/utils/utils.dart ' ;
@ -26,39 +27,37 @@ import 'package:provider/provider.dart';
import ' ../../../widgets/common_bottom_sheet.dart ' ;
import ' widgets/AddressItem.dart ' ;
class CallAmbulancePage extends StatelessWidget {
class CallAmbulancePage extends StatefulWidget {
bool ? isFromRRT ;
CallAmbulancePage ( { super . key , this . isFromRRT = false } ) ;
@ override
State < CallAmbulancePage > createState ( ) = > _CallAmbulancePageState ( ) ;
}
class _CallAmbulancePageState extends State < CallAmbulancePage > {
TextEditingController addressController = TextEditingController ( ) ;
@ override
Widget build ( BuildContext context ) {
return Scaffold (
bottomSheet: ExpandableBottomSheet (
bottomSheetType:
context . watch < EmergencyServicesViewModel > ( ) . bottomSheetType ,
bottomSheetType: context . watch < EmergencyServicesViewModel > ( ) . bottomSheetType ,
children: {
BottomSheetType . EXPANDED: ExpanedBottomSheet ( context ) ,
BottomSheetType . FIXED: FixedBottomSheet ( context ) ,
BottomSheetType . EXPANDED: expand edBottomSheet( context ) ,
BottomSheetType . FIXED: f ixedBottomSheet( context ) ,
} ,
) ,
body: Stack (
children: [
if ( context . read < EmergencyServicesViewModel > ( ) . isGMSAvailable | |
Platform . isIOS )
GMSMap (
currentLocation:
context . read < EmergencyServicesViewModel > ( ) . getGMSLocation ( ) ,
onCameraMoved: ( value ) = > context
. read < EmergencyServicesViewModel > ( )
. handleGMSMapCameraMoved ( value ) )
if ( context . read < EmergencyServicesViewModel > ( ) . isGMSAvailable | | Platform . isIOS )
GMSMap ( currentLocation: context . read < EmergencyServicesViewModel > ( ) . getGMSLocation ( ) , onCameraMoved: ( value ) = > context . read < EmergencyServicesViewModel > ( ) . handleGMSMapCameraMoved ( value ) )
else
HMSMap (
currentLocation:
context . read < EmergencyServicesViewModel > ( ) . getHMSLocation ( ) ,
onCameraMoved: ( value ) = > context
. read < EmergencyServicesViewModel > ( )
. handleHMSMapCameraMoved ( value ) ) ,
HMSMap ( currentLocation: context . read < EmergencyServicesViewModel > ( ) . getHMSLocation ( ) , onCameraMoved: ( value ) = > context . read < EmergencyServicesViewModel > ( ) . handleHMSMapCameraMoved ( value ) ) ,
Align (
alignment: AlignmentDirectional . topStart ,
child: Utils . buildSvgWithAssets (
icon: AppAssets . closeBottomNav , width: 32. h , height: 32. h ) ,
child: Utils . buildSvgWithAssets ( icon: AppAssets . closeBottomNav , width: 32. h , height: 32. h ) ,
) . paddingOnly ( top: 51. h , left: 24. h ) . onPress ( ( ) {
Navigator . pop ( context ) ;
} )
@ -67,13 +66,12 @@ class CallAmbulancePage extends StatelessWidget {
) ;
}
Widget F ixedBottomSheet( BuildContext context ) {
Widget f ixedBottomSheet( BuildContext context ) {
return GestureDetector (
onVerticalDragUpdate: ( details ) {
print ( " the delta is ${ details . delta . dy } " ) ;
if ( details . delta . dy < 0 ) {
context . read < EmergencyServicesViewModel > ( ) . updateBottomSheetState ( BottomSheetType . EXPANDED ) ;
}
} ,
@ -85,14 +83,10 @@ class CallAmbulancePage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment . end ,
children: [
Padding (
padding: EdgeInsetsDirectional . only ( end: 24. h , bottom: 24. h ) ,
child: DecoratedBox (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor , borderRadius: 12. h ) ,
child: Utils . buildSvgWithAssets (
icon: AppAssets . locate_me , width: 24. h , height: 24. h )
. paddingAll ( 12. h ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration ( color: AppColors . whiteColor , borderRadius: 12. h ) ,
child: Utils . buildSvgWithAssets ( icon: AppAssets . locate_me , width: 24. h , height: 24. h ) . paddingAll ( 12. h ) ,
) ,
) ,
] ,
@ -117,8 +111,8 @@ class CallAmbulancePage extends StatelessWidget {
spacing: 24. h ,
children: [
TextInputWidget (
labelText: " Enter Pickup Location Manually " . needTranslation ,
hintText: " Enter Pickup Location " . needTranslation ,
labelText: widget . isFromRRT ! ? " Type Address " . needTranslation : " Enter Pickup Location Manually " . needTranslation ,
hintText: widget . isFromRRT ! ? " Enter street or area name " . needTranslation : " Enter Pickup Location " . needTranslation ,
leadingIcon: AppAssets . location_pickup ,
isAllowLeadingIcon: true ,
isEnable: false ,
@ -126,50 +120,27 @@ class CallAmbulancePage extends StatelessWidget {
autoFocus: false ,
isBorderAllowed: false ,
keyboardType: TextInputType . text ,
padding: EdgeInsets . symmetric (
vertical: ResponsiveExtension ( 10 ) . h ,
horizontal: ResponsiveExtension ( 15 ) . h ,
) ,
) . onPress ( ( ) {
context
. read < EmergencyServicesViewModel > ( )
. updateBottomSheetState ( BottomSheetType . EXPANDED ) ;
} ) . paddingOnly ( right: 24. h , left: 24. h ) ,
controller: addressController ,
padding: EdgeInsets . symmetric ( vertical: ResponsiveExtension ( 8 ) . h , horizontal: ResponsiveExtension ( 12 ) . h ) ,
) . paddingOnly ( right: 24. h , left: 24. h ) ,
SizedBox (
height: 200. h ,
child: DecoratedBox (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . scaffoldBgColor ,
customBorder: BorderRadius . only (
topLeft: Radius . circular ( 24. h ) ,
topRight: Radius . circular ( 24. h ) ,
) ,
customBorder: BorderRadius . only ( topLeft: Radius . circular ( 24. h ) , topRight: Radius . circular ( 24. h ) ) ,
) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
spacing: 24. h ,
children: [
Column (
spacing: 4. h ,
spacing: 4 ,
children: [
" Select Pickup Location " . needTranslation . toText21 (
weight: FontWeight . w600 ,
color: AppColors . textColor ,
) ,
" Please select the location of pickup "
. needTranslation
. toText12 (
fontWeight: FontWeight . w500 ,
color: AppColors . greyTextColor ,
)
] ,
) ,
" Select Pickup Location " . needTranslation . toText21 ( weight: FontWeight . w600 , color: AppColors . textColor ) ,
" Please select the location of pickup " . needTranslation . toText12 ( fontWeight: FontWeight . w500 , color: AppColors . greyTextColor ) ,
SizedBox ( height: 20. h ) ,
CustomButton (
text: " Select Location " . needTranslation ,
onPressed: ( ) {
context
. read < EmergencyServicesViewModel > ( )
. updateBottomSheetState ( BottomSheetType . EXPANDED ) ;
context . read < EmergencyServicesViewModel > ( ) . updateBottomSheetState ( BottomSheetType . EXPANDED ) ;
} )
] ,
) . paddingOnly ( top: 24. h , bottom: 32. h , left: 24. h , right: 24. h ) ,
@ -182,7 +153,7 @@ class CallAmbulancePage extends StatelessWidget {
) ;
}
Widget Expan edBottomSheet( BuildContext context ) {
Widget expand edBottomSheet( BuildContext context ) {
return GestureDetector (
onVerticalDragUpdate: ( details ) {
if ( details . delta . dy > 0 ) {
@ -195,10 +166,7 @@ class CallAmbulancePage extends StatelessWidget {
DecoratedBox (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . scaffoldBgColor ,
customBorder: BorderRadius . only (
topLeft: Radius . circular ( 24. h ) ,
topRight: Radius . circular ( 24. h ) ,
) ,
customBorder: BorderRadius . only ( topLeft: Radius . circular ( 24. h ) , topRight: Radius . circular ( 24. h ) ) ,
) ,
child: Column (
children: [
@ -207,17 +175,12 @@ class CallAmbulancePage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment . start ,
spacing: 16. h ,
children: [
" Select Pickup Location " . needTranslation . toText21 (
weight: FontWeight . w600 ,
color: AppColors . textColor ,
) ,
" Select Pickup Location " . needTranslation . toText21 ( weight: FontWeight . w600 , color: AppColors . textColor ) ,
locationsSections ( context ) ,
hospitalAndPickUpSection ( context ) ,
widget . isFromRRT ! ? SizedBox ( ) : hospitalAndPickUpSection ( context ) ,
] ,
) . paddingOnly ( top: 24. h , bottom: 32. h , left: 24. h , right: 24. h ) ,
) ,
bottomPriceContent ( context )
] ,
) ,
@ -249,8 +212,7 @@ class CallAmbulancePage extends StatelessWidget {
shrinkWrap: true ,
itemCount: 3 ,
itemBuilder: ( __ , index ) {
if ( index = =
2 ) / / todo means the end of the list so handle as per the viewmodel
if ( index = = 2 ) / / todo means the end of the list so handle as per the viewmodel
{
return CustomButton (
height: 40. h ,
@ -264,11 +226,8 @@ class CallAmbulancePage extends StatelessWidget {
} else {
return AddressItem (
isSelected: index = = 0 ,
address:
" Flat No 301, Building No 12, Palm Spring Apartment, Sector 45, Gurugram, Haryana 122003 " ,
title: index = = 0
? " Home " . needTranslation
: " Work " . needTranslation ,
address: " Flat No 301, Building No 12, Palm Spring Apartment, Sector 45, Gurugram, Haryana 122003 " ,
title: index = = 0 ? " Home " . needTranslation : " Work " . needTranslation ,
onTap: ( ) { } ,
) ;
}
@ -293,9 +252,7 @@ class CallAmbulancePage extends StatelessWidget {
subTitle: " hospital " . needTranslation ,
leadingIcon: AppAssets . hospital ,
) ,
Utils . buildSvgWithAssets ( icon: AppAssets . down_cheveron ,
width: 24. h , height: 24. h )
. paddingAll ( 16. h )
Utils . buildSvgWithAssets ( icon: AppAssets . down_cheveron , width: 24. h , height: 24. h ) . paddingAll ( 16. h )
] ,
) . onPress ( ( ) {
showHospitalBottomSheet ( context ) ;
@ -307,7 +264,6 @@ class CallAmbulancePage extends StatelessWidget {
thickness: 1 ,
) ,
SizedBox ( height: 16. h ) ,
Row (
children: [
hospitalAndPickUpItemContent (
@ -379,14 +335,8 @@ class CallAmbulancePage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment . end ,
children: [
DecoratedBox (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . scaffoldBgColor ,
customBorder: BorderRadius . only (
topLeft: Radius . circular ( 24. h ) ,
topRight: Radius . circular ( 24. h ) ,
) ,
hasShadow: true
) ,
decoration: RoundedRectangleBorder ( )
. toSmoothCornerDecoration ( color: AppColors . scaffoldBgColor , customBorder: BorderRadius . only ( topLeft: Radius . circular ( 24. h ) , topRight: Radius . circular ( 24. h ) ) , hasShadow: true ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
spacing: 12. h ,
@ -398,30 +348,18 @@ class CallAmbulancePage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment . start ,
spacing: 4. h ,
children: [
" Total amount to pay " . needTranslation . toText18 (
weight: FontWeight . w600 ,
color: AppColors . textColor ,
) ,
" Total amount to pay " . needTranslation . toText18 ( weight: FontWeight . w600 , color: AppColors . textColor ) ,
Row (
children: [
Utils . buildSvgWithAssets ( icon: AppAssets . warning ,
height: 18. h , width: 18. h ) ,
SizedBox ( width: 4. h , ) ,
" Amount will be paid at the hospital "
. needTranslation
. toText12 (
fontWeight: FontWeight . w500 ,
color: AppColors . greyTextColor ,
) ,
Utils . buildSvgWithAssets ( icon: AppAssets . warning , height: 18. h , width: 18. h ) ,
SizedBox ( width: 4. h ) ,
" Amount will be paid at the hospital " . needTranslation . toText12 ( fontWeight: FontWeight . w500 , color: AppColors . greyTextColor ) ,
] ,
)
] ,
) ,
) ,
" \$ 250 " . toText24 (
fontWeight: FontWeight . w600 ,
color: AppColors . textColor ,
)
Utils . getPaymentAmountWithSymbol ( " 250 " . toString ( ) . toText24 ( isBold: true ) , AppColors . blackColor , 17 , isSaudiCurrency: true ) ,
] ,
) ,
CustomButton (
@ -430,7 +368,7 @@ class CallAmbulancePage extends StatelessWidget {
Navigator . push ( context , CustomPageRoute ( page: RequestingServicesPage ( ) ) ) ;
} )
] ,
) . paddingOnly ( top: 24. h , bottom: 1 2.h , left: 24. h , right: 24. h ) ,
) . paddingOnly ( top: 24. h , bottom: 24 .h , left: 24. h , right: 24. h ) ,
) ,
] ,
) ;
@ -438,8 +376,7 @@ class CallAmbulancePage extends StatelessWidget {
showHospitalBottomSheet ( BuildContext context ) {
showCommonBottomSheetWithoutHeight (
title:
LocaleKeys . selectHospital . tr ( ) ,
title: LocaleKeys . selectHospital . tr ( ) ,
context ,
child: HospitalBottomSheetBody ( ) ,
isFullScreen: false ,