import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:photos/models/collection_items.dart'; import 'package:photos/models/file.dart'; import 'package:photos/ui/viewer/search/search_result_widgets/collection_result_widget.dart'; import 'package:photos/ui/viewer/search/search_result_widgets/filename_result_widget.dart'; import 'package:photos/ui/viewer/search/search_result_widgets/location_result_widget.dart'; class SearchResultsSuggestions extends StatelessWidget { final List matchedCollectionsWithThumbnail; final List matchedFiles; final Map> locationsToMatchedFiles; const SearchResultsSuggestions( this.matchedCollectionsWithThumbnail, this.matchedFiles, this.locationsToMatchedFiles, { Key key, }) : super(key: key); @override Widget build(BuildContext context) { List suggestions = []; for (CollectionWithThumbnail c in matchedCollectionsWithThumbnail) { suggestions.add(CollectionResultWidget(c)); } for (File file in matchedFiles) { suggestions.add(FilenameResultWidget(file)); } for (MapEntry> locationAndFiles in locationsToMatchedFiles.entries) { suggestions.add(LocationResultsWidget(locationAndFiles)); } return Container( constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.6), child: ListView.builder( itemCount: suggestions.length, itemBuilder: (context, index) { return suggestions[index]; }, ), ); } }