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
4f22f3ec
Commit
4f22f3ec
authored
Dec 09, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #838 from abarth/cleanup_global_scope
Cleanup the global scope a bit:
parents
b42ac4e6
13f9e91f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
68 additions
and
80 deletions
+68
-80
ensure_visible.dart
examples/widgets/ensure_visible.dart
+1
-1
overlay_geometry.dart
examples/widgets/overlay_geometry.dart
+1
-1
drag_target.dart
packages/flutter/lib/src/widgets/drag_target.dart
+6
-6
focus.dart
packages/flutter/lib/src/widgets/focus.dart
+0
-2
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+9
-9
heroes.dart
packages/flutter/lib/src/widgets/heroes.dart
+0
-2
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+49
-57
status_transitions.dart
packages/flutter/lib/src/widgets/status_transitions.dart
+2
-2
No files found.
examples/widgets/ensure_visible.dart
View file @
4f22f3ec
...
...
@@ -85,7 +85,7 @@ class EnsureVisibleAppState extends State<EnsureVisibleApp> {
cardModel:
cardModels
[
index
],
selected:
index
==
selectedCardIndex
,
onTap:
(
BuildContext
context
)
{
ensureWidgetIs
Visible
(
context
,
duration:
const
Duration
(
milliseconds:
200
))
Scrollable
.
ensure
Visible
(
context
,
duration:
const
Duration
(
milliseconds:
200
))
.
then
((
_
)
{
setState
(()
{
selectedCardIndex
=
index
;
});
});
...
...
examples/widgets/overlay_geometry.dart
View file @
4f22f3ec
...
...
@@ -129,7 +129,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
markers
[
MarkerType
.
topLeft
]
=
box
.
localToGlobal
(
new
Point
(
0.0
,
0.0
));
final
Size
size
=
box
.
size
;
markers
[
MarkerType
.
bottomRight
]
=
box
.
localToGlobal
(
new
Point
(
size
.
width
,
size
.
height
));
final
ScrollableState
scrollable
=
findScrollableAncestor
(
target
.
currentContext
);
final
ScrollableState
scrollable
=
Scrollable
.
of
(
target
.
currentContext
);
markersScrollOffset
=
scrollable
.
scrollOffset
;
});
}
...
...
packages/flutter/lib/src/widgets/drag_target.dart
View file @
4f22f3ec
...
...
@@ -194,10 +194,10 @@ class DragTarget<T> extends StatefulComponent {
final
DragTargetWillAccept
<
T
>
onWillAccept
;
final
DragTargetAccept
<
T
>
onAccept
;
DragTargetState
<
T
>
createState
()
=>
new
DragTargetState
<
T
>();
_DragTargetState
<
T
>
createState
()
=>
new
_
DragTargetState
<
T
>();
}
class
DragTargetState
<
T
>
extends
State
<
DragTarget
<
T
>>
{
class
_
DragTargetState
<
T
>
extends
State
<
DragTarget
<
T
>>
{
final
List
<
T
>
_candidateData
=
new
List
<
T
>();
final
List
<
dynamic
>
_rejectedData
=
new
List
<
dynamic
>();
...
...
@@ -279,7 +279,7 @@ class _DragAvatar<T> {
final
Widget
feedback
;
final
Offset
feedbackOffset
;
DragTargetState
_activeTarget
;
_
DragTargetState
_activeTarget
;
bool
_activeTargetWillAcceptDrop
=
false
;
Offset
_lastOffset
;
OverlayEntry
_entry
;
...
...
@@ -299,7 +299,7 @@ class _DragAvatar<T> {
_lastOffset
=
globalPosition
-
dragStartPoint
;
_entry
.
markNeedsBuild
();
HitTestResult
result
=
WidgetFlutterBinding
.
instance
.
hitTest
(
globalPosition
+
feedbackOffset
);
DragTargetState
target
=
_getDragTarget
(
result
.
path
);
_
DragTargetState
target
=
_getDragTarget
(
result
.
path
);
if
(
target
==
_activeTarget
)
return
;
if
(
_activeTarget
!=
null
)
...
...
@@ -308,13 +308,13 @@ class _DragAvatar<T> {
_activeTargetWillAcceptDrop
=
_activeTarget
!=
null
&&
_activeTarget
.
didEnter
(
data
);
}
DragTargetState
_getDragTarget
(
List
<
HitTestEntry
>
path
)
{
_
DragTargetState
_getDragTarget
(
List
<
HitTestEntry
>
path
)
{
// Look for the RenderBox that corresponds to the hit target (the hit target
// widget builds a RenderMetadata box for us for this purpose).
for
(
HitTestEntry
entry
in
path
)
{
if
(
entry
.
target
is
RenderMetaData
)
{
RenderMetaData
renderMetaData
=
entry
.
target
;
if
(
renderMetaData
.
metaData
is
DragTargetState
)
if
(
renderMetaData
.
metaData
is
_
DragTargetState
)
return
renderMetaData
.
metaData
;
}
}
...
...
packages/flutter/lib/src/widgets/focus.dart
View file @
4f22f3ec
...
...
@@ -4,8 +4,6 @@
import
'framework.dart'
;
typedef
void
FocusChanged
(
GlobalKey
key
);
// _noFocusedScope is used by Focus to track the case where none of the Focus
// component's subscopes (e.g. dialogs) are focused. This is distinct from the
// focused scope being null, which means that we haven't yet decided which scope
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
4f22f3ec
...
...
@@ -335,7 +335,7 @@ enum _StateLifecycle {
/// The signature of setState() methods.
typedef
void
StateSetter
(
VoidCallback
fn
);
/// The logic and internal state for a
StatefulComponent
.
/// The logic and internal state for a
[StatefulComponent]
.
abstract
class
State
<
T
extends
StatefulComponent
>
{
/// The current configuration (an instance of the corresponding
/// StatefulComponent class).
...
...
@@ -439,13 +439,13 @@ abstract class State<T extends StatefulComponent> {
}
}
abstract
class
ProxyComponent
extends
Widget
{
const
ProxyComponent
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
abstract
class
_
ProxyComponent
extends
Widget
{
const
_
ProxyComponent
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
final
Widget
child
;
}
abstract
class
ParentDataWidget
extends
ProxyComponent
{
abstract
class
ParentDataWidget
extends
_
ProxyComponent
{
const
ParentDataWidget
({
Key
key
,
Widget
child
})
:
super
(
key:
key
,
child:
child
);
...
...
@@ -460,7 +460,7 @@ abstract class ParentDataWidget extends ProxyComponent {
void
applyParentData
(
RenderObject
renderObject
);
}
abstract
class
InheritedWidget
extends
ProxyComponent
{
abstract
class
InheritedWidget
extends
_
ProxyComponent
{
const
InheritedWidget
({
Key
key
,
Widget
child
})
:
super
(
key:
key
,
child:
child
);
...
...
@@ -1248,8 +1248,8 @@ class StatefulComponentElement<T extends StatefulComponent, U extends State<T>>
}
}
abstract
class
ProxyElement
<
T
extends
ProxyComponent
>
extends
ComponentElement
<
T
>
{
ProxyElement
(
T
widget
)
:
super
(
widget
)
{
abstract
class
_ProxyElement
<
T
extends
_
ProxyComponent
>
extends
ComponentElement
<
T
>
{
_
ProxyElement
(
T
widget
)
:
super
(
widget
)
{
_builder
=
(
BuildContext
context
)
=>
this
.
widget
.
child
;
}
...
...
@@ -1267,7 +1267,7 @@ abstract class ProxyElement<T extends ProxyComponent> extends ComponentElement<T
void
notifyDescendants
(
T
oldWidget
);
}
class
ParentDataElement
extends
ProxyElement
<
ParentDataWidget
>
{
class
ParentDataElement
extends
_
ProxyElement
<
ParentDataWidget
>
{
ParentDataElement
(
ParentDataWidget
widget
)
:
super
(
widget
);
void
mount
(
Element
parent
,
dynamic
slot
)
{
...
...
@@ -1300,7 +1300,7 @@ class ParentDataElement extends ProxyElement<ParentDataWidget> {
class
InheritedElement
extends
ProxyElement
<
InheritedWidget
>
{
class
InheritedElement
extends
_
ProxyElement
<
InheritedWidget
>
{
InheritedElement
(
InheritedWidget
widget
)
:
super
(
widget
);
void
notifyDescendants
(
InheritedWidget
oldWidget
)
{
...
...
packages/flutter/lib/src/widgets/heroes.dart
View file @
4f22f3ec
...
...
@@ -56,8 +56,6 @@ import 'transitions.dart';
// should interpolate the inherited properties from their value at the source to
// their value at the target. See: https://github.com/flutter/flutter/issues/213
final
Object
centerOfAttentionHeroTag
=
new
Object
();
class
_HeroManifest
{
const
_HeroManifest
({
this
.
key
,
...
...
packages/flutter/lib/src/widgets/scrollable.dart
View file @
4f22f3ec
...
...
@@ -52,6 +52,55 @@ abstract class Scrollable extends StatefulComponent {
final
SnapOffsetCallback
snapOffsetCallback
;
final
double
snapAlignmentOffset
;
/// Returns the closest enclosing scrollable for the given context.
static
ScrollableState
of
(
BuildContext
context
)
{
return
context
.
ancestorStateOfType
(
ScrollableState
);
}
/// Scrolls the closest enclosing scrollable to make the given context visible.
static
Future
ensureVisible
(
BuildContext
context
,
{
Duration
duration
,
Curve
curve
})
{
assert
(
context
.
findRenderObject
()
is
RenderBox
);
// TODO(abarth): This function doesn't handle nested scrollable widgets.
ScrollableState
scrollable
=
Scrollable
.
of
(
context
);
if
(
scrollable
==
null
)
return
new
Future
.
value
();
RenderBox
targetBox
=
context
.
findRenderObject
();
assert
(
targetBox
.
attached
);
Size
targetSize
=
targetBox
.
size
;
RenderBox
scrollableBox
=
scrollable
.
context
.
findRenderObject
();
assert
(
scrollableBox
.
attached
);
Size
scrollableSize
=
scrollableBox
.
size
;
double
scrollOffsetDelta
;
switch
(
scrollable
.
config
.
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
Point
targetCenter
=
targetBox
.
localToGlobal
(
new
Point
(
0.0
,
targetSize
.
height
/
2.0
));
Point
scrollableCenter
=
scrollableBox
.
localToGlobal
(
new
Point
(
0.0
,
scrollableSize
.
height
/
2.0
));
scrollOffsetDelta
=
targetCenter
.
y
-
scrollableCenter
.
y
;
break
;
case
ScrollDirection
.
horizontal
:
Point
targetCenter
=
targetBox
.
localToGlobal
(
new
Point
(
targetSize
.
width
/
2.0
,
0.0
));
Point
scrollableCenter
=
scrollableBox
.
localToGlobal
(
new
Point
(
scrollableSize
.
width
/
2.0
,
0.0
));
scrollOffsetDelta
=
targetCenter
.
x
-
scrollableCenter
.
x
;
break
;
case
ScrollDirection
.
both
:
assert
(
false
);
// See https://github.com/flutter/engine/issues/888
break
;
}
ExtentScrollBehavior
scrollBehavior
=
scrollable
.
scrollBehavior
;
double
scrollOffset
=
(
scrollable
.
scrollOffset
+
scrollOffsetDelta
)
.
clamp
(
scrollBehavior
.
minScrollOffset
,
scrollBehavior
.
maxScrollOffset
);
if
(
scrollOffset
!=
scrollable
.
scrollOffset
)
return
scrollable
.
scrollTo
(
scrollOffset
,
duration:
duration
,
curve:
curve
);
return
new
Future
.
value
();
}
ScrollableState
createState
();
}
...
...
@@ -261,69 +310,12 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
}
}
ScrollableState
findScrollableAncestor
(
BuildContext
context
)
{
ScrollableState
result
;
context
.
visitAncestorElements
((
Element
element
)
{
if
(
element
is
StatefulComponentElement
)
{
if
(
element
.
state
is
ScrollableState
)
{
result
=
element
.
state
;
return
false
;
}
}
return
true
;
});
return
result
;
}
class
ScrollNotification
extends
Notification
{
ScrollNotification
(
this
.
scrollable
,
this
.
position
);
final
ScrollableState
scrollable
;
final
double
position
;
}
Future
ensureWidgetIsVisible
(
BuildContext
context
,
{
Duration
duration
,
Curve
curve
})
{
assert
(
context
.
findRenderObject
()
is
RenderBox
);
// TODO(abarth): This function doesn't handle nested scrollable widgets.
ScrollableState
scrollable
=
findScrollableAncestor
(
context
);
if
(
scrollable
==
null
)
return
new
Future
.
value
();
RenderBox
targetBox
=
context
.
findRenderObject
();
assert
(
targetBox
.
attached
);
Size
targetSize
=
targetBox
.
size
;
RenderBox
scrollableBox
=
scrollable
.
context
.
findRenderObject
();
assert
(
scrollableBox
.
attached
);
Size
scrollableSize
=
scrollableBox
.
size
;
double
scrollOffsetDelta
;
switch
(
scrollable
.
config
.
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
Point
targetCenter
=
targetBox
.
localToGlobal
(
new
Point
(
0.0
,
targetSize
.
height
/
2.0
));
Point
scrollableCenter
=
scrollableBox
.
localToGlobal
(
new
Point
(
0.0
,
scrollableSize
.
height
/
2.0
));
scrollOffsetDelta
=
targetCenter
.
y
-
scrollableCenter
.
y
;
break
;
case
ScrollDirection
.
horizontal
:
Point
targetCenter
=
targetBox
.
localToGlobal
(
new
Point
(
targetSize
.
width
/
2.0
,
0.0
));
Point
scrollableCenter
=
scrollableBox
.
localToGlobal
(
new
Point
(
scrollableSize
.
width
/
2.0
,
0.0
));
scrollOffsetDelta
=
targetCenter
.
x
-
scrollableCenter
.
x
;
break
;
case
ScrollDirection
.
both
:
assert
(
false
);
// See https://github.com/flutter/engine/issues/888
break
;
}
ExtentScrollBehavior
scrollBehavior
=
scrollable
.
scrollBehavior
;
double
scrollOffset
=
(
scrollable
.
scrollOffset
+
scrollOffsetDelta
)
.
clamp
(
scrollBehavior
.
minScrollOffset
,
scrollBehavior
.
maxScrollOffset
);
if
(
scrollOffset
!=
scrollable
.
scrollOffset
)
return
scrollable
.
scrollTo
(
scrollOffset
,
duration:
duration
,
curve:
curve
);
return
new
Future
.
value
();
}
/// A simple scrollable widget that has a single child. Use this component if
/// you are not worried about offscreen widgets consuming resources.
class
ScrollableViewport
extends
Scrollable
{
...
...
packages/flutter/lib/src/widgets/status_transitions.dart
View file @
4f22f3ec
...
...
@@ -18,10 +18,10 @@ abstract class StatusTransitionComponent extends StatefulComponent {
Widget
build
(
BuildContext
context
);
StatusTransitionState
createState
()
=>
new
StatusTransitionState
();
_StatusTransitionState
createState
()
=>
new
_
StatusTransitionState
();
}
class
StatusTransitionState
extends
State
<
StatusTransitionComponent
>
{
class
_
StatusTransitionState
extends
State
<
StatusTransitionComponent
>
{
void
initState
()
{
super
.
initState
();
config
.
performance
.
addStatusListener
(
_performanceStatusChanged
);
...
...
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