You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			110 lines
		
	
	
		
			5.4 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			110 lines
		
	
	
		
			5.4 KiB
		
	
	
	
		
			Dart
		
	
| import 'dart:async';
 | |
| 
 | |
| import 'package:easy_localization/easy_localization.dart';
 | |
| import 'package:flutter/material.dart';
 | |
| import 'package:flutter_staggered_animations/flutter_staggered_animations.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/insurance/insurance_view_model.dart';
 | |
| import 'package:hmg_patient_app_new/features/insurance/models/resp_models/patient_insurance_approval_response_model.dart';
 | |
| import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
 | |
| import 'package:hmg_patient_app_new/presentation/insurance/widgets/insurance_approval_card.dart';
 | |
| import 'package:hmg_patient_app_new/presentation/insurance/widgets/insurance_approval_details_page.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/routes/custom_page_route.dart';
 | |
| import 'package:provider/provider.dart';
 | |
| 
 | |
| class InsuranceApprovalsPage extends StatefulWidget {
 | |
|   const InsuranceApprovalsPage({super.key});
 | |
| 
 | |
|   @override
 | |
|   State<InsuranceApprovalsPage> createState() => _InsuranceApprovalsPageState();
 | |
| }
 | |
| 
 | |
| class _InsuranceApprovalsPageState extends State<InsuranceApprovalsPage> {
 | |
|   late InsuranceViewModel insuranceViewModel;
 | |
|   late AppState appState;
 | |
| 
 | |
|   @override
 | |
|   void initState() {
 | |
|     scheduleMicrotask(() {
 | |
|       insuranceViewModel.setIsInsuranceApprovalsLoading(true);
 | |
|       insuranceViewModel.getPatientInsuranceApprovalsList();
 | |
|     });
 | |
|     super.initState();
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     appState = getIt.get<AppState>();
 | |
|     insuranceViewModel = Provider.of<InsuranceViewModel>(context, listen: false);
 | |
|     return CollapsingListView(
 | |
|       title: "${LocaleKeys.insurance.tr(context: context)} ${LocaleKeys.approvals.tr(context: context)}",
 | |
|       child: SingleChildScrollView(
 | |
|         child: Consumer<InsuranceViewModel>(builder: (context, insuranceVM, child) {
 | |
|           return Column(
 | |
|             crossAxisAlignment: CrossAxisAlignment.start,
 | |
|             children: [
 | |
|               ListView.separated(
 | |
|                 padding: EdgeInsets.only(top: 24.h),
 | |
|                 shrinkWrap: true,
 | |
|                 physics: NeverScrollableScrollPhysics(),
 | |
|                 itemCount: insuranceVM.isInsuranceApprovalsLoading
 | |
|                     ? 5
 | |
|                     : insuranceVM.patientInsuranceApprovalsList.isNotEmpty
 | |
|                         ? insuranceVM.patientInsuranceApprovalsList.length
 | |
|                         : 1,
 | |
|                 itemBuilder: (context, index) {
 | |
|                   return insuranceVM.isInsuranceApprovalsLoading
 | |
|                       ? Container(
 | |
|                           decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.h, hasShadow: true),
 | |
|                           child: InsuranceApprovalCard(
 | |
|                             insuranceApprovalResponseModel: InsuranceApprovalResponseModel(),
 | |
|                             appState: appState,
 | |
|                             isLoading: true,
 | |
|                           ),
 | |
|                         ).paddingSymmetrical(24.h, 0.h)
 | |
|                       : insuranceVM.patientInsuranceApprovalsList.isNotEmpty
 | |
|                           ? AnimationConfiguration.staggeredList(
 | |
|                               position: index,
 | |
|                               duration: const Duration(milliseconds: 500),
 | |
|                               child: SlideAnimation(
 | |
|                                 verticalOffset: 100.0,
 | |
|                                 child: FadeInAnimation(
 | |
|                                   child: AnimatedContainer(
 | |
|                                     duration: Duration(milliseconds: 300),
 | |
|                                     curve: Curves.easeInOut,
 | |
|                                     decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.h, hasShadow: true),
 | |
|                                     child: InsuranceApprovalCard(
 | |
|                                       insuranceApprovalResponseModel: insuranceVM.patientInsuranceApprovalsList[index],
 | |
|                                       appState: appState,
 | |
|                                       isLoading: false,
 | |
|                                     ).onPress(() {
 | |
|                                       Navigator.of(context).push(
 | |
|                                         CustomPageRoute(
 | |
|                                           page: InsuranceApprovalDetailsPage(insuranceApprovalResponseModel: insuranceVM.patientInsuranceApprovalsList[index]),
 | |
|                                         ),
 | |
|                                       );
 | |
|                                     }),
 | |
|                                   ).paddingSymmetrical(24.h, 0.h),
 | |
|                                 ),
 | |
|                               ),
 | |
|                             )
 | |
|                           : Utils.getNoDataWidget(context, noDataText: "You don't have any insurance approvals yet.".needTranslation);
 | |
|                 },
 | |
|                 separatorBuilder: (BuildContext cxt, int index) => SizedBox(height: 16.h),
 | |
|               ),
 | |
|               SizedBox(height: 24.h),
 | |
|             ],
 | |
|           );
 | |
|         }),
 | |
|       ),
 | |
|     );
 | |
|   }
 | |
| }
 |