@ -2,19 +2,54 @@ import 'package:easy_localization/easy_localization.dart';
import ' package:flutter/material.dart ' ;
import ' package:hmg_patient_app_new/core/app_export.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/symptoms_checker/models/resp_models/triage_level_response_model.dart ' ;
import ' package:hmg_patient_app_new/generated/locale_keys.g.dart ' ;
import ' package:hmg_patient_app_new/theme/colors.dart ' ;
class TriageLevelCard extends State less Widget {
class TriageLevelCard extends State fu lWidget {
final TriageLevelDataDetails triageLevelData ;
const TriageLevelCard ( { super . key , required this . triageLevelData } ) ;
@ override
State < TriageLevelCard > createState ( ) = > _TriageLevelCardState ( ) ;
}
class _TriageLevelCardState extends State < TriageLevelCard > with SingleTickerProviderStateMixin {
late AnimationController _animationController ;
late Animation < double > _borderAnimation ;
@ override
void initState ( ) {
super . initState ( ) ;
/ / Create animation controller for border pulse effect
_animationController = AnimationController (
vsync: this ,
duration: const Duration ( milliseconds: 2000 ) ,
) ;
/ / Create animation that goes from 1.0 to 0.3 and back ( for opacity )
_borderAnimation = Tween < double > ( begin: 1.0 , end: 0.3 ) . animate (
CurvedAnimation (
parent: _animationController ,
curve: Curves . easeInOut ,
) ,
) ;
/ / Start the animation and repeat
_animationController . repeat ( reverse: true ) ;
}
@ override
void dispose ( ) {
_animationController . dispose ( ) ;
super . dispose ( ) ;
}
/ / / Get localized title based on triage level
String getTitle ( BuildContext context ) {
final triageLevel = triageLevelData . triageLevel ? ? ' ' ;
final triageLevel = widget. triageLevelData. triageLevel ? ? ' ' ;
switch ( triageLevel ) {
case ' emergency_ambulance ' :
@ -34,7 +69,7 @@ class TriageLevelCard extends StatelessWidget {
/ / / Get localized description based on triage level
String getDescription ( BuildContext context ) {
final triageLevel = triageLevelData. triageLevel ? ? ' ' ;
final triageLevel = widget. triageLevelData. triageLevel ? ? ' ' ;
switch ( triageLevel ) {
case ' emergency_ambulance ' :
@ -54,7 +89,7 @@ class TriageLevelCard extends StatelessWidget {
/ / / Get color based on triage level
Color getBackgroundColor ( ) {
final triageLevel = triageLevelData. triageLevel ? ? ' ' ;
final triageLevel = widget. triageLevelData. triageLevel ? ? ' ' ;
switch ( triageLevel ) {
case ' emergency_ambulance ' :
@ -72,7 +107,7 @@ class TriageLevelCard extends StatelessWidget {
/ / / Get border color based on triage level
Color getBorderColor ( ) {
final triageLevel = triageLevelData. triageLevel ? ? ' ' ;
final triageLevel = widget. triageLevelData. triageLevel ? ? ' ' ;
switch ( triageLevel ) {
case ' emergency_ambulance ' :
@ -90,7 +125,7 @@ class TriageLevelCard extends StatelessWidget {
/ / / Get icon based on triage level
IconData getIcon ( ) {
final triageLevel = triageLevelData. triageLevel ? ? ' ' ;
final triageLevel = widget. triageLevelData. triageLevel ? ? ' ' ;
switch ( triageLevel ) {
case ' emergency_ambulance ' :
@ -110,7 +145,7 @@ class TriageLevelCard extends StatelessWidget {
/ / / Get root cause text ( localized )
String ? getRootCauseText ( BuildContext context ) {
final rootCause = triageLevelData. rootCause ? ? ' ' ;
final rootCause = widget. triageLevelData. rootCause ? ? ' ' ;
switch ( rootCause ) {
case ' emergency_evidence_present ' :
@ -138,13 +173,33 @@ class TriageLevelCard extends StatelessWidget {
final title = getTitle ( context ) ;
final description = getDescription ( context ) ;
final rootCauseText = getRootCauseText ( context ) ;
final seriousSymptoms = triageLevelData. serious ? ? [ ] ;
final seriousSymptoms = widget. triageLevelData. serious ? ? [ ] ;
return Container (
width: double . infinity ,
margin: EdgeInsets . only ( left: 24. w , right: 24. w , top: 16. h , bottom: 8. h ) ,
padding: EdgeInsets . all ( 20. w ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration ( color: AppColors . whiteColor , borderRadius: 24. r , hasShadow: true ) ,
return AnimatedBuilder (
animation: _borderAnimation ,
builder: ( context , child ) {
return Container (
width: double . infinity ,
margin: EdgeInsets . only ( left: 24. w , right: 24. w , top: 16. h , bottom: 8. h ) ,
padding: EdgeInsets . all ( 20. w ) ,
decoration: BoxDecoration (
color: AppColors . whiteColor ,
borderRadius: BorderRadius . circular ( 24. r ) ,
border: Border . all (
color: borderColor . withValues ( alpha: _borderAnimation . value ) ,
width: 2. w ,
) ,
boxShadow: [
BoxShadow (
color: Colors . black . withValues ( alpha: 0.08 ) ,
blurRadius: 10. r ,
offset: Offset ( 0 , 2. h ) ,
) ,
] ,
) ,
child: child ,
) ;
} ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [