import 'package:flutter/material.dart'; import '../../data/search_repository.dart'; class SearchResultTile extends StatelessWidget { final SearchResult result; final VoidCallback onTap; const SearchResultTile({ super.key, required this.result, required this.onTap, }); IconData _iconForType(String type) { switch (type) { case 'house': case 'building': return Icons.home; case 'street': return Icons.add_road; case 'city': case 'town': case 'village': return Icons.location_city; case 'park': return Icons.park; case 'restaurant': return Icons.restaurant; case 'cafe': return Icons.local_cafe; case 'shop': case 'supermarket': return Icons.shopping_cart; case 'hotel': return Icons.hotel; case 'hospital': case 'pharmacy': return Icons.local_hospital; default: return Icons.place; } } @override Widget build(BuildContext context) { return ListTile( leading: CircleAvatar( backgroundColor: Theme.of(context).colorScheme.primaryContainer, child: Icon( _iconForType(result.type), color: Theme.of(context).colorScheme.onPrimaryContainer, size: 20, ), ), title: Text( result.name, maxLines: 1, overflow: TextOverflow.ellipsis, ), subtitle: Text( result.displayAddress, maxLines: 1, overflow: TextOverflow.ellipsis, style: Theme.of(context).textTheme.bodySmall, ), trailing: Text( result.type, style: Theme.of(context).textTheme.labelSmall?.copyWith( color: Theme.of(context).colorScheme.outline, ), ), onTap: onTap, ); } }