From 39252122efad4a4a301c577d81be709d6ccd2dfb Mon Sep 17 00:00:00 2001 From: ashilkn Date: Fri, 15 Nov 2024 13:35:41 +0530 Subject: [PATCH] [mob][photos] Show all faces in 'All' section of faces --- .../result/people_section_all_page.dart | 44 ++++++++++++++++--- .../ui/viewer/search_tab/people_section.dart | 4 +- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/mobile/lib/ui/viewer/search/result/people_section_all_page.dart b/mobile/lib/ui/viewer/search/result/people_section_all_page.dart index 43ddc7f268..17cb144f3c 100644 --- a/mobile/lib/ui/viewer/search/result/people_section_all_page.dart +++ b/mobile/lib/ui/viewer/search/result/people_section_all_page.dart @@ -1,17 +1,51 @@ +import "dart:async"; + import 'package:flutter/material.dart'; +import "package:photos/events/event.dart"; import "package:photos/generated/l10n.dart"; import "package:photos/models/search/search_result.dart"; +import "package:photos/models/search/search_types.dart"; import "package:photos/theme/ente_theme.dart"; import "package:photos/ui/viewer/search_tab/people_section.dart"; -class PeopleSectionAllPage extends StatelessWidget { - final Future> searchResults; - +class PeopleSectionAllPage extends StatefulWidget { const PeopleSectionAllPage({ super.key, - required this.searchResults, }); + @override + State createState() => _PeopleSectionAllPageState(); +} + +class _PeopleSectionAllPageState extends State { + late Future> sectionData; + final streamSubscriptions = []; + + @override + void initState() { + super.initState(); + sectionData = SectionType.face.getData(context); + + final streamsToListenTo = SectionType.face.viewAllUpdateEvents(); + for (Stream stream in streamsToListenTo) { + streamSubscriptions.add( + stream.listen((event) async { + setState(() { + sectionData = SectionType.face.getData(context); + }); + }), + ); + } + } + + @override + void dispose() { + for (var subscriptions in streamSubscriptions) { + subscriptions.cancel(); + } + super.dispose(); + } + @override Widget build(BuildContext context) { final smallFontSize = getEnteTextTheme(context).small.fontSize!; @@ -24,7 +58,7 @@ class PeopleSectionAllPage extends StatelessWidget { title: Text(S.of(context).people), ), body: FutureBuilder>( - future: searchResults, + future: sectionData, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: CircularProgressIndicator()); diff --git a/mobile/lib/ui/viewer/search_tab/people_section.dart b/mobile/lib/ui/viewer/search_tab/people_section.dart index 3460002583..df5c929e31 100644 --- a/mobile/lib/ui/viewer/search_tab/people_section.dart +++ b/mobile/lib/ui/viewer/search_tab/people_section.dart @@ -86,9 +86,7 @@ class _PeopleSectionState extends State { if (shouldShowMore) { routeToPage( context, - PeopleSectionAllPage( - searchResults: Future.value(widget.examples), - ), + const PeopleSectionAllPage(), ); } },