@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import ' package:hmg_patient_app_new/core/app_state.dart ' ;
import ' package:hmg_patient_app_new/core/dependencies.dart ' ;
import ' package:hmg_patient_app_new/core/utils/size_utils.dart ' ;
import ' package:hmg_patient_app_new/core/utils/utils.dart ' ;
import ' package:hmg_patient_app_new/extensions/string_extensions.dart ' ;
import ' package:hmg_patient_app_new/extensions/widget_extensions.dart ' ;
import ' package:hmg_patient_app_new/features/hmg_services/hmg_services_view_model.dart ' ;
@ -17,6 +18,7 @@ import 'package:hmg_patient_app_new/services/navigation_service.dart';
import ' package:hmg_patient_app_new/theme/colors.dart ' ;
import ' package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart ' ;
import ' package:hmg_patient_app_new/widgets/buttons/custom_button.dart ' ;
import ' package:hmg_patient_app_new/widgets/common_bottom_sheet.dart ' ;
import ' package:hmg_patient_app_new/widgets/map/map_utility_screen.dart ' ;
import ' package:hmg_patient_app_new/widgets/routes/custom_page_route.dart ' ;
import ' package:provider/provider.dart ' ;
@ -61,28 +63,9 @@ class _HhcProceduresPageState extends State<HhcProceduresPage> {
}
Widget _buildPendingOrderCard ( GetCMCAllOrdersResponseModel order ) {
int status = order . statusId ? ? 0 ;
String statusDisp = order . statusText ? ? " " ;
Color statusColor ;
if ( status = = 1 ) {
/ / pending
statusColor = AppColors . statusPendingColor ;
} else if ( status = = 2 ) {
/ / processing
statusColor = AppColors . statusProcessingColor ;
} else if ( status = = 3 ) {
/ / completed
statusColor = AppColors . statusCompletedColor ;
} else {
/ / cancel / rejected
statusColor = AppColors . statusRejectedColor ;
}
final canCancel = order . statusId = = 1 | | order . statusId = = 2 ;
final isArabic = getIt . get < AppState > ( ) . isArabic ( ) ;
/ / Extract services from orderselectedservice
List < dynamic > selectedServices = [ ] ;
if ( order . orderselectedservice ! = null ) {
if ( order . orderselectedservice is List ) {
@ -108,16 +91,12 @@ class _HhcProceduresPageState extends State<HhcProceduresPage> {
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Container (
padding: EdgeInsets . symmetric ( horizontal: 12. w , vertical: 6. h ) ,
decoration: BoxDecoration (
color: statusColor . withValues ( alpha: 0.1 ) ,
borderRadius: BorderRadius . circular ( 8. r ) ,
) ,
child: statusDisp . toText12 (
color: statusColor ,
fontWeight: FontWeight . w600 ,
) ,
Row (
children: [
" Request ID: " . needTranslation . toText14 ( color: AppColors . textColorLight , weight: FontWeight . w500 ) ,
SizedBox ( width: 4. w ) ,
" ${ order . iD ? ? ' - ' } " . toText16 ( isBold: true ) ,
] ,
) ,
SizedBox ( width: 8. w ) ,
if ( order . created ! = null )
@ -127,17 +106,7 @@ class _HhcProceduresPageState extends State<HhcProceduresPage> {
) ,
] ,
) ,
SizedBox ( height: 16. h ) ,
/ / Request ID
Row (
children: [
" Request ID: " . needTranslation . toText14 ( color: AppColors . textColorLight , weight: FontWeight . w500 ) ,
SizedBox ( width: 4. w ) ,
" ${ order . iD ? ? ' - ' } " . toText16 ( isBold: true ) ,
] ,
) ,
SizedBox ( height: 8. h ) ,
/ / Services List
if ( selectedServices . isNotEmpty ) . . . [
@ -212,13 +181,13 @@ class _HhcProceduresPageState extends State<HhcProceduresPage> {
] ,
) ,
) ;
} ) .toList ( ) ,
} ) ,
] ,
) ,
) ,
] ,
SizedBox ( height: 12 .h ) ,
SizedBox ( height: 8 .h ) ,
/ / Info message
Container (
@ -274,9 +243,17 @@ class _HhcProceduresPageState extends State<HhcProceduresPage> {
) ;
}
Widget _buildServiceSelectionList ( List < GetCMCServicesResponseModel > services ) {
if ( services . isEmpty ) {
return Center (
_buildServicesListBottomsSheet ( List < GetCMCServicesResponseModel > services ) {
showCommonBottomSheetWithoutHeight (
hasBottomPadding: false ,
padding: EdgeInsets . only ( top: 24. h ) ,
context ,
title: ' Select Services ' . needTranslation ,
isCloseButtonVisible: true ,
isDismissible: true ,
callBackFunc: ( ) { } ,
child: services . isEmpty
? Center (
child: Padding (
padding: EdgeInsets . all ( 24. h ) ,
child: Text (
@ -287,61 +264,52 @@ class _HhcProceduresPageState extends State<HhcProceduresPage> {
) ,
) ,
) ,
) ;
}
)
: Consumer < HmgServicesViewModel > (
builder: ( context , hmgServicesViewModel , child ) {
final pendingOrder = _getPendingOrder ( hmgServicesViewModel . hhcOrdersList ) ;
final hasSelectedServices = pendingOrder = = null & & hmgServicesViewModel . selectedHhcServices . isNotEmpty ;
return Consumer < HmgServicesViewModel > (
builder: ( context , viewModel , child ) {
return Column (
crossAxisAlignment: CrossAxisAlignment . start ,
return Stack (
children: [
SizedBox ( height: 8. h ) ,
SizedBox ( height: 16. h ) ,
Text (
' Select Services ' . needTranslation ,
style: TextStyle (
fontSize: 20. h ,
fontWeight: FontWeight . w700 ,
color: AppColors . blackColor ,
letterSpacing: - 0.8 ,
) ,
) . paddingOnly ( left: 16. w , right: 16. w ) ,
SizedBox ( height: 12. h ) ,
ListView . builder (
padding: EdgeInsets . symmetric ( horizontal: 16. w ) ,
itemCount: services . length ,
/ / Services List
ConstrainedBox (
constraints: BoxConstraints ( maxHeight: SizeUtils . height * 0.7 ) ,
child: ListView . separated (
separatorBuilder: ( context , index ) = > Divider ( color: AppColors . dividerColor ) . paddingSymmetrical ( 16. w , 0 ) ,
padding: EdgeInsets . only ( left: 16. w , right: 16. w , bottom: hasSelectedServices ? 160. h : 8. h ) ,
shrinkWrap: true ,
physics: NeverScrollableScrollPhysics ( ) ,
itemCount: services . length ,
itemBuilder: ( context , index ) {
final service = services [ index ] ;
final isSelected = viewModel. isHhcServiceSelected ( service ) ;
final isSelected = hmgServicesViewModel . isHhcServiceSelected ( service ) ;
final isArabic = getIt . get < AppState > ( ) . isArabic ( ) ;
final serviceName = isArabic ? ( service . textN ? ? service . text ? ? ' ' ) : ( service . text ? ? ' ' ) ;
return AnimatedContainer (
duration: Duration ( milliseconds: 300 ) ,
curve: Curves . easeInOut ,
margin: EdgeInsets . only ( bottom: 12. h ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 16. r ,
hasShadow: true ,
) ,
child: Material (
color: Colors . transparent ,
child: InkWell (
onTap: ( ) = > viewModel. toggleHhcServiceSelection ( service ) ,
onTap: ( ) = > hmgServicesViewModel . toggleHhcServiceSelection ( service ) ,
borderRadius: BorderRadius . circular ( 16. r ) ,
child: Container (
padding: EdgeInsets . all ( 16 .w ) ,
padding: EdgeInsets . all ( 8. w ) ,
child: Row (
children: [
Checkbox (
value: isSelected ,
onChanged: ( v ) = > viewModel . toggleHhcServiceSelection ( service ) ,
activeColor: AppColors . primaryRedColor ,
materialTapTargetSize: MaterialTapTargetSize . shrinkWrap ,
visualDensity: VisualDensity . compact ,
AnimatedContainer (
duration: const Duration ( milliseconds: 300 ) ,
curve: Curves . easeInOut ,
width: 24. w ,
height: 24. w ,
decoration: BoxDecoration (
color: isSelected ? AppColors . primaryRedColor : Colors . transparent ,
borderRadius: BorderRadius . circular ( 5. r ) ,
border: Border . all (
color: isSelected ? AppColors . primaryRedColor : AppColors . borderGrayColor ,
width: 1. w ,
) ,
) ,
child: isSelected ? Icon ( Icons . check , size: 18. f , color: AppColors . whiteColor ) : null ,
) ,
SizedBox ( width: 12. w ) ,
Expanded (
@ -349,7 +317,7 @@ class _HhcProceduresPageState extends State<HhcProceduresPage> {
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
serviceName . toText16 (
weight: FontWeight . w4 00,
weight: FontWeight . w5 00,
color: AppColors . blackColor ,
maxlines: 2 ,
) ,
@ -360,13 +328,63 @@ class _HhcProceduresPageState extends State<HhcProceduresPage> {
) ,
) ,
) ,
) ,
) ;
} ,
) ,
) ,
if ( hasSelectedServices )
Positioned (
left: 0 ,
right: 0 ,
bottom: 0 ,
child: Container (
padding: EdgeInsets . symmetric ( horizontal: 16. w , vertical: 24. h ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 24. r ,
hasShadow: true ,
) ,
child: Column (
children: [
Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
" Selected Services " . needTranslation . toText12 (
color: AppColors . textColorLight ,
fontWeight: FontWeight . w600 ,
) ,
" ${ hmgServicesViewModel . selectedHhcServices . length } service(s) selected " . toText14 (
isBold: true ,
weight: FontWeight . bold ,
) ,
] ,
) ,
] ,
) ,
SizedBox ( height: 16. h ) ,
CustomButton (
borderWidth: 0 ,
text: " Next " . needTranslation ,
onPressed: ( ) {
Navigator . pop ( context ) ;
_proceedWithSelectedService ( ) ;
} ,
textColor: AppColors . whiteColor ,
borderRadius: 12. r ,
borderColor: Colors . transparent ,
) ,
] ,
) ,
) ,
) ,
] ,
) ;
} ,
) ,
) ;
}
@ -426,77 +444,70 @@ class _HhcProceduresPageState extends State<HhcProceduresPage> {
@ override
Widget build ( BuildContext context ) {
return CollapsingListView (
return Scaffold (
backgroundColor: AppColors . bgScaffoldColor ,
body: Column (
children: [
Expanded (
child: CollapsingListView (
title: " Home Health Care " . needTranslation ,
history: ( ) = > Navigator . of ( context ) . push ( CustomPageRoute ( page: HhcOrderDetailPage ( ) , direction: AxisDirection . up ) ) ,
bottomChild: Consumer < HmgServicesViewModel > (
c hild: Consumer < HmgServicesViewModel > (
builder: ( context , hmgServicesViewModel , child ) {
if ( hmgServicesViewModel . isHhcOrdersLoading | | hmgServicesViewModel . isHhcServicesLoading ) return SizedBox . shrink ( ) ;
if ( hmgServicesViewModel . isHhcOrdersLoading | | hmgServicesViewModel . isHhcServicesLoading ) {
return _buildLoadingShimmer ( ) ;
}
final pendingOrder = _getPendingOrder ( hmgServicesViewModel . hhcOrdersList ) ;
if ( pendingOrder = = null & & hmgServicesViewModel . selectedHhcServices . isNotEmpty ) {
return SafeArea (
top: false ,
child: Container (
color: AppColors . whiteColor ,
child: Column (
mainAxisSize: MainAxisSize . min ,
children: [
/ / Selected Services Summary Widget
Container (
margin: EdgeInsets . symmetric ( horizontal: 16. w , vertical: 4. h ) ,
padding: EdgeInsets . all ( 16. w ) ,
child: Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
if ( pendingOrder ! = null ) {
return _buildPendingOrderCard ( pendingOrder ) ;
} else {
return Column (
children: [
" Selected Services " . needTranslation . toText12 (
color: AppColors . textColorLight ,
fontWeight: FontWeight . w600 ,
Center (
child: Utils . getNoDataWidget (
context ,
noDataText: " You have no pending requests. " . needTranslation ,
) ,
" ${ hmgServicesViewModel . selectedHhcServices . length } service(s) selected " . toText14 (
isBold: true ,
weight: FontWeight . bold ,
) ,
] ,
) ;
}
} ,
) ,
] ,
) ,
) ,
/ / Next Button
Padding (
padding: EdgeInsets . only ( left: 16. w , right: 16. w ) ,
Consumer (
builder: ( BuildContext context , HmgServicesViewModel hmgServicesViewModel , Widget ? child ) {
if ( hmgServicesViewModel . isHhcOrdersLoading | | hmgServicesViewModel . isHhcServicesLoading ) {
return SizedBox . shrink ( ) ;
}
final pendingOrder = _getPendingOrder ( hmgServicesViewModel . hhcOrdersList ) ;
if ( pendingOrder = = null ) {
return Container (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 24. r ,
hasShadow: true ,
) ,
child: Padding (
padding: EdgeInsets . only ( left: 16. w , right: 16. w , bottom: 24. h , top: 24. h ) ,
child: CustomButton (
borderWidth: 0 ,
text: " Next " . needTranslation ,
onPressed: _proceedWithSelectedService ,
text: " Create new reques t" . needTranslation ,
onPressed: ( ) = > _buildServicesListBottomsSheet ( hmgServicesViewModel . hhcServicesList ) ,
textColor: AppColors . whiteColor ,
borderRadius: 12. r ,
borderColor: Colors . transparent ,
padding: EdgeInsets . symmetric ( vertical: 14. h ) ,
) ,
) ,
] ,
) ,
) ,
) ;
}
return SizedBox . shrink ( ) ;
} ,
) ,
child: Consumer < HmgServicesViewModel > (
builder: ( context , hmgServicesViewModel , child ) {
if ( hmgServicesViewModel . isHhcOrdersLoading | | hmgServicesViewModel . isHhcServicesLoading ) {
return _buildLoadingShimmer ( ) ;
}
final pendingOrder = _getPendingOrder ( hmgServicesViewModel . hhcOrdersList ) ;
if ( pendingOrder ! = null ) {
return _buildPendingOrderCard ( pendingOrder ) ;
} else {
return _buildServiceSelectionList ( hmgServicesViewModel . hhcServicesList ) ;
}
} ,
] ,
) ,
) ;
}