|
1 | 1 | import 'package:flare_flutter/flare_actor.dart'; |
2 | | -import 'package:flutter/cupertino.dart' as IOS; |
| 2 | +import 'package:gsy_github_app_flutter/widget/pull/gsy_refresh_sliver.dart' as IOS; |
3 | 3 | import 'package:flutter/material.dart'; |
4 | 4 | import 'package:flutter_spinkit/flutter_spinkit.dart'; |
5 | 5 | import 'package:gsy_github_app_flutter/common/style/gsy_style.dart'; |
@@ -45,6 +45,9 @@ class GSYPullLoadWidget extends StatefulWidget { |
45 | 45 | class _GSYPullLoadWidgetState extends State<GSYPullLoadWidget> |
46 | 46 | with GSYFlarePullController { |
47 | 47 | //with GSYFlarePullMutliController { |
| 48 | + |
| 49 | + final GlobalKey<IOS.CupertinoSliverRefreshControlState> sliverRefreshKey = GlobalKey<IOS.CupertinoSliverRefreshControlState>(); |
| 50 | + |
48 | 51 | ScrollController _scrollController; |
49 | 52 |
|
50 | 53 | bool isRefreshing = false; |
@@ -184,32 +187,40 @@ class _GSYPullLoadWidgetState extends State<GSYPullLoadWidget> |
184 | 187 | Widget build(BuildContext context) { |
185 | 188 | if (widget.userIos) { |
186 | 189 | ///用ios模式的下拉刷新 |
187 | | - return CustomScrollView( |
188 | | - controller: _scrollController, |
189 | | - |
190 | | - ///回弹效果 |
191 | | - physics: const CustomBouncingScrollPhysics( |
192 | | - parent: AlwaysScrollableScrollPhysics(), |
193 | | - refreshHeight: iosRefreshHeight), |
194 | | - slivers: <Widget>[ |
195 | | - ///控制显示刷新的 CupertinoSliverRefreshControl |
196 | | - IOS.CupertinoSliverRefreshControl( |
197 | | - refreshIndicatorExtent: iosRefreshIndicatorExtent, |
198 | | - refreshTriggerPullDistance: iosRefreshHeight, |
199 | | - onRefresh: handleRefresh, |
200 | | - builder: buildSimpleRefreshIndicator, |
201 | | - ), |
202 | | - SliverSafeArea( |
203 | | - sliver: SliverList( |
204 | | - delegate: SliverChildBuilderDelegate( |
205 | | - (BuildContext context, int index) { |
206 | | - return _getItem(index); |
207 | | - }, |
208 | | - childCount: _getListCount(), |
| 190 | + return new NotificationListener( |
| 191 | + onNotification: (ScrollNotification notification) { |
| 192 | + ///通知 CupertinoSliverRefreshControl 当前的拖拽状态 |
| 193 | + sliverRefreshKey.currentState.notifyScrollNotification(notification); |
| 194 | + return false; |
| 195 | + }, |
| 196 | + child: CustomScrollView( |
| 197 | + controller: _scrollController, |
| 198 | + |
| 199 | + ///回弹效果 |
| 200 | + physics: const CustomBouncingScrollPhysics( |
| 201 | + parent: AlwaysScrollableScrollPhysics(), |
| 202 | + refreshHeight: iosRefreshHeight), |
| 203 | + slivers: <Widget>[ |
| 204 | + ///控制显示刷新的 CupertinoSliverRefreshControl |
| 205 | + IOS.CupertinoSliverRefreshControl( |
| 206 | + key: sliverRefreshKey, |
| 207 | + refreshIndicatorExtent: iosRefreshIndicatorExtent, |
| 208 | + refreshTriggerPullDistance: iosRefreshHeight, |
| 209 | + onRefresh: handleRefresh, |
| 210 | + builder: buildSimpleRefreshIndicator, |
| 211 | + ), |
| 212 | + SliverSafeArea( |
| 213 | + sliver: SliverList( |
| 214 | + delegate: SliverChildBuilderDelegate( |
| 215 | + (BuildContext context, int index) { |
| 216 | + return _getItem(index); |
| 217 | + }, |
| 218 | + childCount: _getListCount(), |
| 219 | + ), |
209 | 220 | ), |
210 | 221 | ), |
211 | | - ), |
212 | | - ], |
| 222 | + ], |
| 223 | + ), |
213 | 224 | ); |
214 | 225 | } |
215 | 226 |
|
|
0 commit comments