Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
6eb13718
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6eb13718
编写于
7月 17, 2015
作者:
C
Collin Jackson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Navigator improvements, avoid building invisible routes
上级
a19fdb4a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
4 deletion
+37
-4
sky/sdk/example/widgets/navigation.dart
sky/sdk/example/widgets/navigation.dart
+10
-0
sky/sdk/lib/widgets/navigator.dart
sky/sdk/lib/widgets/navigator.dart
+27
-4
未找到文件。
sky/sdk/example/widgets/navigation.dart
浏览文件 @
6eb13718
...
...
@@ -68,6 +68,16 @@ List<Route> routes = [
class
NavigationExampleApp
extends
App
{
NavigationState
_navState
=
new
NavigationState
(
routes
);
void
onBack
()
{
if
(
_navState
.
hasPrevious
())
{
setState
(()
{
_navState
.
pop
();
});
}
else
{
super
.
onBack
();
}
}
Widget
build
()
{
return
new
Flex
([
new
Navigator
(
_navState
)]);
}
...
...
sky/sdk/lib/widgets/navigator.dart
浏览文件 @
6eb13718
...
...
@@ -42,8 +42,8 @@ class RouteState extends RouteBase {
// TODO(jackson): Refactor this into its own file
// and support multiple transition types
const
Duration
_kTransitionDuration
=
const
Duration
(
milliseconds:
20
0
);
const
Point
_kTransitionStartPoint
=
const
Point
(
0.0
,
100
.0
);
const
Duration
_kTransitionDuration
=
const
Duration
(
milliseconds:
15
0
);
const
Point
_kTransitionStartPoint
=
const
Point
(
0.0
,
75
.0
);
enum
TransitionDirection
{
forward
,
reverse
}
class
Transition
extends
AnimatedComponent
{
Transition
({
...
...
@@ -51,12 +51,14 @@ class Transition extends AnimatedComponent {
this
.
content
,
this
.
direction
,
this
.
onDismissed
,
this
.
onCompleted
,
this
.
interactive
})
:
super
(
key:
key
);
Widget
content
;
TransitionDirection
direction
;
bool
interactive
;
Function
onDismissed
;
Function
onCompleted
;
AnimatedType
<
Point
>
_position
;
AnimatedType
<
double
>
_opacity
;
...
...
@@ -73,7 +75,8 @@ class Transition extends AnimatedComponent {
_performance
=
new
AnimationPerformance
()
..
duration
=
_kTransitionDuration
..
variable
=
new
AnimatedList
([
_position
,
_opacity
])
..
addListener
(
_checkDismissed
);
..
addListener
(
_checkDismissed
)
..
addListener
(
_checkCompleted
);
if
(
direction
==
TransitionDirection
.
reverse
)
_performance
.
progress
=
1.0
;
watch
(
_performance
);
...
...
@@ -114,6 +117,17 @@ class Transition extends AnimatedComponent {
}
}
bool
_completed
=
false
;
void
_checkCompleted
()
{
if
(!
_completed
&&
direction
==
TransitionDirection
.
forward
&&
_performance
.
isCompleted
)
{
if
(
onCompleted
!=
null
)
onCompleted
();
_completed
=
true
;
}
}
Widget
build
()
{
Matrix4
transform
=
new
Matrix4
.
identity
()
..
translate
(
_position
.
value
.
x
,
_position
.
value
.
y
);
...
...
@@ -133,6 +147,7 @@ class HistoryEntry {
HistoryEntry
({
this
.
route
,
this
.
key
});
final
RouteBase
route
;
final
int
key
;
bool
transitionFinished
=
false
;
// TODO(jackson): Keep track of the requested transition
}
...
...
@@ -170,6 +185,7 @@ class NavigationState {
if
(
historyIndex
>
0
)
{
HistoryEntry
entry
=
history
[
historyIndex
];
entry
.
route
.
popState
();
entry
.
transitionFinished
=
false
;
historyIndex
--;
}
}
...
...
@@ -217,7 +233,9 @@ class Navigator extends StatefulComponent {
Widget
build
()
{
List
<
Widget
>
visibleRoutes
=
new
List
<
Widget
>();
for
(
int
i
=
0
;
i
<
state
.
history
.
length
;
i
++)
{
// TODO(jackson): Avoid building routes that are not visible
// Avoid building routes that are not visible
if
(
i
+
1
<
state
.
history
.
length
&&
state
.
history
[
i
+
1
].
transitionFinished
)
continue
;
HistoryEntry
historyEntry
=
state
.
history
[
i
];
Widget
content
=
historyEntry
.
route
.
build
(
this
,
historyEntry
.
route
);
if
(
i
==
0
)
{
...
...
@@ -235,6 +253,11 @@ class Navigator extends StatefulComponent {
setState
(()
{
state
.
history
.
remove
(
historyEntry
);
});
},
onCompleted:
()
{
setState
(()
{
historyEntry
.
transitionFinished
=
true
;
});
}
);
visibleRoutes
.
add
(
transition
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录