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
0f92316b
Commit
0f92316b
authored
Feb 26, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2223 from Hixie/size-obs-6
SizeObserver crusade: Remove EnterExitTransition
parents
fa659389
f7d493b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
197 deletions
+0
-197
enter_exit_transition.dart
packages/flutter/lib/src/widgets/enter_exit_transition.dart
+0
-196
widgets.dart
packages/flutter/lib/widgets.dart
+0
-1
No files found.
packages/flutter/lib/src/widgets/enter_exit_transition.dart
deleted
100644 → 0
View file @
fa659389
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'basic.dart'
;
import
'framework.dart'
;
class
SmoothlyResizingOverflowBox
extends
StatefulComponent
{
SmoothlyResizingOverflowBox
({
Key
key
,
this
.
child
,
this
.
size
,
this
.
duration
,
this
.
curve
:
Curves
.
linear
})
:
super
(
key:
key
)
{
assert
(
duration
!=
null
);
assert
(
curve
!=
null
);
}
final
Widget
child
;
final
Size
size
;
final
Duration
duration
;
final
Curve
curve
;
_SmoothlyResizingOverflowBoxState
createState
()
=>
new
_SmoothlyResizingOverflowBoxState
();
}
class
_SmoothlyResizingOverflowBoxState
extends
State
<
SmoothlyResizingOverflowBox
>
{
SizeTween
_sizeTween
;
CurveTween
_curveTween
;
Animation
<
Size
>
_size
;
AnimationController
_sizeController
;
void
initState
()
{
super
.
initState
();
_sizeController
=
new
AnimationController
(
duration:
config
.
duration
);
_sizeTween
=
new
SizeTween
(
begin:
config
.
size
);
_curveTween
=
new
CurveTween
(
curve:
config
.
curve
);
_size
=
_sizeTween
.
chain
(
_curveTween
).
animate
(
_sizeController
)
..
addListener
(()
{
setState
(()
{});
});
}
void
didUpdateConfig
(
SmoothlyResizingOverflowBox
oldConfig
)
{
bool
needsAnimation
=
false
;
if
(
config
.
size
!=
oldConfig
.
size
)
{
_sizeTween
..
begin
=
_size
.
value
..
end
=
config
.
size
;
needsAnimation
=
true
;
}
_sizeController
.
duration
=
config
.
duration
;
_curveTween
.
curve
=
config
.
curve
;
if
(
needsAnimation
)
{
_sizeController
..
value
=
0.0
..
forward
();
}
}
void
dispose
()
{
_sizeController
.
stop
();
super
.
dispose
();
}
Widget
build
(
BuildContext
context
)
{
return
new
SizedOverflowBox
(
size:
_size
.
value
,
child:
config
.
child
);
}
}
class
_Entry
{
_Entry
({
this
.
child
,
this
.
enterController
,
this
.
enterTransition
});
final
Widget
child
;
final
AnimationController
enterController
;
final
Widget
enterTransition
;
Size
childSize
=
Size
.
zero
;
AnimationController
exitController
;
Widget
exitTransition
;
Widget
get
currentTransition
=>
exitTransition
??
enterTransition
;
void
dispose
()
{
enterController
?.
stop
();
exitController
?.
stop
();
}
}
typedef
Widget
TransitionBuilderCallback
(
Animation
<
double
>
animation
,
Widget
child
);
Widget
_identityTransition
(
Animation
<
double
>
animation
,
Widget
child
)
=>
child
;
class
EnterExitTransition
extends
StatefulComponent
{
EnterExitTransition
({
Key
key
,
this
.
child
,
this
.
duration
,
this
.
curve
:
Curves
.
linear
,
this
.
onEnter
:
_identityTransition
,
this
.
onExit
:
_identityTransition
})
:
super
(
key:
key
)
{
assert
(
child
!=
null
);
assert
(
duration
!=
null
);
assert
(
curve
!=
null
);
assert
(
onEnter
!=
null
);
assert
(
onExit
!=
null
);
}
final
Widget
child
;
final
Duration
duration
;
final
Curve
curve
;
final
TransitionBuilderCallback
onEnter
;
final
TransitionBuilderCallback
onExit
;
_EnterExitTransitionState
createState
()
=>
new
_EnterExitTransitionState
();
}
class
_EnterExitTransitionState
extends
State
<
EnterExitTransition
>
{
final
List
<
_Entry
>
_entries
=
new
List
<
_Entry
>();
void
initState
()
{
super
.
initState
();
_entries
.
add
(
_createEnterTransition
());
}
_Entry
_createEnterTransition
()
{
AnimationController
enterController
=
new
AnimationController
(
duration:
config
.
duration
)..
forward
();
return
new
_Entry
(
child:
config
.
child
,
enterController:
enterController
,
enterTransition:
config
.
onEnter
(
enterController
,
new
KeyedSubtree
(
key:
new
GlobalKey
(),
child:
config
.
child
))
);
}
Future
_createExitTransition
(
_Entry
entry
)
async
{
AnimationController
exitController
=
new
AnimationController
(
duration:
config
.
duration
);
entry
..
exitController
=
exitController
..
exitTransition
=
config
.
onExit
(
exitController
,
entry
.
enterTransition
);
await
exitController
.
forward
();
if
(!
mounted
)
return
;
setState
(()
{
_entries
.
remove
(
entry
);
});
}
void
didUpdateConfig
(
EnterExitTransition
oldConfig
)
{
if
(
config
.
child
.
key
!=
oldConfig
.
child
.
key
)
{
_createExitTransition
(
_entries
.
last
);
_entries
.
add
(
_createEnterTransition
());
}
}
void
dispose
()
{
for
(
_Entry
entry
in
new
List
<
_Entry
>.
from
(
_entries
))
entry
.
dispose
();
super
.
dispose
();
}
Widget
build
(
BuildContext
context
)
{
return
new
SmoothlyResizingOverflowBox
(
size:
_entries
.
last
.
childSize
,
duration:
config
.
duration
,
curve:
config
.
curve
,
child:
new
Stack
(
children:
_entries
.
map
((
_Entry
entry
)
{
return
new
SizeObserver
(
key:
new
ObjectKey
(
entry
),
onSizeChanged:
(
Size
newSize
)
{
setState
(()
{
entry
.
childSize
=
newSize
;
});
},
child:
entry
.
currentTransition
);
}).
toList
()
)
);
}
}
packages/flutter/lib/widgets.dart
View file @
0f92316b
...
...
@@ -14,7 +14,6 @@ export 'src/widgets/child_view.dart';
export
'src/widgets/dismissable.dart'
;
export
'src/widgets/drag_target.dart'
;
export
'src/widgets/editable.dart'
;
export
'src/widgets/enter_exit_transition.dart'
;
export
'src/widgets/focus.dart'
;
export
'src/widgets/framework.dart'
;
export
'src/widgets/gesture_detector.dart'
;
...
...
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