Skip to content

Commit

Permalink
set min height to 0 for dialog and bottom sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
ulusoyca committed Jul 8, 2024
1 parent 1fe7a8a commit d2bf505
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/src/modal_type/wolt_bottom_sheet_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class WoltBottomSheetType extends WoltModalType {
return BoxConstraints(
minWidth: availableSize.width,
maxWidth: availableSize.width,
minHeight: availableSize.height * 0.4,
minHeight: 0,
maxHeight: availableSize.height * 0.9,
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/modal_type/wolt_dialog_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ class WoltDialogType extends WoltModalType {
return BoxConstraints(
minWidth: width,
maxWidth: width,
minHeight: 360,
minHeight: 0,
maxHeight: max(360, availableHeight * 0.8),
);
}
return BoxConstraints(
minWidth: width,
maxWidth: width,
minHeight: availableHeight * 0.8,
minHeight: 0,
maxHeight: availableHeight * 0.8,
);
}
Expand Down
1 change: 1 addition & 0 deletions playground/lib/home/pages/modal_page_name.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ enum ModalPageName {
customTopBar,
updatePage,
inAppNavigation,
minHeight,
flexibleLayout,
}
10 changes: 10 additions & 0 deletions playground/lib/home/pages/root_sheet_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:demo_ui_components/demo_ui_components.dart';
import 'package:flutter/material.dart';
import 'package:playground/home/pages/modal_page_name.dart';
import 'package:playground/home/pages/sheet_page_with_custom_top_bar.dart';
import 'package:playground/home/pages/sheet_page_with_min_height.dart';
import 'package:playground/home/pages/sheet_page_with_update_page_method.dart';
import 'package:playground/home/pages/sheet_page_with_forced_max_height.dart';
import 'package:playground/home/pages/sheet_page_with_hero_image.dart';
Expand All @@ -27,6 +28,7 @@ class RootSheetPage {
SheetPageWithHeroImage.build(isLastPage: false),
SheetPageWithLazyList.build(isLastPage: false),
SheetPageWithTextField.build(isLastPage: false),
SheetPageWithMinHeight.build(isLastPage: false),
SheetPageWithInAppNavigation.build(isLastPage: false),
SheetPageWithCustomTopBar.build(isLastPage: false),
SheetPageWithNoPageTitleNoTopBar.build(isLastPage: false),
Expand Down Expand Up @@ -78,6 +80,11 @@ class RootSheetPage {
value: SheetPageWithLazyList.pageId,
isSelected: false,
),
WoltSelectionListItemData(
title: 'Page with min height constraint',
value: SheetPageWithMinHeight.pageId,
isSelected: false,
),
WoltSelectionListItemData(
title: 'Page with auto-focus text field',
value: SheetPageWithTextField.pageId,
Expand Down Expand Up @@ -132,6 +139,9 @@ class RootSheetPage {
case ModalPageName.textField:
destinationPage = SheetPageWithTextField.build();
break;
case ModalPageName.minHeight:
destinationPage = SheetPageWithMinHeight.build();
break;
case ModalPageName.noTitleNoTopBar:
destinationPage =
SheetPageWithNoPageTitleNoTopBar.build();
Expand Down
33 changes: 33 additions & 0 deletions playground/lib/home/pages/sheet_page_with_min_height.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:demo_ui_components/demo_ui_components.dart';
import 'package:flutter/material.dart';
import 'package:playground/home/pages/modal_page_name.dart';
import 'package:wolt_modal_sheet/wolt_modal_sheet.dart';

class SheetPageWithMinHeight {
SheetPageWithMinHeight._();

static const ModalPageName pageId = ModalPageName.minHeight;

static WoltModalSheetPage build({bool isLastPage = true}) {
return WoltModalSheetPage(
id: pageId,
hasTopBarLayer: false,
stickyActionBar: Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
child: Builder(builder: (context) {
return WoltElevatedButton(
onPressed: isLastPage
? Navigator.of(context).pop
: WoltModalSheet.of(context).showNext,
child: Text(isLastPage ? "Close" : "Next"),
);
}),
),
child: const Padding(
padding: EdgeInsets.only(bottom: 100, top: 16, left: 16, right: 16),
child: ModalSheetContentText(
'This page is added to test the constraints for minimum height.'),
),
);
}
}

0 comments on commit d2bf505

Please sign in to comment.