Tkko / Flutter_dismissible_page

Flutter page widget that is dismissed by swipe gestures, with Hero style animations, Inspired by Facebook and Instagram stories.
https://pub.dev/packages/dismissible_page
MIT License
151 stars 39 forks source link

Not working with CustomScrollView #14

Open czaku opened 2 years ago

czaku commented 2 years ago

Doesn't work when on top of a page that has a CustomScrollView and some slivers inside (SliverList) etc. Only dismisses sideways. If there is no scrollable content in CustomScrollView then works also in vertical. Any tips on how to approach view structure or is it a bug?

Tkko commented 2 years ago

Hi @czaku, not a bug, just not implemented yet.

czaku commented 2 years ago

Thanks, anything that you are planning to release anytime soon? Asking for a friend :P

Tkko commented 2 years ago

Thanks, anything that you are planning to release anytime soon? Asking for a friend :P

Honestly, I tried implementing it before but didn't manage to finish it, I need some kind of help and more free time :D

czaku commented 2 years ago

Thanks, I don’t think I am good enough in Dart and Flutter yet, but might give it a try!

Thanks, Lukasz Czak

Mobile: +44 7895547572 On 26 Apr 2022, 09:37 +0100, Tornike @.***>, wrote:

Thanks, anything that you are planning to release anytime soon? Asking for a friend :P Honestly, I tried implementing it before but didn't manage to finish it, I need some kind of help and more free time :D β€” Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

azharul-islam commented 2 years ago

Trying to implement App Store like dismiss feature that has a full page scrollview. This is the ONLY library that achieves something close. This scrollview dismiss feature is holding it back. Hope you get to finish it πŸ₯Ί

Tkko commented 1 year ago

Hang on guys, almost there

aytunch commented 1 year ago

@Tkko this looks just BEAUTIFUL :) Please add it to the example folder also when it is finished. Looking forward to it :D

aytunch commented 1 year ago

@Tkko hi, sorry if I am bothering :/ When can we expect this to be merged? Thanks.

Tkko commented 1 year ago

@Tkko hi, sorry if I am bothering :/ When can we expect this to be merged? Thanks.

I have to test it for a few days, but before that you can test the behavior by depending on the feature_branch or on the demo website (on the mobile or in the desktop with developers options opened)

Few thing no to handle from my side, depending on the ScrollPhysics the behavior is different and I'm not sure what to do about that Android (ClampingScrollPhysics) iOS (BouncingScrollPhysics)
aytunch commented 1 year ago

@Tkko the video you posted 7 days ago in the above comments show no artifacts. Was that using NoScrollPhysics? Maybe that should be the suggested way to implement this functionality?

Tkko commented 1 year ago

@Tkko the video you posted 7 days ago in the above comments show no artifacts. Was that using NoScrollPhysics? Maybe that should be the suggested way to implement this functionality?

Sadly, It was ClampingScrollPhysics, scrolling up behavior was the same. All in all, the current functionality is good enough but not ideal

Tkko commented 1 year ago

Looks like the modal_bottom_sheet has same behavior

Ciock commented 1 year ago

I made BouncingScrollPhysics works with stretchy_header

https://user-images.githubusercontent.com/35781302/199485617-4b952530-a7fa-4315-8417-61620baf35da.mov

DismissiblePage(
  direction: DismissiblePageDismissDirection.down,
  onDismissed: RoutesService.to.doBack,
  child: StretchyHeader.listView(
        headerData: HeaderData(
          blurContent: false,
          headerHeight: Get.width / NibRatioDimension.squareLike.value,
          header: Hero(
            tag: space?.id,
            child: _SpaceCoverImage(
              space: controller.space!,
              height: Get.width / NibRatioDimension.squareLike.value,
            ),
          ),
        ),
        children: [ /* children below image */ ],
      ),
    ),
  ),
);
Tkko commented 1 year ago

Guys, It's finally merged, checkout it on pub, and tell me if anything goes wrong. From my experience, it's pretty stable, but I advice you (or your QA) to spent some time on testing the feature.

Version 1.0.0

aytunch commented 1 year ago

@Tkko thank you very much. In the live demo, if you change the type to multi and try to dismiss a page, it glitches. Can you confirm? The dismissing starts from the end of the screen

Tkko commented 1 year ago

@aytunch Correct, seems like multi directional drag doesn't work well on Web desktop.

Platform Standard thumb drag Mouse wheel
iOS βœ… βž–
Android βœ… βž–
Web Mobile βœ… βž–
Web Desktop βœ… - Except multi direction ❌
Mac os βœ… - Except multi direction ❌
Linux Can't test on mac os Can't test on mac os
Windows Can't test on mac os Can't test on mac os

If anyone can test the behavior on Windows and Linux, it would be much appreciated ❀️

Rogue85 commented 1 year ago

@Tkko hi, sorry if I am bothering :/ When can we expect this to be merged? Thanks.

I have to test it for a few days, but before that you can test the behavior by depending on the feature_branch or on the demo website (on the mobile or in the desktop with developers options opened)

Few thing no to handle from my side, depending on the ScrollPhysics the behavior is different and I'm not sure what to do about that

Android (ClampingScrollPhysics) iOS (BouncingScrollPhysics) Screen.Recording.2022-10-10.at.9.41.36.PM.mov

Screen.Recording.2022-10-10.at.9.42.50.PM.mov

Do you have any ideas on how to avoid scrolling during dismissal animation?

Tkko commented 1 year ago

Hey @Rogue85 I'm not sure how to fix it.

Rogue85 commented 1 year ago

I was able to achieve this with SnapshotWidget. It's not the best solution, but I haven't found another one.

astubenbord commented 1 year ago

@Rogue85 Maybe check out https://pub.dev/packages/flutter_top_blocked_bouncing_scroll_physics, it basically prevents over-scrolling on top while applying the typical bouncing physics on bottom.

@Tkko: My question is actually the other way around. Is there any way to prevent the DismissiblePage to fire while still scrolling? The behaviour that I'm currently experiencing is that when scrolling down and then up again (mid scroll), DismissiblePage tends to start the dismissing animation although the scroll view has not yet returned to its initial offset.

See here:

https://github.com/Tkko/Flutter_dismissible_page/assets/79228196/fd364881-47e1-4d30-96b7-657a0cff5113

In the video I let go of the pointer, but it also occurs when keeping the finger/mouse on the screen, i.e. one fluid up then down.

Here's the code from the video above:

import 'package:dismissible_page/dismissible_page.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("My App"),
      ),
      body: Center(
        child: ElevatedButton(
          child: Text("Open"),
          onPressed: () => context.pushTransparentRoute(
            DismissiblePage(
              direction: DismissiblePageDismissDirection.down,
              child: Scaffold(
                body: CustomScrollView(
                  physics: BouncingScrollPhysics(),
                  slivers: [
                    SliverAppBar(
                      title: Text("Scrollable dismissible page"),
                    ),
                    SliverList.builder(
                      itemCount: 30,
                      itemBuilder: (context, index) => ListTile(
                        title: Text("Item $index"),
                      ),
                    )
                  ],
                ),
              ),
              onDismissed: Navigator.of(context).pop,
            ),
          ),
        ),
      ),
    );
  }
}

It might be related to the BouncingScrollPhysics, I cannot reproduce this with ClampingScrollPhysics.

Is there any way to ensure that the dismissible page only starts dismissing when the scroll view is actually at the top? I've already tried attaching listeners to the scroll controller of the scroll view which based on the current offset disables the dismissible page through a local state variable. However, that didn't seem to work well and felt very clunky.

Tkko commented 1 year ago

Hey @astubenbord, what happens in the video is that when you scroll up, over scroll event is fired which calls onStart method and when you scroll down DismissiblePage is being dismissed. In short, it looks like a bug. Let me fix it

Tkko commented 1 year ago

@astubenbord Can you depend on master branch and verify if the issue is fixed?

  dismissible_page:
    git:
      url: https://github.com/Tkko/Flutter_dismissible_page
      ref: master
astubenbord commented 1 year ago

Wow, that was quick, thanks! Will test and report back on thursday if that's fine with you?

astubenbord commented 1 year ago

@Tkko First of all sorry for the late reply. The above problem does not occur anymore, thanks a lot! However, when starting the dismissal and then scrolling back up, the page stays in that "dismiss state" instead of first scrolling the whole page back up again before scrolling the inner page content.

See below:

https://github.com/Tkko/Flutter_dismissible_page/assets/79228196/b3d9d87d-ac08-49c0-af5a-01dd32167678