2022-07-21 05:29:57 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-08-05 11:21:15 +00:00
|
|
|
import 'package:photos/ente_theme_data.dart';
|
2022-08-04 16:16:16 +00:00
|
|
|
import 'package:photos/models/search/album_search_result.dart';
|
|
|
|
import 'package:photos/models/search/file_search_result.dart';
|
|
|
|
import 'package:photos/models/search/location_search_result.dart';
|
|
|
|
import 'package:photos/models/search/search_results.dart';
|
2022-08-02 03:32:55 +00:00
|
|
|
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';
|
2022-08-02 12:59:24 +00:00
|
|
|
import 'package:photos/ui/viewer/search/search_result_widgets/location_result_widget.dart';
|
2022-07-19 11:52:16 +00:00
|
|
|
|
2022-08-04 16:16:16 +00:00
|
|
|
class SearchResultsSuggestionsWidget extends StatelessWidget {
|
|
|
|
final List<SearchResult> results;
|
|
|
|
const SearchResultsSuggestionsWidget(
|
|
|
|
this.results, {
|
2022-07-28 10:15:46 +00:00
|
|
|
Key key,
|
2022-07-27 11:51:43 +00:00
|
|
|
}) : super(key: key);
|
2022-07-19 11:52:16 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-08-05 16:56:06 +00:00
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.transparent,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Colors.black.withOpacity(0.2),
|
|
|
|
spreadRadius: -3,
|
|
|
|
blurRadius: 6,
|
|
|
|
offset: const Offset(0, 6),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-06 08:42:28 +00:00
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
|
|
|
child: Container(
|
|
|
|
margin: const EdgeInsets.only(top: 8),
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
maxHeight: MediaQuery.of(context).size.height * 0.5,
|
|
|
|
),
|
|
|
|
child: ListView.builder(
|
|
|
|
shrinkWrap: true,
|
|
|
|
itemCount: results.length + 1,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
if (results.length == index) {
|
|
|
|
return Container(
|
|
|
|
height: 6,
|
|
|
|
color: Theme.of(context).colorScheme.searchResultsColor,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
final result = results[index];
|
|
|
|
if (result is AlbumSearchResult) {
|
|
|
|
return CollectionResultWidget(result);
|
|
|
|
} else if (result is FileSearchResult) {
|
|
|
|
return FilenameResultWidget(result);
|
|
|
|
} else if (result is LocationSearchResult) {
|
|
|
|
return LocationResultsWidget(result);
|
|
|
|
} else {
|
|
|
|
throw StateError("Invalid/Unsupported value");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2022-08-05 16:56:06 +00:00
|
|
|
),
|
2022-07-21 05:29:57 +00:00
|
|
|
),
|
|
|
|
);
|
2022-07-20 10:17:35 +00:00
|
|
|
}
|
|
|
|
}
|