π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add AlbumDescriptionHeader widget for displaying album descriptions with dynamic height
AmanRajSinghMouryac7e22c44d77b
diff --git a/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/album_description_header.dart b/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/album_description_header.dartnew file mode 100644index 0000000000..c3b1411fd6--- /dev/null+++ b/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/album_description_header.dart@@ -0,0 +1,74 @@+import "package:ente_components/ente_components.dart";+import "package:flutter/material.dart";++class AlbumDescriptionHeader extends StatelessWidget+ implements PreferredSizeWidget {+ const AlbumDescriptionHeader._({+ required this.description,+ required double height,+ }) : _height = height;++ static const maxLines = 3;++ final String description;+ final double _height;++ static AlbumDescriptionHeader? maybeOf(+ BuildContext context,+ String? description,+ ) {+ final normalizedDescription = description?.trim();+ if (normalizedDescription == null || normalizedDescription.isEmpty) {+ return null;+ }++ return AlbumDescriptionHeader._(+ description: normalizedDescription,+ height: preferredHeight(context, normalizedDescription),+ );+ }++ static double preferredHeight(BuildContext context, String? description) {+ final normalizedDescription = description?.trim();+ if (normalizedDescription == null || normalizedDescription.isEmpty) {+ return 0;+ }++ final painter = TextPainter(+ text: TextSpan(text: normalizedDescription, style: TextStyles.body),+ maxLines: maxLines,+ textDirection: Directionality.of(context),+ textScaler: MediaQuery.textScalerOf(context),+ )..layout(maxWidth: MediaQuery.sizeOf(context).width - Spacing.lg * 2);+ return painter.height + Spacing.lg;+ }++ @override+ Size get preferredSize => Size.fromHeight(_height);++ @override+ Widget build(BuildContext context) {+ return SizedBox(+ height: _height,+ child: Padding(+ padding: const EdgeInsets.fromLTRB(+ Spacing.lg,+ 0,+ Spacing.lg,+ Spacing.lg,+ ),+ child: Align(+ alignment: Alignment.topLeft,+ child: Text(+ description,+ maxLines: maxLines,+ overflow: TextOverflow.ellipsis,+ style: TextStyles.body.copyWith(+ color: context.componentColors.textLight,+ ),+ ),+ ),+ ),+ );+ }+}