Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat: populate people as well

Prateek Sunalf22ad9611ff6
diff --git a/mobile/lib/models/search/search_types.dart b/mobile/lib/models/search/search_types.dart
index db2c9be797..fa177c92f6 100644
--- a/mobile/lib/models/search/search_types.dart
+++ b/mobile/lib/models/search/search_types.dart
@@ -97,19 +97,14 @@ extension SectionTypeExtensions on SectionType {
bool get isCTAVisible {
switch (this) {
case SectionType.face:
- return false;
case SectionType.magic:
- return false;
case SectionType.moment:
+ case SectionType.fileTypesAndExtension:
return false;
case SectionType.location:
- return true;
case SectionType.contacts:
- return true;
case SectionType.album:
return true;
- case SectionType.fileTypesAndExtension:
- return false;
}
}
@@ -122,19 +117,14 @@ extension SectionTypeExtensions on SectionType {
bool get isEmptyCTAVisible {
switch (this) {
case SectionType.face:
- return false;
case SectionType.magic:
- return false;
case SectionType.moment:
+ case SectionType.fileTypesAndExtension:
return false;
case SectionType.location:
- return true;
case SectionType.contacts:
- return true;
case SectionType.album:
return true;
- case SectionType.fileTypesAndExtension:
- return false;
}
}
diff --git a/mobile/lib/ui/settings/widgets/people_widget_settings.dart b/mobile/lib/ui/settings/widgets/people_widget_settings.dart
index 31853218ed..128af97ac5 100644
--- a/mobile/lib/ui/settings/widgets/people_widget_settings.dart
+++ b/mobile/lib/ui/settings/widgets/people_widget_settings.dart
@@ -1,9 +1,12 @@
import 'package:flutter/material.dart';
import "package:photos/generated/l10n.dart";
import 'package:photos/theme/ente_theme.dart';
+import "package:photos/ui/components/buttons/button_widget.dart";
import 'package:photos/ui/components/buttons/icon_button_widget.dart';
+import "package:photos/ui/components/models/button_type.dart";
import 'package:photos/ui/components/title_bar_title_widget.dart';
import 'package:photos/ui/components/title_bar_widget.dart';
+import "package:photos/ui/viewer/search/result/people_section_all_page.dart";
class PeopleWidgetSettings extends StatelessWidget {
const PeopleWidgetSettings({super.key});
@@ -12,6 +15,23 @@ class PeopleWidgetSettings extends StatelessWidget {
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
return Scaffold(
+ bottomNavigationBar: Padding(
+ padding: EdgeInsets.fromLTRB(
+ 16,
+ 8,
+ 16,
+ 8 + MediaQuery.viewPaddingOf(context).bottom,
+ ),
+ child: ButtonWidget(
+ buttonType: ButtonType.primary,
+ buttonSize: ButtonSize.large,
+ labelText: S.of(context).save,
+ shouldSurfaceExecutionStates: false,
+ onTap: () async {
+ // await _generateAlbumUrl();
+ },
+ ),
+ ),
body: CustomScrollView(
primary: false,
slivers: <Widget>[
@@ -33,7 +53,7 @@ class PeopleWidgetSettings extends StatelessWidget {
),
],
),
- if (1 == 1)
+ if (1 != 1)
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 32.0),
@@ -59,24 +79,8 @@ class PeopleWidgetSettings extends StatelessWidget {
),
)
else
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (context, index) {
- return const Padding(
- padding: EdgeInsets.symmetric(horizontal: 32.0),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Text(
- "Show a grid here with lots of data and a save button",
- ),
- ],
- ),
- );
- },
- childCount: 1,
- ),
+ const SliverToBoxAdapter(
+ child: PeopleSectionAllWidget(),
),
],
),
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 544dc4d98a..c8a76958bd 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
@@ -10,16 +10,31 @@ import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/common/loading_widget.dart";
import "package:photos/ui/viewer/search_tab/people_section.dart";
-class PeopleSectionAllPage extends StatefulWidget {
+class PeopleSectionAllPage extends StatelessWidget {
const PeopleSectionAllPage({
super.key,
});
@override
- State<PeopleSectionAllPage> createState() => _PeopleSectionAllPageState();
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: Text(SectionType.face.sectionTitle(context)),
+ centerTitle: false,
+ ),
+ body: const PeopleSectionAllWidget(),
+ );
+ }
}
-class _PeopleSectionAllPageState extends State<PeopleSectionAllPage> {
+class PeopleSectionAllWidget extends StatefulWidget {
+ const PeopleSectionAllWidget({super.key});
+
+ @override
+ State<PeopleSectionAllWidget> createState() => _PeopleSectionAllWidgetState();
+}
+
+class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
late Future<List<SearchResult>> sectionData;
final streamSubscriptions = <StreamSubscription>[];
@@ -55,67 +70,63 @@ class _PeopleSectionAllPageState extends State<PeopleSectionAllPage> {
MediaQuery.textScalerOf(context).scale(smallFontSize) / smallFontSize;
const horizontalEdgePadding = 20.0;
const gridPadding = 16.0;
- return Scaffold(
- appBar: AppBar(
- title: Text(SectionType.face.sectionTitle(context)),
- centerTitle: false,
- ),
- body: FutureBuilder<List<SearchResult>>(
- future: sectionData,
- builder: (context, snapshot) {
- if (snapshot.connectionState == ConnectionState.waiting) {
- return const Center(child: EnteLoadingWidget());
- } else if (snapshot.hasError) {
- return const Center(child: Icon(Icons.error_outline_rounded));
- } else if (!snapshot.hasData || snapshot.data!.isEmpty) {
- return Center(child: Text(S.of(context).noResultsFound + '.'));
- } else {
- final results = snapshot.data!;
- final screenWidth = MediaQuery.of(context).size.width;
- final crossAxisCount = (screenWidth / 100).floor();
- final itemSize = (screenWidth -
- ((horizontalEdgePadding * 2) +
- ((crossAxisCount - 1) * gridPadding))) /
- crossAxisCount;
+ return FutureBuilder<List<SearchResult>>(
+ future: sectionData,
+ builder: (context, snapshot) {
+ if (snapshot.connectionState == ConnectionState.waiting) {
+ return const Center(child: EnteLoadingWidget());
+ } else if (snapshot.hasError) {
+ return const Center(child: Icon(Icons.error_outline_rounded));
+ } else if (!snapshot.hasData || snapshot.data!.isEmpty) {
+ return Center(child: Text(S.of(context).noResultsFound + '.'));
+ } else {
+ final results = snapshot.data!;
+ final screenWidth = MediaQuery.of(context).size.width;
+ final crossAxisCount = (screenWidth / 100).floor();
- return GridView.builder(
- padding: const EdgeInsets.fromLTRB(
- horizontalEdgePadding,
- 16,
- horizontalEdgePadding,
- 96,
- ),
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- mainAxisSpacing: gridPadding,
- crossAxisSpacing: gridPadding,
- crossAxisCount: crossAxisCount,
- childAspectRatio:
- itemSize / (itemSize + (24 * textScaleFactor)),
- ),
- itemCount: results.length,
- itemBuilder: (context, index) {
- return PersonSearchExample(
- searchResult: results[index],
- size: itemSize,
- )
- .animate(delay: Duration(milliseconds: index * 13))
- .fadeIn(
- duration: const Duration(milliseconds: 225),
- curve: Curves.easeIn,
- )
- .slide(
- begin: const Offset(0, -0.06),
- curve: Curves.easeInOut,
- duration: const Duration(
- milliseconds: 225,
- ),
- );
- },
- );
- }
- },
- ),
+ final itemSize = (screenWidth -
+ ((horizontalEdgePadding * 2) +
+ ((crossAxisCount - 1) * gridPadding))) /
+ crossAxisCount;
+
+ return GridView.builder(
+ padding: const EdgeInsets.fromLTRB(
+ horizontalEdgePadding,
+ 16,
+ horizontalEdgePadding,
+ 96,
+ ),
+ shrinkWrap: true,
+ primary: false,
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+ mainAxisSpacing: gridPadding,
+ crossAxisSpacing: gridPadding,
+ crossAxisCount: crossAxisCount,
+ childAspectRatio: itemSize / (itemSize + (24 * textScaleFactor)),
+ ),
+ itemCount: results.length,
+ itemBuilder: (context, index) {
+ return PersonSearchExample(
+ searchResult: results[index],
+ size: itemSize,
+ )
+ .animate(delay: Duration(milliseconds: index * 13))
+ .fadeIn(
+ duration: const Duration(milliseconds: 225),
+ curve: Curves.easeIn,
+ )
+ .slide(
+ begin: const Offset(0, -0.06),
+ curve: Curves.easeInOut,
+ duration: const Duration(
+ milliseconds: 225,
+ ),
+ );
+ },
+ );
+ }
+ },
);
}
}