Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NonScrollingWoltModalSheetPage page type #127

Merged
merged 3 commits into from
Jan 29, 2024

Conversation

ulusoyca
Copy link
Collaborator

@ulusoyca ulusoyca commented Jan 26, 2024

Description

This PR introduces a new page type, NonScrollingWoltModalSheetPage, to the WoltModalSheet package. The new page type extends the existing SliverWoltModalSheetPage and is tailored for content that adapts to available vertical space without the necessity for scrolling. This enhancement is made to support the use cases where the content is flexible in height but does not exceed the modal sheet's maximum height.

This addition came from the need to have a modal sheet page type that better suits content that is unlikely to require scrolling. This is particularly useful for modal content that dynamically sizes itself to the remaining space but remains within the viewport constraints, such as dynamic forms, confirmation dialogs, or any content with adaptive height requirements.

If content has a risk of exceeding the modal sheet's height, it is advisable to use SliverWoltModalSheetPage or WoltModalSheetPage for their scrolling capabilities.

Key Features

  • Flex Layout Compatibility: The new page type utilizes a Column with Flexible widgets, allowing content to stretch or compress based on the modal's height.

  • No Scroll Requirement: It's optimized for scenarios where the content fits within the viewport, making it an efficient choice for fixed or intrinsic sized content.

  • Simplified Content Specification: Developers can pass a single Widget as the main content, making the API cleaner and more intuitive.

Implementation Notes

FlexibleWoltModalSheetPage passes a SliverFillViewport with a single child to mainContentSlivers, ensuring that the content is laid out correctly within the modal sheet.
Default values and behavior are inherited from SliverWoltModalSheetPage, maintaining consistency within the package.

Usage Example

The code snippet below produces the screenshots attached in bottomsheet type. The dialog example shows the configuration without top bar.

return NonScrollingWoltModalSheetPage(
      leadingNavBarWidget: WoltModalSheetBackButton(onBackPressed: onBackPressed),
      trailingNavBarWidget: WoltModalSheetCloseButton(onClosed: onClosed),
      hasTopBarLayer: true,
      navBarHeight: 72.0,
      topBarTitle: const Text('Non-scrolling page'),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          const Flexible(
            flex: 2,
            child: Center(
              child: Text('Flex: 2', style: textStyle),
            ),
          ),
          const Flexible(
            flex: 3,
            child: ColoredBox(
              color: Colors.amber,
              child: Center(child: Text('Flex: 3', style: textStyle)),
            ),
          ),
          Flexible(
            flex: 1,
            child: GestureDetector(
              onTap: isLastPage ? onClosed : nextPagePressed,
              child: ColoredBox(
                color: Colors.green,
                child: Center(
                  child: Text(
                    "Flex: 1\n Tap here to ${isLastPage ? 'close' : 'go to the next page'}",
                    style: textStyle,
                    textAlign: TextAlign.center,
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
Bottom sheet Dialog
image image

How to test

Use the playground app, and select WoltFlexibleSheetPage example
image

@ulusoyca ulusoyca requested a review from MbIXjkee January 26, 2024 13:32
@ulusoyca ulusoyca force-pushed the issue-124-introduce-non-scrollable-content branch from b7c9e31 to bf188ed Compare January 26, 2024 14:02
final Widget child;

/// Creates a page to be built within [WoltScrollableModalSheet].
FlexibleWoltModalSheetPage({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is flexible here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MbIXjkee As agreed, I renamed this class to NonScrollingWoltModalSheetPage. Check the commit: c48c897

@ulusoyca ulusoyca changed the title Add FlexibleWoltModalSheetPage for Non-Scrollable Content Add NonScrollingWoltModalSheetPage page type Jan 29, 2024
@ulusoyca ulusoyca force-pushed the issue-124-introduce-non-scrollable-content branch from 07cf17b to a27a028 Compare January 29, 2024 08:58
@ulusoyca ulusoyca enabled auto-merge January 29, 2024 09:02
Copy link
Collaborator

@MbIXjkee MbIXjkee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ulusoyca ulusoyca merged commit 339fce2 into main Jan 29, 2024
2 checks passed
@ulusoyca ulusoyca deleted the issue-124-introduce-non-scrollable-content branch January 29, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants