import 'package:flutter/material.dart'; import '../../data/routing_repository.dart'; class RouteSummary extends StatelessWidget { final RouteData route; final String profile; final bool isSelected; final VoidCallback? onTap; const RouteSummary({ super.key, required this.route, required this.profile, this.isSelected = false, this.onTap, }); IconData _profileIcon(String profile) { switch (profile) { case 'walking': return Icons.directions_walk; case 'cycling': return Icons.directions_bike; case 'driving': default: return Icons.directions_car; } } @override Widget build(BuildContext context) { final colorScheme = Theme.of(context).colorScheme; return Card( color: isSelected ? colorScheme.primaryContainer : colorScheme.surfaceContainerHighest, child: InkWell( onTap: onTap, borderRadius: BorderRadius.circular(12), child: Padding( padding: const EdgeInsets.all(16), child: Row( children: [ Icon( _profileIcon(profile), size: 32, color: isSelected ? colorScheme.onPrimaryContainer : colorScheme.onSurfaceVariant, ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( route.durationFormatted, style: Theme.of(context).textTheme.titleMedium?.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 2), Text( route.distanceFormatted, style: Theme.of(context).textTheme.bodySmall, ), ], ), ), if (route.legs.isNotEmpty && route.legs.first.summary.isNotEmpty) Expanded( child: Text( 'via ${route.legs.first.summary}', style: Theme.of(context).textTheme.bodySmall, maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.end, ), ), ], ), ), ), ); } }