import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import '../../../domain/entities/logistic_object.dart'; import '../../../domain/entities/tour.dart'; class ScanResultSheet extends StatelessWidget { final LogisticObject object; final String suggestedState; final Tour? tour; final String? containerInfo; final VoidCallback onConfirm; final VoidCallback onCancel; const ScanResultSheet({ super.key, required this.object, required this.suggestedState, this.tour, this.containerInfo, required this.onConfirm, required this.onCancel, }); @override Widget build(BuildContext context) { final theme = Theme.of(context); final currentStateColor = ObjectStateInfo.getColorForState(object.state); final suggestedStateColor = ObjectStateInfo.getColorForState(suggestedState); return Container( decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(24)), ), child: Column( mainAxisSize: MainAxisSize.min, children: [ // Handle Container( margin: const EdgeInsets.only(top: 12), width: 40, height: 4, decoration: BoxDecoration( color: Colors.grey.shade300, borderRadius: BorderRadius.circular(2), ), ), const SizedBox(height: 24), // Success Icon Container( width: 80, height: 80, decoration: BoxDecoration( gradient: LinearGradient( colors: [ Colors.green.shade400, Colors.green.shade600, ], ), shape: BoxShape.circle, boxShadow: [ BoxShadow( color: Colors.green.withValues(alpha: 77), blurRadius: 20, offset: const Offset(0, 8), ), ], ), child: const Icon( Icons.check, color: Colors.white, size: 40, ), ).animate().scale(duration: 300.ms, curve: Curves.elasticOut), const SizedBox(height: 24), // Title Text( 'Objekt gefunden', style: theme.textTheme.headlineSmall?.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 24), // Object Info Card Padding( padding: const EdgeInsets.symmetric(horizontal: 24), child: Card( elevation: 0, color: Colors.grey.shade50, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), side: BorderSide(color: Colors.grey.shade200), ), child: Padding( padding: const EdgeInsets.all(20), child: Column( children: [ _buildInfoRow( context, 'Code', object.code, Icons.qr_code, ), const Divider(height: 24), _buildInfoRow( context, 'Typ', object.typeName ?? object.subtype.toUpperCase(), Icons.inventory_2, ), const Divider(height: 24), _buildStateRow( context, 'Aktueller Status', object.state, currentStateColor, ), if (containerInfo != null) ...[ const Divider(height: 24), _buildInfoRow( context, 'Container', containerInfo!, Icons.inventory_2, ), ], ], ), ), ), ), const SizedBox(height: 24), // State Transition Container( margin: const EdgeInsets.symmetric(horizontal: 24), padding: const EdgeInsets.all(20), decoration: BoxDecoration( gradient: LinearGradient( colors: [ suggestedStateColor.withValues(alpha: 26), suggestedStateColor.withValues(alpha: 13), ], ), borderRadius: BorderRadius.circular(16), border: Border.all(color: suggestedStateColor.withValues(alpha: 77)), ), child: Column( children: [ Text( 'Status wird geändert zu:', style: theme.textTheme.bodySmall?.copyWith( color: Colors.grey.shade600, ), ), const SizedBox(height: 8), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 12, height: 12, decoration: BoxDecoration( color: suggestedStateColor, shape: BoxShape.circle, ), ), const SizedBox(width: 8), Text( ObjectStateInfo.getDisplayName(suggestedState), style: theme.textTheme.titleMedium?.copyWith( fontWeight: FontWeight.w600, color: suggestedStateColor, ), ), ], ), ], ), ), const SizedBox(height: 32), // Action Buttons Padding( padding: const EdgeInsets.symmetric(horizontal: 24), child: Row( children: [ Expanded( child: OutlinedButton( onPressed: onCancel, style: OutlinedButton.styleFrom( padding: const EdgeInsets.symmetric(vertical: 16), ), child: const Text('Abbrechen'), ), ), const SizedBox(width: 16), Expanded( flex: 2, child: ElevatedButton( onPressed: onConfirm, style: ElevatedButton.styleFrom( padding: const EdgeInsets.symmetric(vertical: 16), ), child: const Text('Bestätigen'), ), ), ], ), ), const SizedBox(height: 32), ], ), ); } Widget _buildInfoRow(BuildContext context, String label, String value, IconData icon) { final theme = Theme.of(context); return Row( children: [ Container( padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: theme.colorScheme.primary.withValues(alpha: 26), borderRadius: BorderRadius.circular(10), ), child: Icon( icon, size: 20, color: theme.colorScheme.primary, ), ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( label, style: theme.textTheme.bodySmall?.copyWith( color: Colors.grey.shade600, ), ), const SizedBox(height: 2), Text( value, style: theme.textTheme.bodyLarge?.copyWith( fontWeight: FontWeight.w600, ), ), ], ), ), ], ); } Widget _buildStateRow(BuildContext context, String label, String state, Color color) { final theme = Theme.of(context); return Row( children: [ Container( padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: color.withValues(alpha: 26), borderRadius: BorderRadius.circular(10), ), child: Icon( Icons.info, size: 20, color: color, ), ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( label, style: theme.textTheme.bodySmall?.copyWith( color: Colors.grey.shade600, ), ), const SizedBox(height: 2), Container( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), decoration: BoxDecoration( color: color.withValues(alpha: 26), borderRadius: BorderRadius.circular(20), ), child: Text( ObjectStateInfo.getDisplayName(state), style: theme.textTheme.bodyMedium?.copyWith( fontWeight: FontWeight.w600, color: color, ), ), ), ], ), ), ], ); } }