Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Fix clipping issue at bottom of edit person screen

ashilknf4588703326f
diff --git a/mobile/lib/ui/viewer/people/person_clusters_page.dart b/mobile/lib/ui/viewer/people/person_clusters_page.dart
index 1fbd46ca19..3c083b2d4b 100644
--- a/mobile/lib/ui/viewer/people/person_clusters_page.dart
+++ b/mobile/lib/ui/viewer/people/person_clusters_page.dart
@@ -11,9 +11,11 @@ import "package:photos/models/ml/face/person.dart";
import "package:photos/services/machine_learning/face_ml/person/person_service.dart";
import "package:photos/services/search_service.dart";
import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/common/loading_widget.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";
+import "package:visibility_detector/visibility_detector.dart";
class PersonClustersPage extends StatefulWidget {
final PersonEntity person;
@@ -189,77 +191,27 @@ class _PersonClustersWidgetState extends State<PersonClustersWidget> {
final int crossAxisCount =
(constraints.maxWidth / columnWidth).floor().clamp(2, 5);
- // Calculate expected height based on number of rows
- final int rowCount = (keys.length / crossAxisCount).ceil();
- // Thumbnail height + text height + spacing
- final double expectedHeight = (rowCount * (110 + 30 + 8));
-
- return SizedBox(
- height: expectedHeight + 500,
- child: GridView.builder(
- physics:
- const NeverScrollableScrollPhysics(), // Disable scrolling
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: crossAxisCount,
- childAspectRatio:
- 1, // Adjust this to control height vs width
- crossAxisSpacing: 8,
- mainAxisSpacing: 8,
- ),
- itemCount: keys.length,
- itemBuilder: (context, index) {
- final String clusterID = keys[index];
- final List<EnteFile> files = clusters[clusterID]!;
-
- return GestureDetector(
- onTap: () {
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => ClusterPage(
- files,
- personID: widget.person,
- clusterID: clusterID,
- showNamingBanner: false,
- ),
- ),
- );
- },
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- SizedBox(
- width: 100,
- height: 100,
- child: ClipPath(
- clipper: ShapeBorderClipper(
- shape: ContinuousRectangleBorder(
- borderRadius: BorderRadius.circular(75),
- ),
- ),
- child: files.isNotEmpty
- ? PersonFaceWidget(
- files.first,
- clusterID: clusterID,
- )
- : const NoThumbnailWidget(
- addBorder: false,
- ),
- ),
- ),
- const SizedBox(height: 8),
- Text(
- context.l10n.memoryCount(
- files.length,
- NumberFormat().format(files.length),
- ),
- style: getEnteTextTheme(context).small,
- textAlign: TextAlign.center,
- ),
- ],
- ),
- );
- },
+ return GridView.builder(
+ shrinkWrap: true,
+ physics:
+ const NeverScrollableScrollPhysics(), // Disable scrolling
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+ crossAxisCount: crossAxisCount,
+ childAspectRatio: 1, // Adjust this to control height vs width
+ crossAxisSpacing: 8,
+ mainAxisSpacing: 8,
),
+ itemCount: keys.length,
+ itemBuilder: (context, index) {
+ final String clusterID = keys[index];
+ final List<EnteFile> files = clusters[clusterID]!;
+
+ return _ClusterWrapperForGird(
+ files,
+ clusterID,
+ widget.person,
+ );
+ },
);
},
);
@@ -273,3 +225,91 @@ class _PersonClustersWidgetState extends State<PersonClustersWidget> {
);
}
}
+
+class _ClusterWrapperForGird extends StatefulWidget {
+ final List<EnteFile> files;
+ final String clusterID;
+ final PersonEntity person;
+
+ const _ClusterWrapperForGird(
+ this.files,
+ this.clusterID,
+ this.person,
+ );
+
+ @override
+ State<_ClusterWrapperForGird> createState() => __ClusterWrapperForGirdState();
+}
+
+class __ClusterWrapperForGirdState extends State<_ClusterWrapperForGird> {
+ bool _isVisible = false;
+ @override
+ Widget build(BuildContext context) {
+ final loadingColor = getEnteColorScheme(context).strokeMuted;
+ return VisibilityDetector(
+ key: ValueKey(widget.clusterID),
+ onVisibilityChanged: (info) {
+ if (!_isVisible && info.visibleFraction >= 0.01) {
+ setState(() {
+ _isVisible = true;
+ });
+ }
+ },
+ child: GestureDetector(
+ onTap: () {
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (context) => ClusterPage(
+ widget.files,
+ personID: widget.person,
+ clusterID: widget.clusterID,
+ showNamingBanner: false,
+ ),
+ ),
+ );
+ },
+ child: _isVisible
+ ? Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ SizedBox(
+ width: 100,
+ height: 100,
+ child: ClipPath(
+ clipper: ShapeBorderClipper(
+ shape: ContinuousRectangleBorder(
+ borderRadius: BorderRadius.circular(75),
+ ),
+ ),
+ child: widget.files.isNotEmpty
+ ? PersonFaceWidget(
+ widget.files.first,
+ clusterID: widget.clusterID,
+ )
+ : const NoThumbnailWidget(
+ addBorder: false,
+ ),
+ ),
+ ),
+ const SizedBox(height: 8),
+ Text(
+ context.l10n.memoryCount(
+ widget.files.length,
+ NumberFormat().format(widget.files.length),
+ ),
+ style: getEnteTextTheme(context).small,
+ textAlign: TextAlign.center,
+ ),
+ ],
+ )
+ : SizedBox(
+ width: 100,
+ height: 100,
+ child: EnteLoadingWidget(
+ color: loadingColor,
+ ),
+ ),
+ ),
+ );
+ }
+}