Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix search section large text overflows

ashilkn2f3923c6260e
diff --git a/mobile/apps/photos/changes/search-sections-large-text.md b/mobile/apps/photos/changes/search-sections-large-text.md
new file mode 100644
index 0000000000..bd6e7b8f46
--- /dev/null
+++ b/mobile/apps/photos/changes/search-sections-large-text.md
@@ -0,0 +1 @@
+- Improved Search section layouts for larger text sizes.
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart
index 71e3101fd3..ed204ce066 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart
@@ -167,7 +167,7 @@ class _ContactsSectionState extends State<ContactsSection> {
),
const SizedBox(height: 4),
SearchTabHorizontalListView(
- height: 92,
+ height: ContactRecommendation.heightFor(context),
itemCount: _contactSearchResults.length + 1,
itemBuilder: (context, index) {
if (index == _contactSearchResults.length) {
@@ -189,9 +189,20 @@ class _ContactsSectionState extends State<ContactsSection> {
}
class ContactRecommendation extends StatefulWidget {
+ static const _avatarSize = 62.0;
+ static const _height = 92.0;
+
final GenericSearchResult contactSearchResult;
const ContactRecommendation(this.contactSearchResult, {super.key});
+ static double heightFor(BuildContext context) {
+ return (_avatarSize +
+ 10 +
+ searchTabSingleLineTextHeight(context, TextStyles.mini))
+ .clamp(_height, double.infinity)
+ .toDouble();
+ }
+
@override
State<ContactRecommendation> createState() => _ContactRecommendationState();
}
@@ -222,13 +233,13 @@ class _ContactRecommendationState extends State<ContactRecommendation> {
children: [
ClipOval(
child: SizedBox(
- width: 62,
- height: 62,
+ width: ContactRecommendation._avatarSize,
+ height: ContactRecommendation._avatarSize,
child: ContactAvatarWidget(
contactUserId: contactUserId,
email: contactEmail,
personId: personId,
- size: 62,
+ size: ContactRecommendation._avatarSize,
),
),
),
@@ -249,6 +260,7 @@ class _ContactRecommendationState extends State<ContactRecommendation> {
class ContactCTA extends StatelessWidget {
static const _inviteAsset = "assets/invite_contact.svg";
+ static const _iconSize = 62.0;
const ContactCTA({super.key});
@@ -263,8 +275,8 @@ class ContactCTA extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
- width: 62,
- height: 62,
+ width: _iconSize,
+ height: _iconSize,
decoration: BoxDecoration(
color: colorScheme.fill,
shape: BoxShape.circle,
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/file_type_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/file_type_section.dart
index 235ad9d2e1..7b2df9493f 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/file_type_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/file_type_section.dart
@@ -71,7 +71,7 @@ class FileTypeSection extends StatelessWidget {
const SectionHeader(SectionType.fileTypesAndExtension, hasMore: true),
const SizedBox(height: 8),
SearchTabHorizontalListView(
- height: 56,
+ height: _FileTypeCard.heightFor(context),
itemCount: previewTiles.length,
itemBuilder: (context, index) {
return _FileTypeRecommendation(previewTiles[index]);
@@ -191,15 +191,26 @@ class _FileTypeRecommendationState extends State<_FileTypeRecommendation> {
class _FileTypeCard extends StatelessWidget {
static const width = 108.0;
- static const height = 56.0;
+ static const _height = 56.0;
+ static const _labelTop = 31.0;
+ static const _labelBottomPadding = 8.0;
final _FileTypeTile tile;
const _FileTypeCard(this.tile);
+ static double heightFor(BuildContext context) {
+ return (_labelTop +
+ searchTabSingleLineTextHeight(context, _labelStyle(Colors.black)) +
+ _labelBottomPadding)
+ .clamp(_height, double.infinity)
+ .toDouble();
+ }
+
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
+ final height = heightFor(context);
return CustomPaint(
painter: _FileTypeCardBackgroundPainter(colorScheme.fill),
child: SizedBox(
@@ -210,16 +221,10 @@ class _FileTypeCard extends StatelessWidget {
Positioned(
left: 13,
right: 38,
- top: 31,
- height: 17,
+ top: _labelTop,
child: Text(
tile.label,
- style: TextStyles.mini.copyWith(
- color: colorScheme.textBase,
- fontSize: 12.461538,
- fontWeight: FontWeight.w700,
- height: 16.615385 / 12.461538,
- ),
+ style: _labelStyle(colorScheme.textBase),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
@@ -242,6 +247,15 @@ class _FileTypeCard extends StatelessWidget {
),
);
}
+
+ static TextStyle _labelStyle(Color color) {
+ return TextStyles.mini.copyWith(
+ color: color,
+ fontSize: 12.461538,
+ fontWeight: FontWeight.w700,
+ height: 16.615385 / 12.461538,
+ );
+ }
}
class _FileExtensionPill extends StatelessWidget {
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/locations_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/locations_section.dart
index 4ee3719b81..7293bb9a00 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/locations_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/locations_section.dart
@@ -117,7 +117,7 @@ class _LocationsSectionState extends State<LocationsSection> {
),
const SizedBox(height: 4),
SearchTabHorizontalListView(
- height: LocationRecommendation.height,
+ height: LocationRecommendation.heightFor(context),
itemCount: _locationsSearchResults.length + 1,
itemBuilder: (context, index) {
if (index == 0) {
@@ -138,13 +138,23 @@ class _LocationsSectionState extends State<LocationsSection> {
class LocationRecommendation extends StatelessWidget {
static const width = 108.0;
- static const height = 158.0;
+ static const _height = 158.0;
static const outerCornerRadius = 20.0;
static const cornerSmoothing = 1.0;
static const sideOfThumbnail = 108.0;
final GenericSearchResult locationSearchResult;
const LocationRecommendation(this.locationSearchResult, {super.key});
+ static double heightFor(BuildContext context) {
+ return (sideOfThumbnail +
+ 8 +
+ searchTabSingleLineTextHeight(context, TextStyles.body) +
+ 2 +
+ searchTabSingleLineTextHeight(context, TextStyles.mini))
+ .clamp(_height, double.infinity)
+ .toDouble();
+ }
+
@override
Widget build(BuildContext context) {
final heroTag =
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart
index 36ace7828c..d530c02c50 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart
@@ -109,7 +109,7 @@ class _MagicSectionState extends State<MagicSection> {
),
const SizedBox(height: 4),
SearchTabHorizontalListView(
- height: 158,
+ height: MagicRecommendation.heightFor(context),
itemCount: _magicSearchResults.length,
itemBuilder: (context, index) {
return MagicRecommendation(_magicSearchResults[index]);
@@ -125,12 +125,23 @@ class _MagicSectionState extends State<MagicSection> {
class MagicRecommendation extends StatelessWidget {
static const _width = 108.0;
+ static const _height = 158.0;
static const _thumbnailSize = 108.0;
static const _cornerRadius = 20.0;
static const _cornerSmoothing = 1.0;
final GenericSearchResult magicSearchResult;
const MagicRecommendation(this.magicSearchResult, {super.key});
+ static double heightFor(BuildContext context) {
+ return (_thumbnailSize +
+ 8 +
+ searchTabSingleLineTextHeight(context, TextStyles.body) +
+ 2 +
+ searchTabSingleLineTextHeight(context, TextStyles.mini))
+ .clamp(_height, double.infinity)
+ .toDouble();
+ }
+
@override
Widget build(BuildContext context) {
final heroTag =
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dart
index 3906a859da..250bfdd335 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dart
@@ -1,4 +1,5 @@
import "dart:async";
+import "dart:math" as math;
import "package:ente_components/theme/text_styles.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
@@ -147,7 +148,7 @@ class SearchExampleRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SearchTabHorizontalListView(
- height: 158,
+ height: PersonSearchExample.heightFor(context),
itemCount: examples.length,
itemBuilder: (context, index) {
return PersonSearchExample(
@@ -172,6 +173,18 @@ class PersonSearchExample extends StatelessWidget {
this.size = 108,
});
+ static double heightFor(BuildContext context, {double size = 108}) {
+ final labelHeight =
+ size +
+ 8 +
+ searchTabSingleLineTextHeight(context, TextStyles.body) +
+ 2 +
+ searchTabSingleLineTextHeight(context, TextStyles.mini);
+ final clusterLabelHeight =
+ size + 6 + searchTabSingleLineTextHeight(context, TextStyles.body);
+ return math.max(158, math.max(labelHeight, clusterLabelHeight));
+ }
+
void toggleSelection() {
selectedPeople?.toggleSelection(
searchResult.params[kPersonParamID]! as String,
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab_horizontal_scroll.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab_horizontal_scroll.dart
index 1e97d76e43..cca266f629 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab_horizontal_scroll.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab_horizontal_scroll.dart
@@ -2,6 +2,15 @@ import "package:flutter/material.dart";
const searchTabHorizontalPadding = 15.0;
+double searchTabSingleLineTextHeight(BuildContext context, TextStyle style) {
+ final textPainter = TextPainter(
+ text: TextSpan(text: "Ag", style: style),
+ textDirection: Directionality.of(context),
+ textScaler: MediaQuery.textScalerOf(context),
+ )..layout();
+ return textPainter.height;
+}
+
class SearchTabHorizontalListView extends StatelessWidget {
const SearchTabHorizontalListView({
required this.height,
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/section_header.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/section_header.dart
index ec0460356b..a9525477ad 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/section_header.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/section_header.dart
@@ -6,6 +6,7 @@ import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/ui/viewer/search/result/people_section_all_page.dart";
import "package:photos/ui/viewer/search/result/search_section_all_page.dart";
+import "package:photos/ui/viewer/search_tab/search_tab_horizontal_scroll.dart";
class SectionHeader extends StatelessWidget {
final SectionType sectionType;
@@ -21,6 +22,7 @@ class SectionHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
+ final headerHeight = _sectionHeaderHeightFor(context);
return GestureDetector(
onTap: () {
if (hasMore) {
@@ -28,13 +30,18 @@ class SectionHeader extends StatelessWidget {
}
},
child: SizedBox(
- height: 38,
+ height: headerHeight,
child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Text(
- sectionType.sectionTitle(context),
- style: TextStyles.display3.copyWith(color: colorScheme.textBase),
+ Expanded(
+ child: Text(
+ sectionType.sectionTitle(context),
+ style: TextStyles.display3.copyWith(
+ color: colorScheme.textBase,
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
),
hasMore
? Row(
@@ -79,3 +86,10 @@ class SectionHeader extends StatelessWidget {
);
}
}
+
+double _sectionHeaderHeightFor(BuildContext context) {
+ return searchTabSingleLineTextHeight(
+ context,
+ TextStyles.display3,
+ ).clamp(38.0, double.infinity).toDouble();
+}