Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add configurable bottom sheet header height

ashilkn0f2f7124f0c8
diff --git a/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/filter_options_bottom_sheet.dart b/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/filter_options_bottom_sheet.dart
index 48e9be05bb..b62350363e 100644
--- a/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/filter_options_bottom_sheet.dart
+++ b/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/filter_options_bottom_sheet.dart
@@ -35,14 +35,12 @@ class _FilterOptionsBottomSheetState extends State<FilterOptionsBottomSheet> {
return BottomSheetComponent(
title: l10n.filter,
closeTooltip: l10n.close,
- contentSpacing: 24,
content: ConstrainedBox(
constraints: BoxConstraints(
maxHeight:
MediaQuery.sizeOf(context).height * _maxContentHeightFactor,
),
child: SingleChildScrollView(
- clipBehavior: Clip.none,
child: SizedBox(
width: double.infinity,
child: Column(
diff --git a/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dart b/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dart
index fabc05a6c0..fcb88556e9 100644
--- a/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dart
+++ b/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dart
@@ -22,6 +22,7 @@ class _BottomSheetHeaderComponent extends StatelessWidget {
this.closeTooltip = 'Close',
this.textAlign,
this.isCentered = false,
+ this.height = _headerHeight,
});
final String? title;
@@ -35,6 +36,7 @@ class _BottomSheetHeaderComponent extends StatelessWidget {
final String closeTooltip;
final TextAlign? textAlign;
final bool isCentered;
+ final double height;
@override
Widget build(BuildContext context) {
@@ -60,7 +62,7 @@ class _BottomSheetHeaderComponent extends StatelessWidget {
final colors = context.componentColors;
return SizedBox(
- height: _headerHeight,
+ height: height,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
@@ -101,6 +103,7 @@ class BottomSheetComponent extends StatelessWidget {
this.textAlign,
this.crossAxisAlignment = CrossAxisAlignment.start,
this.padding = const EdgeInsets.all(Spacing.xl),
+ this.headerHeight = _headerHeight,
this.contentSpacing = Spacing.lg,
this.actionsTopSpacing = Spacing.lg,
this.backgroundColor,
@@ -123,6 +126,11 @@ class BottomSheetComponent extends StatelessWidget {
final TextAlign? textAlign;
final CrossAxisAlignment crossAxisAlignment;
final EdgeInsets padding;
+
+ /// Height of the default title and close-button header.
+ ///
+ /// Ignored when [header] is provided.
+ final double headerHeight;
final double contentSpacing;
final double actionsTopSpacing;
final Color? backgroundColor;
@@ -147,6 +155,7 @@ class BottomSheetComponent extends StatelessWidget {
closeTooltip: closeTooltip,
textAlign: textAlign,
isCentered: usesCenteredLayout,
+ height: headerHeight,
)
: null);
final effectiveContent =
diff --git a/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dart b/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dart
index 8912dd7f71..e2ae3e4427 100644
--- a/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dart
+++ b/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dart
@@ -55,6 +55,33 @@ void main() {
expect(find.text('Secondary'), findsOneWidget);
});
+ testWidgets('BottomSheetComponent supports custom header height', (
+ tester,
+ ) async {
+ await tester.pumpWidget(
+ _wrap(
+ const BottomSheetComponent(
+ title: 'Default header',
+ content: Text('Body copy'),
+ ),
+ ),
+ );
+
+ expect(_headerWithHeight('Default header', 38), findsOneWidget);
+
+ await tester.pumpWidget(
+ _wrap(
+ const BottomSheetComponent(
+ title: 'Custom header',
+ headerHeight: 46,
+ content: Text('Body copy'),
+ ),
+ ),
+ );
+
+ expect(_headerWithHeight('Custom header', 46), findsOneWidget);
+ });
+
testWidgets('BottomSheetComponent centers illustration message', (
tester,
) async {
@@ -312,3 +339,12 @@ Future<void> _openLauncher(
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
}
+
+Finder _headerWithHeight(String title, double height) {
+ return find.ancestor(
+ of: find.text(title),
+ matching: find.byWidgetPredicate(
+ (widget) => widget is SizedBox && widget.height == height,
+ ),
+ );
+}