Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
3dbec840
Unverified
Commit
3dbec840
authored
Feb 06, 2019
by
xster
Committed by
GitHub
Feb 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small cleanup in CupertinoSliverRefreshControl (#27570)
parent
b06a7093
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
15 deletions
+16
-15
refresh.dart
packages/flutter/lib/src/cupertino/refresh.dart
+16
-15
No files found.
packages/flutter/lib/src/cupertino/refresh.dart
View file @
3dbec840
...
...
@@ -27,6 +27,7 @@ class _CupertinoSliverRefresh extends SingleChildRenderObjectWidget {
// The amount of space the indicator should occupy in the sliver in a
// resting state when in the refreshing mode.
final
double
refreshIndicatorLayoutExtent
;
// _RenderCupertinoSliverRefresh will paint the child in the available
// space either way but this instructs the _RenderCupertinoSliverRefresh
// on whether to also occupy any layoutExtent space or not.
...
...
@@ -82,8 +83,8 @@ class _RenderCupertinoSliverRefresh extends RenderSliver
}
// The child box will be laid out and painted in the available space either
// way but this determines whether to also occupy any
layoutExtent space or
// not.
// way but this determines whether to also occupy any
//
[SliverGeometry.layoutExtent] space or
not.
bool
get
hasLayoutExtent
=>
_hasLayoutExtent
;
bool
_hasLayoutExtent
;
set
hasLayoutExtent
(
bool
value
)
{
...
...
@@ -268,7 +269,7 @@ class CupertinoSliverRefreshControl extends StatefulWidget {
/// Create a new refresh control for inserting into a list of slivers.
///
/// The [refreshTriggerPullDistance] and [refreshIndicatorExtent] arguments
/// must not be null.
/// must not be null
and must be >= 0
.
///
/// The [builder] argument may be null, in which case no indicator UI will be
/// shown but the [onRefresh] will still be invoked. By default, [builder]
...
...
@@ -389,8 +390,8 @@ class CupertinoSliverRefreshControl extends StatefulWidget {
}
class
_CupertinoSliverRefreshControlState
extends
State
<
CupertinoSliverRefreshControl
>
{
//
/
Reset the state from done to inactive when only this fraction of the
//
/
original `refreshTriggerPullDistance` is left.
// Reset the state from done to inactive when only this fraction of the
// original `refreshTriggerPullDistance` is left.
static
const
double
_inactiveResetOverscrollFraction
=
0.1
;
RefreshIndicatorMode
refreshState
;
...
...
@@ -399,12 +400,12 @@ class _CupertinoSliverRefreshControlState extends State<CupertinoSliverRefreshCo
// The amount of space available from the inner indicator box's perspective.
//
// The value is the sum of the sliver's layout extent and the overscroll
// (which partially gets transfered into the layout extent when the refresh
// (which partially gets transfer
r
ed into the layout extent when the refresh
// triggers).
//
// The value of la
stIndicator
Extent doesn't change when the sliver scrolls
// The value of la
testIndicatorBox
Extent doesn't change when the sliver scrolls
// away without retracting; it is independent from the sliver's scrollOffset.
double
la
stIndicator
Extent
=
0.0
;
double
la
testIndicatorBox
Extent
=
0.0
;
bool
hasSliverLayoutExtent
=
false
;
@override
...
...
@@ -433,7 +434,7 @@ class _CupertinoSliverRefreshControlState extends State<CupertinoSliverRefreshCo
switch
(
refreshState
)
{
case
RefreshIndicatorMode
.
inactive
:
if
(
la
stIndicator
Extent
<=
0
)
{
if
(
la
testIndicatorBox
Extent
<=
0
)
{
return
RefreshIndicatorMode
.
inactive
;
}
else
{
nextState
=
RefreshIndicatorMode
.
drag
;
...
...
@@ -441,9 +442,9 @@ class _CupertinoSliverRefreshControlState extends State<CupertinoSliverRefreshCo
continue
drag
;
drag:
case
RefreshIndicatorMode
.
drag
:
if
(
la
stIndicator
Extent
==
0
)
{
if
(
la
testIndicatorBox
Extent
==
0
)
{
return
RefreshIndicatorMode
.
inactive
;
}
else
if
(
la
stIndicator
Extent
<
widget
.
refreshTriggerPullDistance
)
{
}
else
if
(
la
testIndicatorBox
Extent
<
widget
.
refreshTriggerPullDistance
)
{
return
RefreshIndicatorMode
.
drag
;
}
else
{
if
(
widget
.
onRefresh
!=
null
)
{
...
...
@@ -476,7 +477,7 @@ class _CupertinoSliverRefreshControlState extends State<CupertinoSliverRefreshCo
continue
done
;
}
if
(
la
stIndicator
Extent
>
widget
.
refreshIndicatorExtent
)
{
if
(
la
testIndicatorBox
Extent
>
widget
.
refreshIndicatorExtent
)
{
return
RefreshIndicatorMode
.
armed
;
}
else
{
nextState
=
RefreshIndicatorMode
.
refresh
;
...
...
@@ -496,7 +497,7 @@ class _CupertinoSliverRefreshControlState extends State<CupertinoSliverRefreshCo
// to 0.0 since the last bit of the animation can take some time and
// can feel sluggish if not going all the way back to 0.0 prevented
// a subsequent pull-to-refresh from starting.
if
(
la
stIndicator
Extent
>
if
(
la
testIndicatorBox
Extent
>
widget
.
refreshTriggerPullDistance
*
_inactiveResetOverscrollFraction
)
{
return
RefreshIndicatorMode
.
done
;
}
else
{
...
...
@@ -517,13 +518,13 @@ class _CupertinoSliverRefreshControlState extends State<CupertinoSliverRefreshCo
// its owner to trigger state changes.
child:
LayoutBuilder
(
builder:
(
BuildContext
context
,
BoxConstraints
constraints
)
{
la
stIndicator
Extent
=
constraints
.
maxHeight
;
la
testIndicatorBox
Extent
=
constraints
.
maxHeight
;
refreshState
=
transitionNextState
();
if
(
widget
.
builder
!=
null
&&
refreshState
!=
RefreshIndicatorMode
.
inactive
)
{
return
widget
.
builder
(
context
,
refreshState
,
la
stIndicator
Extent
,
la
testIndicatorBox
Extent
,
widget
.
refreshTriggerPullDistance
,
widget
.
refreshIndicatorExtent
,
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment