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

BouncingScrollPhysics mode does not work if you wrap the page in DismissiblePage #33

Open
PackRuble opened this issue Sep 19, 2023 · 0 comments
Assignees

Comments

@PackRuble
Copy link

Describe the bug
The problem is that the BouncingScrollPhysics mode refuses to work if your page is wrapped in DismissiblePage. This may be important, but my usage looks like this:

return MyDismissiblePage(
          hitTestBehavior: HitTestBehavior.opaque,
          backgroundColor: Colors.black,
          minRadius: 0.0,
          maxRadius: 24.0,
          dragSensitivity: 0.6,
          startingOpacity: 0.5,
          onDismissed: () => Navigator.of(context).pop(),
          direction: DismissiblePageDismissDirection.startToEnd,
          dismissThresholds: const {
            DismissiblePageDismissDirection.startToEnd: 0.4,
          },
          reverseDuration: const Duration(milliseconds: 100),
          maxTransformValue: 0.5,
          child: child,
        );

DismissiblePage version: problems on 1.0.2 and 1.0.3 from git

Additional context
The solution looks quite simple, because the problem is a line inside the build method in DismissiblePage:

return ScrollConfiguration(
        behavior: const _DismissiblePageScrollBehavior(),
        child: MultiAxisDismissiblePage(

If you remove ScrollConfiguration wrapper then scrolling will work great, as expected. I wrote mini code to make everything work as expected. Add the necessary show to export for your case:

import 'package:dismissible_page/dismissible_page.dart'
    show
        DismissiblePage,
        DismissiblePageDismissDirection,
        // ignore: invalid_use_of_visible_for_testing_member
        MultiAxisDismissiblePage,
        // ignore: invalid_use_of_visible_for_testing_member
        SingleAxisDismissiblePage;
import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'package:flutter/material.dart';

export 'package:dismissible_page/dismissible_page.dart'
    show DismissiblePageDismissDirection, TransparentRoute;

class MyDismissiblePage extends DismissiblePage {
  const MyDismissiblePage({
    required super.child,
    required super.onDismissed,
    super.onDragStart,
    super.onDragEnd,
    super.onDragUpdate,
    super.isFullScreen = true,
    super.disabled = false,
    super.backgroundColor = Colors.black,
    super.direction = DismissiblePageDismissDirection.horizontal,
    super.dismissThresholds = const <DismissiblePageDismissDirection, double>{},
    super.dragStartBehavior = DragStartBehavior.down,
    super.dragSensitivity = 0.7,
    super.minRadius = 7,
    super.minScale = .85,
    super.maxRadius = 30,
    super.maxTransformValue = .4,
    super.startingOpacity = 1,
    super.hitTestBehavior = HitTestBehavior.opaque,
    super.reverseDuration = const Duration(milliseconds: 200),
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final contentPadding =
        isFullScreen ? EdgeInsets.zero : MediaQuery.of(context).padding;

    if (disabled) {
      return DecoratedBox(
        decoration: BoxDecoration(color: backgroundColor),
        child: Padding(
          padding: contentPadding,
          child: ClipRRect(
            borderRadius: BorderRadius.circular(minRadius),
            child: child,
          ),
        ),
      );
    }

    if (direction == DismissiblePageDismissDirection.multi) {
      return MultiAxisDismissiblePage(
        onDismissed: onDismissed,
        isFullScreen: isFullScreen,
        backgroundColor: backgroundColor,
        direction: direction,
        dismissThresholds: dismissThresholds,
        dragStartBehavior: dragStartBehavior,
        dragSensitivity: dragSensitivity,
        minRadius: minRadius,
        minScale: minScale,
        maxRadius: maxRadius,
        maxTransformValue: maxTransformValue,
        startingOpacity: startingOpacity,
        onDragStart: onDragStart,
        onDragEnd: onDragEnd,
        onDragUpdate: onDragUpdate,
        reverseDuration: reverseDuration,
        hitTestBehavior: hitTestBehavior,
        contentPadding: contentPadding,
        child: child,
      );
    } else {
      return SingleAxisDismissiblePage(
        onDismissed: onDismissed,
        isFullScreen: isFullScreen,
        backgroundColor: backgroundColor,
        direction: direction,
        dismissThresholds: dismissThresholds,
        dragStartBehavior: dragStartBehavior,
        dragSensitivity: dragSensitivity,
        minRadius: minRadius,
        minScale: minScale,
        maxRadius: maxRadius,
        maxTransformValue: maxTransformValue,
        startingOpacity: startingOpacity,
        onDragStart: onDragStart,
        onDragEnd: onDragEnd,
        onDragUpdate: onDragUpdate,
        reverseDuration: reverseDuration,
        hitTestBehavior: hitTestBehavior,
        contentPadding: contentPadding,
        child: child,
      );
    }
  }
}

Thank you very much to the author for the wonderful package!

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

No branches or pull requests

2 participants