Skip to content

Commit

Permalink
Default scroll physics to clamping
Browse files Browse the repository at this point in the history
  • Loading branch information
ulusoyca committed Aug 1, 2024
1 parent bb8e363 commit e4245fc
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
28 changes: 28 additions & 0 deletions lib/src/theme/wolt_modal_sheet_default_theme_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,34 @@ class WoltModalSheetDefaultThemeData extends WoltModalSheetThemeData {
@override
bool get useSafeArea => true;

/// [mainContentScrollPhysics] sets the scrolling behavior for the main content area of the
/// WoltModalSheet, defaulting to [ClampingScrollPhysics]. This physics type is chosen for
/// several key reasons:
///
/// 1. **Prevent Overscroll:** ClampingScrollPhysics stops the scrollable content from moving
/// beyond the viewport's bounds. This clear boundary is crucial for drag-to-dismiss feature,
/// ensuring that any drag beyond the scroll limit is recognized as an intent to dismiss the
/// modal.
///
/// 2. **Clear Interaction Boundaries:** By preventing the content from bouncing or scrolling
/// past the edge, users receive clear feedback that reaching the end of the scrollable area can
/// transition to other interactions, like closing the modal. This helps avoid confusion
/// between scrolling and modal dismissal gestures.
///
/// 3. **Simplify Gesture Detection:** Using ClampingScrollPhysics simplifies the detection of
/// user gestures, differentiating more reliably between scrolling and actions intended to
/// dismiss the modal. This reduces the complexity and potential errors in handling these
/// interactions.
///
/// Choosing alternative scroll physics like [BouncingScrollPhysics] or [ElasticScrollPhysics]
/// could disrupt the drag-to-dismiss feature. These physics allow content to move beyond
/// scroll limits, which can interfere with gesture recognition, making it unclear whether a
/// gesture is intended for scrolling or dismissing the modal. As a result, drag-to-dismiss
/// would only be functional with a custom drag handle, limiting interaction flexibility on
/// main content area.
@override
ScrollPhysics? get mainContentScrollPhysics => const ClampingScrollPhysics();

@override
WoltModalTypeBuilder get modalTypeBuilder => (context) {
final width = MediaQuery.sizeOf(context).width;
Expand Down
26 changes: 25 additions & 1 deletion lib/src/theme/wolt_modal_sheet_theme_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,31 @@ class WoltModalSheetThemeData extends ThemeExtension<WoltModalSheetThemeData> {
/// If null, [WoltModalSheet] uses [Clip.antiAliasWithSaveLayer].
final Clip? clipBehavior;

/// The default value for [WoltModalSheet] scrollPhysics in the main content.
/// [mainContentScrollPhysics] sets the scrolling behavior for the main content area of the
/// WoltModalSheet, defaulting to [ClampingScrollPhysics]. This physics type is chosen for
/// several key reasons:
///
/// 1. **Prevent Overscroll:** ClampingScrollPhysics stops the scrollable content from moving
/// beyond the viewport's bounds. This clear boundary is crucial for drag-to-dismiss feature,
/// ensuring that any drag beyond the scroll limit is recognized as an intent to dismiss the
/// modal.
///
/// 2. **Clear Interaction Boundaries:** By preventing the content from bouncing or scrolling
/// past the edge, users receive clear feedback that reaching the end of the scrollable area can
/// transition to other interactions, like closing the modal. This helps avoid confusion
/// between scrolling and modal dismissal gestures.
///
/// 3. **Simplify Gesture Detection:** Using ClampingScrollPhysics simplifies the detection of
/// user gestures, differentiating more reliably between scrolling and actions intended to
/// dismiss the modal. This reduces the complexity and potential errors in handling these
/// interactions.
///
/// Choosing alternative scroll physics like [BouncingScrollPhysics] or [ElasticScrollPhysics]
/// could disrupt the drag-to-dismiss feature. These physics allow content to move beyond
/// scroll limits, which can interfere with gesture recognition, making it unclear whether a
/// gesture is intended for scrolling or dismissing the modal. As a result, drag-to-dismiss
/// would only be functional with a custom drag handle, limiting interaction flexibility on
/// main content area.
final ScrollPhysics? mainContentScrollPhysics;

/// Motion animation styles for both pagination and scrolling animations.
Expand Down
35 changes: 35 additions & 0 deletions playground/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
PODS:
- device_info_plus (0.0.1):
- Flutter
- Flutter (1.0.0)
- flutter_keyboard_visibility (0.0.1):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS

DEPENDENCIES:
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- Flutter (from `Flutter`)
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)

EXTERNAL SOURCES:
device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios"
Flutter:
:path: Flutter
flutter_keyboard_visibility:
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"

SPEC CHECKSUMS:
device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46

PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011

COCOAPODS: 1.15.2

0 comments on commit e4245fc

Please sign in to comment.