import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import '../../../../core/theme/app_theme.dart'; import '../../../../core/widgets/status_badge.dart'; import '../../data/models/route_model.dart'; class RouteCard extends StatelessWidget { final RouteModel route; final VoidCallback onTap; const RouteCard({ super.key, required this.route, required this.onTap, }); @override Widget build(BuildContext context) { return Card( child: InkWell( onTap: onTap, borderRadius: BorderRadius.circular(12), child: Padding( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Text( 'Route ${route.id}', style: Theme.of(context).textTheme.titleLarge, overflow: TextOverflow.ellipsis, ), ), StatusBadge( status: route.status.toString().split('.').last, ), ], ), const SizedBox(height: 12), Row( children: [ const Icon(Icons.calendar_today, size: 16, color: Colors.grey), const SizedBox(width: 8), Text( DateFormat('MMM dd, yyyy').format(route.date), style: Theme.of(context).textTheme.bodyMedium, ), ], ), const SizedBox(height: 8), Row( children: [ const Icon(Icons.location_on, size: 16, color: Colors.grey), const SizedBox(width: 8), Text( '${route.stops.length} stops', style: Theme.of(context).textTheme.bodyMedium, ), const SizedBox(width: 16), const Icon(Icons.directions_car, size: 16, color: Colors.grey), const SizedBox(width: 8), Text( '${route.totalDistance.toStringAsFixed(1)} km', style: Theme.of(context).textTheme.bodyMedium, ), ], ), const SizedBox(height: 12), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'Progress', style: Theme.of(context).textTheme.bodySmall, ), Text( '${route.completedStopsCount}/${route.totalStopsCount}', style: Theme.of(context).textTheme.bodySmall, ), ], ), const SizedBox(height: 8), ClipRRect( borderRadius: BorderRadius.circular(4), child: LinearProgressIndicator( value: route.progressPercentage / 100, minHeight: 8, backgroundColor: Colors.grey[300], valueColor: AlwaysStoppedAnimation( route.status == RouteStatus.completed ? AppTheme.completedColor : AppTheme.inProgressColor, ), ), ), ], ), ], ), ), ), ); } }