import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/features/consultations/models/consultation_progress.dart'; import 'package:eatvio_app/features/consultations/presentation/widgets/consultation_progress_plank.dart'; import 'package:eatvio_app/features/consultations/presentation/widgets/personal_diet_status_chip.dart'; import 'package:eatvio_app/generated/l10n.dart'; import 'package:flutter/material.dart'; class ChatConsultationHeader extends StatelessWidget { const ChatConsultationHeader({ super.key, required this.progress, required this.showInfoButton, required this.onInfoTap, }); final ConsultationProgress progress; final bool showInfoButton; final VoidCallback onInfoTap; @override Widget build(BuildContext context) { final showPlank = progress.showProgressPlank; final showChip = progress.hasChip; if (!showPlank && !showChip && !showInfoButton) { return const SizedBox.shrink(); } final s = S.of(context); return Container( margin: const EdgeInsets.fromLTRB(16, 8, 16, 0), padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: appTheme.commentBg, borderRadius: BorderRadius.circular(20), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ if (progress.phase == ConsultationPhase.active || showPlank) Row( children: [ Expanded( child: Text( _title(s), style: TextStyles.textMMedium.copyWith( color: appTheme.black, ), ), ), if (showInfoButton) _InfoButton( onTap: onInfoTap, ), ], ) else if (showInfoButton) Align( alignment: Alignment.centerRight, child: _InfoButton( onTap: onInfoTap, ), ), if (showPlank) ...[ const SizedBox(height: 8), ConsultationProgressPlank(progress: progress), ], if (showChip) ...[ const SizedBox(height: 8), PersonalDietStatusChip(progress: progress), ], ], ), ); } String _title(S s) { if (progress.isCanceled) return s.orderCanceled; if (progress.isPaymentFailed) return s.payment_failed; if (progress.isStepCompleted(ConsultationStep.finished)) return s.done; if (progress.showProgressPlank) return s.order_in_progress; return s.more_about_order; } } class _InfoButton extends StatelessWidget { const _InfoButton({required this.onTap}); final VoidCallback onTap; @override Widget build(BuildContext context) { return InkWell( onTap: onTap, customBorder: const CircleBorder(), child: Container( width: 32, height: 32, decoration: BoxDecoration( color: appTheme.whiteA700, shape: BoxShape.circle, ), child: Icon( Icons.info_outline_rounded, size: 18, color: appTheme.blueA400, ), ), ); } }