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

[Bug report] 一個頁面有多個LoadingMoreSliverList, 第一個list的indicatorBuilder不會觸發IndicatorStatus.noMoreLoad #58

Open
aboyo opened this issue Jun 17, 2024 · 14 comments

Comments

@aboyo
Copy link

aboyo commented Jun 17, 2024

Version

6.0.0

Platforms

dart

Device Model

iPhone 15 Pro

flutter info

Flutter (Channel stable, 3.22.0, on macOS 14.4 23E214 darwin-arm64, locale zh-Hant-TW)
    • Flutter version 3.22.0 on channel stable at /Users/abo/fvm/versions/3.22.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dcb86f68f (6 weeks ago), 2024-05-09 07:39:20 -0500
    • Engine revision f6344b75dc
    • Dart version 3.4.0
    • DevTools version 2.34.3

How to reproduce?

一個頁面有多個LoadingMoreSliverList的話,第一個list的indicatorBuilder不會觸發IndicatorStatus.noMoreLoad
兩個list應該要有各自獨立的行為對嗎? 還是該如何正確的使用~?

Logs

No response

Example code (optional)

LoadingMoreCustomScrollView(
              physics: hasData ? const BouncingScrollPhysics() : const NeverScrollableScrollPhysics(),
              slivers: [
                LoadingMoreSliverList<String>(
                  SliverListConfig<String>(
                    extendedListDelegate: SliverWaterfallFlowDelegateWithMaxCrossAxisExtent(
                      maxCrossAxisExtent: MediaQuery.of(context).size.width / 2,
                      crossAxisSpacing: 12,
                      mainAxisSpacing: 12,
                    ),
                    itemBuilder: (context, title, index) {
                      return Item(title: title);
                    },
                    sourceList: sourceList1,
                    padding: const EdgeInsets.all(12),
                    lastChildLayoutType: LastChildLayoutType.foot,
                    indicatorBuilder: (context, status) {
                      print(status);
                      return SomeWidget();
                    },
                  ),
                ),
                LoadingMoreSliverList<String>(
                  SliverListConfig<String>(
                    extendedListDelegate: SliverWaterfallFlowDelegateWithMaxCrossAxisExtent(
                      maxCrossAxisExtent: MediaQuery.of(context).size.width / 2,
                      crossAxisSpacing: 12,
                      mainAxisSpacing: 12,
                    ),
                    itemBuilder: (context, title, index) {
                      return Item(title: title);
                    },
                    sourceList: sourceList2,
                    padding: const EdgeInsets.all(12),
                    lastChildLayoutType: LastChildLayoutType.foot,
                    indicatorBuilder: (context, status) {
                      print(status);
                      return SomeWidget();
                    },
                  ),
                ),
              ],
            );

Contact

No response

@zmtzawqlp
Copy link
Member

有个参数,默认是 中间的都不显示,你可以自己改下

@aboyo
Copy link
Author

aboyo commented Jun 18, 2024

有个参数,默认是 中间的都不显示,你可以自己改下

hi, 你是說showNoMore嗎?我將showNoMore設成true有顯示,
另外請問一下,當我滑到底至第二個list時,我發現在二個list的IndicatorStatus沒有觸發loading的狀態

@zmtzawqlp
Copy link
Member

因为第2个不适合全屏幕的loading呢。。直接用的小loading

@aboyo
Copy link
Author

aboyo commented Jun 18, 2024

因为第2个不适合全屏幕的loading呢。。直接用的小loading

是的,但我測試滑到第二個list時,第二個list的indicatorBuilder沒有觸發(沒有小loading),過一下子data會直接出現,繼續往下滑時load more時才有IndicatorStatus.loadingMoreBusying

@zmtzawqlp
Copy link
Member

没有重现。你直接说需求。或者自己debug 下过程。

@aboyo
Copy link
Author

aboyo commented Jun 18, 2024

没有重现。你直接说需求。或者自己debug 下过程。

我的需求是:當滑到第二個list時,最一開始載入list2也能顯示小loading(IndicatorStatus.loadingMoreBusying的loading),讓滑動的感覺有接續第一個list的效果,我剛剛有看了下程式碼, 跟你確認下:

if (!preListIsloading &&
!preListhasMore &&
item.hasMore &&
!item.isLoading &&
!item.hasError) {
final LoadingMoreBase<dynamic> sourceList = item.sourceList;
item.defaultLock = false;
if (!item.actualLock) {
if (sourceList.isEmpty) {
if (item.autoRefresh) {
sourceList.refresh();
}
} else if (item.autoLoadMore) {
sourceList.loadMore();
}
}

這邊應該是第二個sliver及之後,呼叫refresh()時,notifyStateChanged預設是false(要為true才會有loading狀態及效果),但由於非第一個sliver,不適合全螢幕的loading,所以
https://github.com/fluttercandies/loading_more_list_library/blob/6fd12633097953544732f46cff94f6b10bf4e3b2/lib/src/loading_more_list_library.dart#L72-L81
這邊要多判斷一個參數來決定indicatorStatus要為IndicatorStatus.fullScreenBusying還是 IndicatorStatus.loadingMoreBusying

可以由:

for (int i = 0; i < _loadingMoreConfigs.length; i++) {

這邊的index來知道是否非第一個sliver,我這樣理解對嗎~?

@zmtzawqlp
Copy link
Member

你第2个列表全屏幕loading 用 loading more 多ui 就好了

@aboyo
Copy link
Author

aboyo commented Jun 19, 2024

你第2个列表全屏幕loading 用 loading more 多ui 就好了

什麼意思~?

@zmtzawqlp
Copy link
Member

fullScreenBusying 换成 loadingMoreBusying 的ui

@aboyo
Copy link
Author

aboyo commented Jun 19, 2024

fullScreenBusying 换成 loadingMoreBusying 的ui

好的 我試下 感謝

@aboyo
Copy link
Author

aboyo commented Jun 20, 2024

我再請問下~
目前我的list2等於是依賴list1(list1滑到底後才開始載入list2),當我下拉刷新時(刷新list1),我的list2想要清空,變成回到一開始的狀態(list1滑到底,換list2開始載入),
我試過在list1 refresh()時,將list2 clear(),但不起作用(如影片)

Screen_Recording_20240620_121256_1.mp4

請問refresh list1時,該怎麼將list2 reset~?

@zmtzawqlp
Copy link
Member

zmtzawqlp commented Jun 20, 2024

下啦刷新。重新new configs。 除了clear 你还需要通知ui 更新。你可以看看代码 onstatechanged

@aboyo
Copy link
Author

aboyo commented Jun 20, 2024

下啦刷新。重新new configs。 除了clear 你还需要通知ui 更新。你可以看看代码 onstatechanged

觸發onstatechanged的是setState方法對嗎:

/// update ui
  void setState() {
    super._onStateChanged(this);
  }

但我剛剛實測我自己在繼承於LoadingMoreBase的controller中宣告的reset()方法

void reset() {
    _hasMore = true;
    _pageIndex = 1;
    clear();
    indicatorStatus = IndicatorStatus.fullScreenBusying;
  }

這樣子看起來是可以(不用呼叫setState()也可以),

2024-06-20.2.54.09.mp4

但你有註解:

//do not change this in out side
 IndicatorStatus indicatorStatus = IndicatorStatus.fullScreenBusying;

@zmtzawqlp
Copy link
Member

下啦刷新。重新new configs。 除了clear 你还需要通知ui 更新。你可以看看代码 onstatechanged

觸發onstatechanged的是setState方法對嗎:

/// update ui
  void setState() {
    super._onStateChanged(this);
  }

但我剛剛實測我自己在繼承於LoadingMoreBase的controller中宣告的reset()方法

void reset() {
    _hasMore = true;
    _pageIndex = 1;
    clear();
    indicatorStatus = IndicatorStatus.fullScreenBusying;
  }

這樣子看起來是可以(不用呼叫setState()也可以),

2024-06-20.2.54.09.mp4
但你有註解:

//do not change this in out side
 IndicatorStatus indicatorStatus = IndicatorStatus.fullScreenBusying;

可以就行。影响不大,只是不希望外部随意就改变。你知道流程就无所谓

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