Skip to content

armgit / ente

Public Imported from GitHub
0

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

Scale app bar filter chip height

ashilkncb4615860816
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart
index 5c9a63f9be..07441aaef8 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart
@@ -132,8 +132,8 @@ class CollectionPage extends StatelessWidget {
child: GalleryBoundariesProvider(
child: Scaffold(
appBar: PreferredSize(
- preferredSize: const Size.fromHeight(
- GalleryAppBarWidget.hierarchicalPreferredHeight,
+ preferredSize: Size.fromHeight(
+ GalleryAppBarWidget.hierarchicalPreferredHeight(context),
),
child: GalleryAppBarWidget(
galleryType,
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index 6780e7a188..403e31a2de 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -63,7 +63,9 @@ import 'package:photos/utils/magic_util.dart';
import "package:uuid/uuid.dart";
class GalleryAppBarWidget extends StatefulWidget {
- static const hierarchicalPreferredHeight = AppBarFilterChips.appBarHeight;
+ static double hierarchicalPreferredHeight(BuildContext context) {
+ return AppBarFilterChips.appBarHeight(context);
+ }
final GalleryType type;
final String? title;
@@ -198,9 +200,11 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
valueListenable: inheritedSearchFilterData!
.searchFilterDataProvider!
.isSearchingNotifier,
- child: const PreferredSize(
- preferredSize: Size.fromHeight(AppBarFilterChips.preferredHeight),
- child: AppBarFilterChips(),
+ child: PreferredSize(
+ preferredSize: Size.fromHeight(
+ AppBarFilterChips.preferredHeight(context),
+ ),
+ child: const AppBarFilterChips(),
),
builder: (context, isSearching, child) {
return AppBar(
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/uncategorized_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/uncategorized_page.dart
index 650a07d44a..c788a5b264 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/uncategorized_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/uncategorized_page.dart
@@ -92,8 +92,8 @@ class UnCategorizedPage extends StatelessWidget {
),
child: Scaffold(
appBar: PreferredSize(
- preferredSize: const Size.fromHeight(
- GalleryAppBarWidget.hierarchicalPreferredHeight,
+ preferredSize: Size.fromHeight(
+ GalleryAppBarWidget.hierarchicalPreferredHeight(context),
),
child: GalleryAppBarWidget(
appBarType,
diff --git a/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/app_bar_filter_chips.dart b/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/app_bar_filter_chips.dart
index 51aa24e879..bc891456c4 100644
--- a/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/app_bar_filter_chips.dart
+++ b/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/app_bar_filter_chips.dart
@@ -11,10 +11,24 @@ import "package:photos/utils/hierarchical_search_util.dart";
class AppBarFilterChips extends StatefulWidget {
const AppBarFilterChips({super.key});
- static const chipHeight = 40.0;
+ static const minChipHeight = 40.0;
static const bottomPadding = 8.0;
- static const preferredHeight = chipHeight + bottomPadding;
- static const appBarHeight = kToolbarHeight + preferredHeight;
+ static const _textVerticalPadding = 24.0;
+ static const _labelLineHeight = 16.0;
+
+ static double chipHeight(BuildContext context) {
+ final textHeight = MediaQuery.textScalerOf(context).scale(_labelLineHeight);
+ final scaledChipHeight = _textVerticalPadding + textHeight;
+ return scaledChipHeight > minChipHeight ? scaledChipHeight : minChipHeight;
+ }
+
+ static double preferredHeight(BuildContext context) {
+ return chipHeight(context) + bottomPadding;
+ }
+
+ static double appBarHeight(BuildContext context) {
+ return kToolbarHeight + preferredHeight(context);
+ }
@override
State<AppBarFilterChips> createState() => _AppBarFilterChipsState();
@@ -81,17 +95,22 @@ class _AppBarFilterChipsState extends State<AppBarFilterChips> {
return const SizedBox.shrink();
}
+ final chipHeight = AppBarFilterChips.chipHeight(context);
+
return Padding(
padding: const EdgeInsets.only(bottom: AppBarFilterChips.bottomPadding),
child: SizedBox(
- height: AppBarFilterChips.chipHeight,
+ height: chipHeight,
child: SingleChildScrollView(
- clipBehavior: Clip.none,
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Row(
children: [
- _buildAllFiltersButton(context, searchFilterDataProvider),
+ _buildAllFiltersButton(
+ context,
+ searchFilterDataProvider,
+ chipHeight,
+ ),
for (final filter in appliedFilters)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
@@ -112,11 +131,12 @@ class _AppBarFilterChipsState extends State<AppBarFilterChips> {
Widget _buildAllFiltersButton(
BuildContext context,
SearchFilterDataProvider searchFilterDataProvider,
+ double chipHeight,
) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: SizedBox(
- height: AppBarFilterChips.chipHeight,
+ height: chipHeight,
child: Center(
child: IconButtonComponent(
icon: const Icon(Icons.filter_list_rounded),
diff --git a/mobile/apps/photos/lib/ui/viewer/location/location_screen.dart b/mobile/apps/photos/lib/ui/viewer/location/location_screen.dart
index fbcc96a6d6..fca13d1cee 100644
--- a/mobile/apps/photos/lib/ui/viewer/location/location_screen.dart
+++ b/mobile/apps/photos/lib/ui/viewer/location/location_screen.dart
@@ -43,7 +43,9 @@ class _LocationScreenState extends State<LocationScreen> {
@override
Widget build(BuildContext context) {
final heightOfStatusBar = MediaQuery.of(context).viewPadding.top;
- const heightOfAppBar = GalleryAppBarWidget.hierarchicalPreferredHeight;
+ final heightOfAppBar = GalleryAppBarWidget.hierarchicalPreferredHeight(
+ context,
+ );
final locationTag = InheritedLocationScreenState.of(
context,
).locationTagEntity.item;
@@ -59,7 +61,7 @@ class _LocationScreenState extends State<LocationScreen> {
),
child: Scaffold(
appBar: PreferredSize(
- preferredSize: const Size(double.infinity, heightOfAppBar),
+ preferredSize: Size(double.infinity, heightOfAppBar),
child: GalleryAppBarWidget(
GalleryType.locationTag,
locationTag.name,
diff --git a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
index 12b36a0b04..3be6a4a866 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
@@ -30,7 +30,9 @@ const kShowUnnamedIgnoredPersonEventSource =
"_AppBarWidgetState._showPersonUnnamedDelete";
class PeopleAppBar extends StatefulWidget {
- static const hierarchicalPreferredHeight = AppBarFilterChips.appBarHeight;
+ static double hierarchicalPreferredHeight(BuildContext context) {
+ return AppBarFilterChips.appBarHeight(context);
+ }
final GalleryType type;
final String? title;
@@ -173,9 +175,11 @@ class _AppBarWidgetState extends State<PeopleAppBar> {
valueListenable: inheritedSearchFilterData!
.searchFilterDataProvider!
.isSearchingNotifier,
- child: const PreferredSize(
- preferredSize: Size.fromHeight(AppBarFilterChips.preferredHeight),
- child: AppBarFilterChips(),
+ child: PreferredSize(
+ preferredSize: Size.fromHeight(
+ AppBarFilterChips.preferredHeight(context),
+ ),
+ child: const AppBarFilterChips(),
),
builder: (context, isSearching, child) {
return AppBar(
diff --git a/mobile/apps/photos/lib/ui/viewer/people/people_page.dart b/mobile/apps/photos/lib/ui/viewer/people/people_page.dart
index a90bf9e6fc..22e8e8ffc9 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/people_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/people_page.dart
@@ -251,7 +251,7 @@ class _PeoplePageState extends State<PeoplePage> {
appBar: PreferredSize(
preferredSize: Size.fromHeight(
widget.searchResult != null
- ? PeopleAppBar.hierarchicalPreferredHeight
+ ? PeopleAppBar.hierarchicalPreferredHeight(context)
: 50.0,
),
child: PeopleAppBar(
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart
index a2f3037c69..f0f16243bb 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart
@@ -153,6 +153,11 @@ class _ContactResultPageState extends State<ContactResultPage> {
: const EmptyState(),
);
+ final appBarHeight = _ContactResultAppBar.preferredHeight(
+ context,
+ isHierarchicalSearchable: true,
+ );
+
return GalleryBoundariesProvider(
child: GalleryFilesState(
child: InheritedSearchFilterDataWrapper(
@@ -160,16 +165,16 @@ class _ContactResultPageState extends State<ContactResultPage> {
child: Scaffold(
backgroundColor: getEnteColorScheme(context).backgroundColour,
appBar: PreferredSize(
- preferredSize: Size.fromHeight(
- _ContactResultAppBar.preferredHeight(
- isHierarchicalSearchable: true,
- ),
- ),
+ preferredSize: Size.fromHeight(appBarHeight),
child: widget.enableGrouping
- ? const _ContactResultAppBar(isHierarchicalSearchable: true)
- : const _AppBarWithBoundary(
+ ? _ContactResultAppBar(
+ isHierarchicalSearchable: true,
+ height: appBarHeight,
+ )
+ : _AppBarWithBoundary(
child: _ContactResultAppBar(
isHierarchicalSearchable: true,
+ height: appBarHeight,
),
),
),
@@ -577,19 +582,24 @@ class _ContactResultAppBar extends StatelessWidget
static const _toolbarHeight = 56.0;
final bool isHierarchicalSearchable;
+ final double height;
- const _ContactResultAppBar({required this.isHierarchicalSearchable});
+ const _ContactResultAppBar({
+ required this.isHierarchicalSearchable,
+ required this.height,
+ });
- static double preferredHeight({required bool isHierarchicalSearchable}) {
+ static double preferredHeight(
+ BuildContext context, {
+ required bool isHierarchicalSearchable,
+ }) {
return isHierarchicalSearchable
- ? AppBarFilterChips.appBarHeight
+ ? AppBarFilterChips.appBarHeight(context)
: _toolbarHeight;
}
@override
- Size get preferredSize => Size.fromHeight(
- preferredHeight(isHierarchicalSearchable: isHierarchicalSearchable),
- );
+ Size get preferredSize => Size.fromHeight(height);
@override
Widget build(BuildContext context) {
@@ -610,9 +620,11 @@ class _ContactResultAppBar extends StatelessWidget
backgroundColor: colorScheme.backgroundColour,
surfaceTintColor: Colors.transparent,
titleSpacing: 0,
- bottom: const PreferredSize(
- preferredSize: Size.fromHeight(AppBarFilterChips.preferredHeight),
- child: Padding(
+ bottom: PreferredSize(
+ preferredSize: Size.fromHeight(
+ AppBarFilterChips.preferredHeight(context),
+ ),
+ child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 12),
child: AppBarFilterChips(),
),
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dart b/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dart
index a086ba77d4..c34fa06a66 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dart
@@ -209,8 +209,8 @@ class _MagicResultScreenState extends State<MagicResultScreen> {
searchFilterDataProvider: _searchFilterDataProvider,
child: Scaffold(
appBar: PreferredSize(
- preferredSize: const Size.fromHeight(
- GalleryAppBarWidget.hierarchicalPreferredHeight,
+ preferredSize: Size.fromHeight(
+ GalleryAppBarWidget.hierarchicalPreferredHeight(context),
),
child: _enableGrouping
? GalleryAppBarWidget(
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/search_result_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/search_result_page.dart
index 59f790bc22..6bebe46fae 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/search_result_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/search_result_page.dart
@@ -108,8 +108,8 @@ class _SearchResultPageState extends State<SearchResultPage> {
searchFilterDataProvider: _searchFilterDataProvider,
child: Scaffold(
appBar: PreferredSize(
- preferredSize: const Size.fromHeight(
- GalleryAppBarWidget.hierarchicalPreferredHeight,
+ preferredSize: Size.fromHeight(
+ GalleryAppBarWidget.hierarchicalPreferredHeight(context),
),
child: widget.enableGrouping
? GalleryAppBarWidget(
diff --git a/mobile/apps/photos/test/ui/viewer/hierarchicial_search/app_bar_filter_chips_test.dart b/mobile/apps/photos/test/ui/viewer/hierarchicial_search/app_bar_filter_chips_test.dart
new file mode 100644
index 0000000000..fecf5c086b
--- /dev/null
+++ b/mobile/apps/photos/test/ui/viewer/hierarchicial_search/app_bar_filter_chips_test.dart
@@ -0,0 +1,43 @@
+import "package:flutter/material.dart";
+import "package:flutter_test/flutter_test.dart";
+import "package:photos/ui/viewer/hierarchicial_search/app_bar_filter_chips.dart";
+
+void main() {
+ testWidgets("AppBarFilterChips keeps default heights without text scaling", (
+ tester,
+ ) async {
+ await tester.pumpWidget(
+ _wrap((context) {
+ expect(AppBarFilterChips.chipHeight(context), 40);
+ expect(AppBarFilterChips.preferredHeight(context), 48);
+ expect(AppBarFilterChips.appBarHeight(context), kToolbarHeight + 48);
+ return const SizedBox.shrink();
+ }),
+ );
+ });
+
+ testWidgets("AppBarFilterChips expands heights with scaled text", (
+ tester,
+ ) async {
+ await tester.pumpWidget(
+ _wrap((context) {
+ expect(AppBarFilterChips.chipHeight(context), 56);
+ expect(AppBarFilterChips.preferredHeight(context), 64);
+ expect(AppBarFilterChips.appBarHeight(context), kToolbarHeight + 64);
+ return const SizedBox.shrink();
+ }, textScaler: const TextScaler.linear(2)),
+ );
+ });
+}
+
+Widget _wrap(
+ WidgetBuilder builder, {
+ TextScaler textScaler = TextScaler.noScaling,
+}) {
+ return MaterialApp(
+ home: MediaQuery(
+ data: MediaQueryData(textScaler: textScaler),
+ child: Builder(builder: builder),
+ ),
+ );
+}