Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob] better visualization of cluster analysis

laurenspriem517b099de877
diff --git a/mobile/lib/ui/viewer/people/cluster_breakup_page.dart b/mobile/lib/ui/viewer/people/cluster_breakup_page.dart
new file mode 100644
index 0000000000..e91909f471
--- /dev/null
+++ b/mobile/lib/ui/viewer/people/cluster_breakup_page.dart
@@ -0,0 +1,124 @@
+import "package:flutter/material.dart";
+import "package:photos/models/file/file.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/viewer/file/no_thumbnail_widget.dart";
+import "package:photos/ui/viewer/people/cluster_page.dart";
+import "package:photos/ui/viewer/search/result/person_face_widget.dart";
+
+class ClusterBreakupPage extends StatefulWidget {
+ final Map<int, List<EnteFile>> newClusterIDsToFiles;
+ final String title;
+
+ const ClusterBreakupPage(
+ this.newClusterIDsToFiles,
+ this.title, {
+ super.key,
+ });
+
+ @override
+ State<ClusterBreakupPage> createState() => _ClusterBreakupPageState();
+}
+
+class _ClusterBreakupPageState extends State<ClusterBreakupPage> {
+ @override
+ Widget build(BuildContext context) {
+ final keys = widget.newClusterIDsToFiles.keys.toList();
+ final clusterIDsToFiles = widget.newClusterIDsToFiles;
+
+ return Scaffold(
+ appBar: AppBar(
+ title: Text(widget.title),
+ ),
+ body: ListView.builder(
+ itemCount: widget.newClusterIDsToFiles.keys.length,
+ itemBuilder: (context, index) {
+ final int clusterID = keys[index];
+ final List<EnteFile> files = clusterIDsToFiles[keys[index]]!;
+ return InkWell(
+ onTap: () {
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (context) => ClusterPage(
+ files,
+ clusterID: index,
+ appendTitle: "(Analysis)",
+ ),
+ ),
+ );
+ },
+ child: Container(
+ padding: const EdgeInsets.all(8.0),
+ child: Row(
+ children: <Widget>[
+ SizedBox(
+ width: 64,
+ height: 64,
+ child: files.isNotEmpty
+ ? ClipRRect(
+ borderRadius: const BorderRadius.all(
+ Radius.elliptical(16, 12),),
+ child: PersonFaceWidget(
+ files.first,
+ clusterID: clusterID,
+ ),
+ )
+ : const ClipRRect(
+ borderRadius:
+ BorderRadius.all(Radius.elliptical(16, 12)),
+ child: NoThumbnailWidget(
+ addBorder: false,
+ ),
+ ),
+ ),
+ const SizedBox(
+ width: 8.0,
+ ), // Add some spacing between the thumbnail and the text
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8.0),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: <Widget>[
+ Text(
+ "${clusterIDsToFiles[keys[index]]!.length} photos",
+ style: getEnteTextTheme(context).body,
+ ),
+ // GestureDetector(
+ // onTap: () async {
+ // try {
+ // final int result = await FaceMLDataDB
+ // .instance
+ // .removeClusterToPerson(
+ // personID: widget.person.remoteID,
+ // clusterID: clusterID,
+ // );
+ // _logger.info(
+ // "Removed cluster $clusterID from person ${widget.person.remoteID}, result: $result",
+ // );
+ // Bus.instance.fire(PeopleChangedEvent());
+ // setState(() {});
+ // } catch (e) {
+ // _logger.severe(
+ // "removing cluster from person,",
+ // e,
+ // );
+ // }
+ // },
+ // child: const Icon(
+ // CupertinoIcons.minus_circled,
+ // color: Colors.red,
+ // ),
+ // ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ },
+ ),
+ );
+ }
+}