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
601089ec
Commit
601089ec
authored
Feb 13, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1829 from Hixie/size-obs-2
SizeObserver crusade: drawer
parents
c0c22777
e5cf7fe3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
21 deletions
+21
-21
drawer.dart
packages/flutter/lib/src/material/drawer.dart
+15
-16
scheduler.dart
packages/flutter/lib/src/scheduler/scheduler.dart
+6
-5
No files found.
packages/flutter/lib/src/material/drawer.dart
View file @
601089ec
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
...
...
@@ -81,7 +82,7 @@ class DrawerControllerState extends State<DrawerController> {
LocalHistoryEntry
_historyEntry
;
// TODO(abarth): This should be a GlobalValueKey when those exist.
GlobalKey
get
_
focus
Key
=>
new
GlobalObjectKey
(
config
.
key
);
GlobalKey
get
_
drawer
Key
=>
new
GlobalObjectKey
(
config
.
key
);
void
_ensureHistoryEntry
()
{
if
(
_historyEntry
==
null
)
{
...
...
@@ -89,7 +90,7 @@ class DrawerControllerState extends State<DrawerController> {
if
(
route
!=
null
)
{
_historyEntry
=
new
LocalHistoryEntry
(
onRemove:
_handleHistoryEntryRemoved
);
route
.
addLocalHistoryEntry
(
_historyEntry
);
Focus
.
moveScopeTo
(
_
focus
Key
,
context:
context
);
Focus
.
moveScopeTo
(
_
drawer
Key
,
context:
context
);
}
}
}
...
...
@@ -116,19 +117,20 @@ class DrawerControllerState extends State<DrawerController> {
}
AnimationController
_controller
;
double
_width
=
_kEdgeDragWidth
;
void
_handleSizeChanged
(
Size
newSize
)
{
setState
(()
{
_width
=
newSize
.
width
;
});
}
void
_handleTapDown
(
Point
position
)
{
_controller
.
stop
();
_ensureHistoryEntry
();
}
double
get
_width
{
assert
(!
Scheduler
.
debugInFrame
);
// we should never try to read the tree state while building or laying out
RenderBox
drawerBox
=
_drawerKey
.
currentContext
?.
findRenderObject
();
if
(
drawerBox
!=
null
)
return
drawerBox
.
size
.
width
;
return
_kWidth
;
// drawer not being shown currently
}
void
_move
(
double
delta
)
{
_controller
.
value
+=
delta
/
_width
;
}
...
...
@@ -193,13 +195,10 @@ class DrawerControllerState extends State<DrawerController> {
child:
new
Align
(
alignment:
const
FractionalOffset
(
1.0
,
0.5
),
widthFactor:
_controller
.
value
,
child:
new
SizeObserver
(
onSizeChanged:
_handleSizeChanged
,
child:
new
RepaintBoundary
(
child:
new
Focus
(
key:
_focusKey
,
child:
config
.
child
)
child:
new
RepaintBoundary
(
child:
new
Focus
(
key:
_drawerKey
,
child:
config
.
child
)
)
)
...
...
packages/flutter/lib/src/scheduler/scheduler.dart
View file @
601089ec
...
...
@@ -215,11 +215,12 @@ abstract class Scheduler extends BindingBase {
_postFrameCallbacks
.
add
(
callback
);
}
bool
_isInFrame
=
false
;
static
bool
get
debugInFrame
=>
_debugInFrame
;
static
bool
_debugInFrame
=
false
;
void
_invokeTransientFrameCallbacks
(
Duration
timeStamp
)
{
Timeline
.
startSync
(
'Animate'
);
assert
(
_
is
InFrame
);
assert
(
_
debug
InFrame
);
Map
<
int
,
FrameCallback
>
callbacks
=
_transientCallbacks
;
_transientCallbacks
=
new
Map
<
int
,
FrameCallback
>();
callbacks
.
forEach
((
int
id
,
FrameCallback
callback
)
{
...
...
@@ -239,8 +240,8 @@ abstract class Scheduler extends BindingBase {
/// [addPostFrameCallback].
void
handleBeginFrame
(
Duration
rawTimeStamp
)
{
Timeline
.
startSync
(
'Begin frame'
);
assert
(!
_
is
InFrame
);
_isInFrame
=
true
;
assert
(!
_
debug
InFrame
);
assert
(()
{
_debugInFrame
=
true
;
return
true
;
})
;
Duration
timeStamp
=
new
Duration
(
microseconds:
(
rawTimeStamp
.
inMicroseconds
/
timeDilation
).
round
());
_hasRequestedABeginFrameCallback
=
false
;
...
...
@@ -255,7 +256,7 @@ abstract class Scheduler extends BindingBase {
for
(
FrameCallback
callback
in
localPostFrameCallbacks
)
invokeFrameCallback
(
callback
,
timeStamp
);
_isInFrame
=
false
;
assert
(()
{
_debugInFrame
=
false
;
return
true
;
})
;
Timeline
.
finishSync
();
// All frame-related callbacks have been executed. Run lower-priority tasks.
...
...
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