lannodev / we_slide

A backdrop animated widget
MIT License
75 stars 25 forks source link

I can not pull down panel on scroll list #25

Closed Faiz-rhm closed 1 year ago

Faiz-rhm commented 1 year ago

when the panel contains a list of items "ListView" is scrollable. It can not be pulled down.

https://github.com/luciano-work/we_slide/assets/14290499/eb8521d1-e389-4df9-b192-e606acca7495

lannodev commented 1 year ago

Hi @Faiz-rhm, Please can you share a small example like this?

Faiz-rhm commented 1 year ago

I have added ListView to the panel..

lannodev commented 1 year ago

I think the best solution to this problem is to add a ScrollController and add a listener to check if the scroll position is 0, then close the pane with weslide controller

Example: https://dartpad.dev/?id=9286d980f4377d8bd9d48bb7858ee354

ScrollController _scrollController = ScrollController();
double _scrollPosition;

scrollListener() {
      _scrollPosition = _scrollController.position.pixels;
        print(_scrollPosition);
      if(_scrollPosition <= 0) {
        _controller.hide();
      }
} 
_scrollController.addListener(scrollListener);

...

panel: Container(
          color: _colorScheme.primary,
          child: ListView.builder(
            controller: _scrollController,
            padding: const EdgeInsets.all(8),
              itemCount: entries.length,
              itemBuilder: (BuildContext context, int index) {
                return Container(
                  margin: const EdgeInsets.symmetric(vertical: 20),
                  height: 150,
                  color: Colors.amber[colorCodes[index]],
                  child: Center(child: Text('Entry ${entries[index]}', style: TextStyle(color: Colors.white)),),
                );
              }
           ),
 )