[mob][photos] Show all faces in 'All' section of faces

This commit is contained in:
ashilkn
2024-11-15 13:35:41 +05:30
parent 184323429a
commit 39252122ef
2 changed files with 40 additions and 8 deletions

View File

@@ -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<List<SearchResult>> searchResults;
class PeopleSectionAllPage extends StatefulWidget {
const PeopleSectionAllPage({
super.key,
required this.searchResults,
});
@override
State<PeopleSectionAllPage> createState() => _PeopleSectionAllPageState();
}
class _PeopleSectionAllPageState extends State<PeopleSectionAllPage> {
late Future<List<SearchResult>> sectionData;
final streamSubscriptions = <StreamSubscription>[];
@override
void initState() {
super.initState();
sectionData = SectionType.face.getData(context);
final streamsToListenTo = SectionType.face.viewAllUpdateEvents();
for (Stream<Event> 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<List<SearchResult>>(
future: searchResults,
future: sectionData,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());

View File

@@ -86,9 +86,7 @@ class _PeopleSectionState extends State<PeopleSection> {
if (shouldShowMore) {
routeToPage(
context,
PeopleSectionAllPage(
searchResults: Future.value(widget.examples),
),
const PeopleSectionAllPage(),
);
}
},