Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

create widget(page) for showing all search results of a specific search section

ashilkn1058962a9353
diff --git a/lib/ui/viewer/search/result/search_section_result_page.dart b/lib/ui/viewer/search/result/search_section_result_page.dart
new file mode 100644
index 0000000000..99b9502c1d
--- /dev/null
+++ b/lib/ui/viewer/search/result/search_section_result_page.dart
@@ -0,0 +1,87 @@
+import "package:flutter/material.dart";
+import "package:photos/models/search/search_result.dart";
+import "package:photos/models/search/search_types.dart";
+import "package:photos/ui/common/loading_widget.dart";
+import "package:photos/ui/components/title_bar_title_widget.dart";
+import "package:photos/ui/viewer/search/result/search_result_widget.dart";
+
+class SearchSectionResultPage extends StatefulWidget {
+ final SectionType sectionType;
+ const SearchSectionResultPage({required this.sectionType, super.key});
+
+ @override
+ State<SearchSectionResultPage> createState() =>
+ _SearchSectionResultPageState();
+}
+
+class _SearchSectionResultPageState extends State<SearchSectionResultPage> {
+ late final Future<List<SearchResult>> sectionData;
+ @override
+ void didChangeDependencies() {
+ super.didChangeDependencies();
+ sectionData = widget.sectionType.getData(limit: null, context: context);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ toolbarHeight: 48,
+ leadingWidth: 48,
+ leading: GestureDetector(
+ onTap: () {
+ Navigator.pop(context);
+ },
+ child: const Icon(
+ Icons.arrow_back_outlined,
+ ),
+ ),
+ ),
+ body: FutureBuilder(
+ future: sectionData,
+ builder: (context, snapshot) {
+ if (snapshot.hasData) {
+ final sectionResults = snapshot.data;
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding:
+ const EdgeInsets.symmetric(vertical: 4, horizontal: 16),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ TitleBarTitleWidget(
+ title: widget.sectionType.sectionTitle(context),
+ ),
+ Text(sectionResults!.length.toString()),
+ ],
+ ),
+ ),
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ vertical: 20,
+ horizontal: 16,
+ ),
+ child: ListView.separated(
+ itemBuilder: (context, index) {
+ return SearchResultWidget(sectionResults[index]);
+ },
+ separatorBuilder: (context, index) {
+ return const SizedBox(height: 10);
+ },
+ itemCount: sectionResults.length,
+ ),
+ ),
+ ),
+ ],
+ );
+ } else {
+ return const EnteLoadingWidget();
+ }
+ },
+ ),
+ );
+ }
+}