commit
						3911a8fd1a
					
				| @ -0,0 +1,103 @@ | ||||
| import 'dart:ui'; | ||||
| 
 | ||||
| import 'package:easy_localization/easy_localization.dart'; | ||||
| import 'package:flutter/material.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'; | ||||
| import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; | ||||
| import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; | ||||
| import 'package:hmg_patient_app_new/theme/colors.dart'; | ||||
| 
 | ||||
| class CollapsingListView extends StatelessWidget { | ||||
|   final String title; | ||||
|   Widget? child; | ||||
|   VoidCallback? search; | ||||
|   Widget? bottomChild; | ||||
|   bool isClose; | ||||
| 
 | ||||
|   CollapsingListView({required this.title, this.child, this.search, this.isClose = false, this.bottomChild}); | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Scaffold( | ||||
|       backgroundColor: AppColors.bgScaffoldColor, | ||||
|       body: Column( | ||||
|         children: [ | ||||
|           CustomScrollView( | ||||
|             slivers: [ | ||||
|               SliverAppBar( | ||||
|                 pinned: true, | ||||
|                 expandedHeight: 100, | ||||
|                 stretch: true, | ||||
|                 backgroundColor: AppColors.bgScaffoldColor, | ||||
|                 leading: IconButton( | ||||
|                   icon: Utils.buildSvgWithAssets(icon: isClose ? AppAssets.closeBottomNav : AppAssets.arrow_back, width: 32.h, height: 32.h), | ||||
|                   padding: EdgeInsets.only(left: 12), | ||||
|                   onPressed: () => Navigator.pop(context), | ||||
|                 ), | ||||
|                 flexibleSpace: LayoutBuilder( | ||||
|                   builder: (context, constraints) { | ||||
|                     final double maxHeight = 100; | ||||
|                     final double minHeight = kToolbarHeight; | ||||
|                     double t = (constraints.maxHeight - minHeight) / (maxHeight - minHeight); | ||||
|                     t = t - 1; | ||||
|                     if (t < 0.7) t = 0.7; | ||||
|                     t = t.clamp(0.0, 1.0); | ||||
| 
 | ||||
|                     final double fontSize = lerpDouble(14, 18, t)!; | ||||
|                     final double bottomPadding = lerpDouble(0, 0, t)!; | ||||
|                     final double leftPadding = lerpDouble(150, 24, t)!; | ||||
| 
 | ||||
|                     return Stack( | ||||
|                       children: [ | ||||
|                         Align( | ||||
|                           alignment: Alignment.lerp( | ||||
|                             Alignment.center, | ||||
|                             Alignment.bottomLeft, | ||||
|                             t, | ||||
|                           )!, | ||||
|                           child: Padding( | ||||
|                               padding: EdgeInsets.only( | ||||
|                                 left: leftPadding, | ||||
|                                 bottom: bottomPadding, | ||||
|                               ), | ||||
|                               child: Row( | ||||
|                                 spacing: 4.h, | ||||
|                                 children: [ | ||||
|                                   Text( | ||||
|                                     title, | ||||
|                                     maxLines: 1, | ||||
|                                     style: TextStyle( | ||||
|                                         fontSize: (27 - (5 * (2 - t))).fSize, | ||||
|                                         fontWeight: FontWeight.lerp( | ||||
|                                           FontWeight.w300, | ||||
|                                           FontWeight.w600, | ||||
|                                           t, | ||||
|                                         )!, | ||||
|                                         color: AppColors.blackColor, | ||||
|                                         letterSpacing: -0.5), | ||||
|                                   ).expanded, | ||||
|                                   if (search != null) Utils.buildSvgWithAssets(icon: AppAssets.search_icon).onPress(search!).paddingOnly(right: 24) | ||||
|                                 ], | ||||
|                               )), | ||||
|                         ), | ||||
|                       ], | ||||
|                     ); | ||||
|                   }, | ||||
|                 ), | ||||
|               ), | ||||
|               SliverList( | ||||
|                 delegate: SliverChildBuilderDelegate( | ||||
|                   (context, index) => child, | ||||
|                   childCount: 1, | ||||
|                 ), | ||||
|               ), | ||||
|             ], | ||||
|           ).expanded, | ||||
|           if (bottomChild != null) bottomChild! | ||||
|         ], | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,172 @@ | ||||
| import 'package:easy_localization/easy_localization.dart'; | ||||
| import 'package:flutter/material.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/date_util.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/lab/models/resp_models/patient_lab_orders_response_model.dart'; | ||||
| import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; | ||||
| import 'package:hmg_patient_app_new/theme/colors.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart'; | ||||
| 
 | ||||
| class LabResultItemView extends StatelessWidget { | ||||
|   final VoidCallback onTap; | ||||
|   final int index; | ||||
|   final PatientLabOrdersResponseModel? labOrder; | ||||
|   final bool isLoading; | ||||
|   final bool isExpanded; | ||||
| 
 | ||||
|   LabResultItemView({Key? key, required this.onTap, this.labOrder, required this.index, this.isLoading = false, this.isExpanded = false}) : super(key: key); | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return AnimatedContainer( | ||||
|       duration: Duration(milliseconds: 300), | ||||
|       curve: Curves.easeInOut, | ||||
|       margin: EdgeInsets.symmetric(vertical: 8.h), | ||||
|       decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 20.h, hasShadow: true), | ||||
|       child: InkWell( | ||||
|         onTap: () { | ||||
|           if (!isLoading) { | ||||
|             onTap(); | ||||
|           } | ||||
|         }, | ||||
|         child: Column( | ||||
|           crossAxisAlignment: CrossAxisAlignment.start, | ||||
|           children: [ | ||||
|             Padding( | ||||
|               padding: EdgeInsets.all(16.h), | ||||
|               child: Column( | ||||
|                 crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                 children: [ | ||||
|                   Row( | ||||
|                     mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                     children: [ | ||||
|                       AppCustomChipWidget( | ||||
|                         labelText: getLabOrderStatusText(labOrder?.status ?? 0, context), | ||||
|                         backgroundColor: getLabOrderStatusColor(labOrder?.status ?? 0).withOpacity(0.15), | ||||
|                         textColor: getLabOrderStatusColor(labOrder?.status ?? 0), | ||||
|                       ).toShimmer2(isShow: isLoading, width: 100), | ||||
|                       if (!isLoading) Icon(isExpanded ? Icons.expand_less : Icons.expand_more), | ||||
|                     ], | ||||
|                   ), | ||||
|                   SizedBox(height: 8.h), | ||||
|                   Row( | ||||
|                     children: [ | ||||
|                       Image.network( | ||||
|                         isLoading ? "" : labOrder!.doctorImageURL!, | ||||
|                         width: 24.h, | ||||
|                         height: 24.h, | ||||
|                         fit: BoxFit.fill, | ||||
|                         errorBuilder: (cxt, child, tr) { | ||||
|                           return SizedBox(height: 24, width: 24); | ||||
|                         }, | ||||
|                       ).toShimmer2(isShow: isLoading).circle(100), | ||||
|                       SizedBox(width: 4.h), | ||||
|                       (labOrder?.doctorName ?? "").toText16(isBold: true).toShimmer2(isShow: isLoading, width: 200) | ||||
|                     ], | ||||
|                   ), | ||||
|                   SizedBox(height: 8.h), | ||||
|                   Wrap( | ||||
|                     spacing: 8.h, | ||||
|                     runSpacing: 0.h, | ||||
|                     children: [ | ||||
|                       AppCustomChipWidget(labelText: isLoading ? "null" : DateUtil.formatDateToDate(DateUtil.convertStringToDate(labOrder!.createdOn), false)).toShimmer2(isShow: isLoading, width: 70), | ||||
|                       AppCustomChipWidget(labelText: isLoading ? "null" : labOrder!.clinicDescription!).toShimmer2(isShow: isLoading, width: 100), | ||||
|                     ], | ||||
|                   ), | ||||
|                 ], | ||||
|               ), | ||||
|             ), | ||||
|             AnimatedSwitcher( | ||||
|               duration: Duration(milliseconds: 300), | ||||
|               switchInCurve: Curves.easeIn, | ||||
|               switchOutCurve: Curves.easeOut, | ||||
|               transitionBuilder: (Widget child, Animation<double> animation) { | ||||
|                 return FadeTransition( | ||||
|                   opacity: animation, | ||||
|                   child: SizeTransition( | ||||
|                     sizeFactor: animation, | ||||
|                     axisAlignment: 0.0, | ||||
|                     child: child, | ||||
|                   ), | ||||
|                 ); | ||||
|               }, | ||||
|               child: isExpanded | ||||
|                   ? Container( | ||||
|                       key: ValueKey<int>(index), | ||||
|                       padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 8.h), | ||||
|                       child: Column( | ||||
|                         crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                         children: [ | ||||
|                           ...labOrder!.testDetails!.map((detail) { | ||||
|                             return Padding( | ||||
|                               padding: EdgeInsets.only(bottom: 8.h), | ||||
|                               child: '● ${detail.description}'.toText14(weight: FontWeight.w500), | ||||
|                             ); | ||||
|                           }).toList(), | ||||
|                           SizedBox(height: 16.h), | ||||
|                           Row( | ||||
|                             mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                             children: [ | ||||
|                               SizedBox(), | ||||
|                               CustomButton( | ||||
|                                 icon: AppAssets.view_report_icon, | ||||
|                                 iconColor: AppColors.primaryRedColor, | ||||
|                                 iconSize: 16.h, | ||||
|                                 text: LocaleKeys.viewReport.tr(context: context), | ||||
|                                 onPressed: () {}, | ||||
|                                 backgroundColor: AppColors.secondaryLightRedColor, | ||||
|                                 borderColor: AppColors.secondaryLightRedColor, | ||||
|                                 textColor: AppColors.primaryRedColor, | ||||
|                                 fontSize: 14, | ||||
|                                 fontWeight: FontWeight.bold, | ||||
|                                 borderRadius: 12, | ||||
|                                 padding: EdgeInsets.fromLTRB(10, 0, 10, 0), | ||||
|                                 height: 40.h, | ||||
|                               ), | ||||
|                             ], | ||||
|                           ), | ||||
|                         ], | ||||
|                       ), | ||||
|                     ) | ||||
|                   : SizedBox.shrink(key: ValueKey<int>(-index)), | ||||
|             ), | ||||
|           ], | ||||
|         ), | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   String getLabOrderStatusText(num status, context) { | ||||
|     switch (status) { | ||||
|       case 44: | ||||
|         return LocaleKeys.resultsPending.tr(context: context); | ||||
|       case 45: | ||||
|         return LocaleKeys.resultsPending.tr(context: context); | ||||
|       case 16: | ||||
|         return LocaleKeys.resultsAvailable.tr(context: context); | ||||
|       case 17: | ||||
|         return LocaleKeys.resultsAvailable.tr(context: context); | ||||
|       default: | ||||
|         return ""; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Color getLabOrderStatusColor(num status) { | ||||
|     switch (status) { | ||||
|       case 44: | ||||
|         return AppColors.warningColorYellow; | ||||
|       case 45: | ||||
|         return AppColors.warningColorYellow; | ||||
|       case 16: | ||||
|         return AppColors.successColor; | ||||
|       case 17: | ||||
|         return AppColors.successColor; | ||||
|       default: | ||||
|         return AppColors.greyColor; | ||||
|     } | ||||
|   } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue