Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
5924b670
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,发现更多精彩内容 >>
提交
5924b670
编写于
7月 24, 2015
作者:
H
Hixie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pushDialog(navigator, (navigator) => new Dialog(...)).then((result) => process(result));
上级
bbe01ebd
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
61 addition
and
35 deletion
+61
-35
sky/sdk/example/address_book/lib/main.dart
sky/sdk/example/address_book/lib/main.dart
+3
-5
sky/sdk/example/fitness/lib/feed.dart
sky/sdk/example/fitness/lib/feed.dart
+3
-6
sky/sdk/example/stocks/lib/stock_settings.dart
sky/sdk/example/stocks/lib/stock_settings.dart
+9
-6
sky/sdk/lib/widgets/dialog.dart
sky/sdk/lib/widgets/dialog.dart
+16
-0
sky/sdk/lib/widgets/navigator.dart
sky/sdk/lib/widgets/navigator.dart
+13
-11
sky/sdk/lib/widgets/widget.dart
sky/sdk/lib/widgets/widget.dart
+17
-7
未找到文件。
sky/sdk/example/address_book/lib/main.dart
浏览文件 @
5924b670
...
...
@@ -68,7 +68,7 @@ class AddressBookApp extends App {
child:
new
Icon
(
type:
'image/photo_camera'
,
size:
24
),
backgroundColor:
Theme
.
of
(
this
).
accentColor
,
onPressed:
()
{
navigator
.
push
(
new
DialogRoute
(
builder:
(
navigator
,
route
)
{
showDialog
(
navigator
,
(
navigator
)
{
return
new
Dialog
(
title:
new
Text
(
"Describe your picture"
),
content:
new
ScrollableBlock
([
...
...
@@ -79,9 +79,7 @@ class AddressBookApp extends App {
actions:
[
new
FlatButton
(
child:
new
Text
(
'DISCARD'
),
onPressed:
()
{
navigator
.
pop
();
}
onPressed:
navigator
.
pop
),
new
FlatButton
(
child:
new
Text
(
'SAVE'
),
...
...
@@ -91,7 +89,7 @@ class AddressBookApp extends App {
),
]
);
})
)
;
});
}
);
}
...
...
sky/sdk/example/fitness/lib/feed.dart
浏览文件 @
5924b670
...
...
@@ -214,10 +214,8 @@ class FeedFragment extends StatefulComponent {
}
void
_handleActionButtonPressed
()
{
setState
(()
{
navigator
.
push
(
new
DialogRoute
(
builder:
(
navigator
,
route
)
{
return
new
AddItemDialog
(
navigator
);
}));
showDialog
(
navigator
,
(
navigator
)
=>
new
AddItemDialog
(
navigator
)).
then
((
route
)
{
navigator
.
pushNamed
(
route
);
});
}
...
...
@@ -286,8 +284,7 @@ class AddItemDialog extends StatefulComponent {
new
FlatButton
(
child:
new
Text
(
'ADD'
),
onPressed:
()
{
navigator
.
pop
();
navigator
.
pushNamed
(
_addItemRoute
);
navigator
.
pop
(
_addItemRoute
);
}
),
]
...
...
sky/sdk/example/stocks/lib/stock_settings.dart
浏览文件 @
5924b670
...
...
@@ -45,26 +45,29 @@ class StockSettings extends StatefulComponent {
_handleOptimismChanged
(
false
);
break
;
case
StockMode
.
pessimistic
:
navigator
.
push
(
new
DialogRoute
(
builder:
(
navigator
,
route
)
{
showDialog
(
navigator
,
(
navigator
)
{
return
new
Dialog
(
title:
new
Text
(
"Change mode?"
),
content:
new
Text
(
"Optimistic mode means everything is awesome. Are you sure you can handle that?"
),
onDismiss:
navigator
.
pop
,
onDismiss:
()
{
navigator
.
pop
(
false
);
},
actions:
[
new
FlatButton
(
child:
new
Text
(
'NO THANKS'
),
onPressed:
navigator
.
pop
onPressed:
()
{
navigator
.
pop
(
false
);
}
),
new
FlatButton
(
child:
new
Text
(
'AGREE'
),
onPressed:
()
{
_handleOptimismChanged
(
true
);
navigator
.
pop
();
navigator
.
pop
(
true
);
}
),
]
);
}));
})
.
then
(
_handleOptimismChanged
);
break
;
}
}
...
...
sky/sdk/lib/widgets/dialog.dart
浏览文件 @
5924b670
...
...
@@ -2,13 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:sky/theme/colors.dart'
as
colors
;
import
'package:sky/widgets/basic.dart'
;
import
'package:sky/widgets/default_text_style.dart'
;
import
'package:sky/widgets/material.dart'
;
import
'package:sky/widgets/navigator.dart'
;
import
'package:sky/widgets/scrollable_viewport.dart'
;
import
'package:sky/widgets/theme.dart'
;
typedef
Widget
DialogBuilder
(
Navigator
navigator
);
/// A material design dialog
///
/// <https://www.google.com/design/spec/components/dialogs.html>
...
...
@@ -100,3 +105,14 @@ class Dialog extends Component {
}
}
Future
<
dynamic
>
showDialog
(
Navigator
navigator
,
DialogBuilder
builder
)
{
Completer
completer
=
new
Completer
();
navigator
.
push
(
new
DialogRoute
(
completer:
completer
,
builder:
(
navigator
,
route
)
{
return
builder
(
navigator
);
}
));
return
completer
.
future
;
}
sky/sdk/lib/widgets/navigator.dart
浏览文件 @
5924b670
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/animation/curves.dart'
;
...
...
@@ -14,7 +16,7 @@ typedef Widget RouteBuilder(Navigator navigator, RouteBase route);
abstract
class
RouteBase
{
Widget
build
(
Navigator
navigator
,
RouteBase
route
);
bool
get
isOpaque
;
void
popState
(
)
{
}
void
popState
(
[
dynamic
result
])
{
assert
(
result
==
null
);
}
}
class
Route
extends
RouteBase
{
...
...
@@ -28,17 +30,16 @@ class Route extends RouteBase {
}
class
DialogRoute
extends
RouteBase
{
DialogRoute
({
this
.
builder
,
this
.
callback
});
DialogRoute
({
this
.
completer
,
this
.
builder
});
final
Completer
completer
;
final
RouteBuilder
builder
;
Function
callback
;
Widget
build
(
Navigator
navigator
,
RouteBase
route
)
=>
builder
(
navigator
,
route
);
bool
get
isOpaque
=>
false
;
void
popState
()
{
if
(
callback
!=
null
)
callback
(
this
);
void
popState
([
dynamic
result
])
{
completer
.
complete
(
result
);
}
}
...
...
@@ -52,7 +53,8 @@ class RouteState extends RouteBase {
Widget
build
(
Navigator
navigator
,
RouteBase
route
)
=>
null
;
bool
get
isOpaque
=>
false
;
void
popState
()
{
void
popState
([
dynamic
result
])
{
assert
(
result
==
null
);
if
(
callback
!=
null
)
callback
(
this
);
}
...
...
@@ -197,10 +199,10 @@ class NavigationState {
historyIndex
++;
}
void
pop
()
{
void
pop
(
[
dynamic
result
]
)
{
if
(
historyIndex
>
0
)
{
HistoryEntry
entry
=
history
[
historyIndex
];
entry
.
route
.
popState
();
entry
.
route
.
popState
(
result
);
entry
.
fullyOpaque
=
false
;
historyIndex
--;
}
...
...
@@ -240,9 +242,9 @@ class Navigator extends StatefulComponent {
});
}
void
pop
()
{
void
pop
(
[
dynamic
result
]
)
{
setState
(()
{
state
.
pop
();
state
.
pop
(
result
);
});
}
...
...
sky/sdk/lib/widgets/widget.dart
浏览文件 @
5924b670
...
...
@@ -26,7 +26,6 @@ abstract class Key {
factory
Key
(
String
value
)
=>
new
StringKey
(
value
);
factory
Key
.
stringify
(
Object
value
)
=>
new
StringKey
(
value
.
toString
());
factory
Key
.
fromObjectIdentity
(
Object
value
)
=>
new
ObjectKey
(
value
);
factory
Key
.
unique
()
=>
new
UniqueKey
();
}
class
StringKey
extends
Key
{
...
...
@@ -45,14 +44,25 @@ class ObjectKey extends Key {
int
get
hashCode
=>
identityHashCode
(
value
);
}
class
UniqueKey
extends
Key
{
UniqueKey
()
:
super
.
constructor
();
String
toString
()
=>
'[
$hashCode
]'
;
abstract
class
GlobalKey
extends
Key
{
GlobalKey
.
constructor
()
:
super
.
constructor
();
// so that subclasses can call us, since the Key() factory constructor shadows the implicit constructor
factory
GlobalKey
({
String
label
})
=>
new
LabeledGlobalKey
(
label
);
factory
GlobalKey
.
fromObjectIdentity
(
Object
value
)
=>
new
GlobalObjectKey
(
value
);
}
class
GlobalKey
extends
Key
{
GlobalKey
()
:
super
.
constructor
();
String
toString
()
=>
'[Global Key
$hashCode
]'
;
class
LabeledGlobalKey
extends
GlobalKey
{
// the label is purely for documentary purposes and does not affect the key
LabeledGlobalKey
(
this
.
_label
)
:
super
.
constructor
();
final
String
_label
;
String
toString
()
=>
'[GlobalKey
${_label != null ? _label : hashCode}
]'
;
}
class
GlobalObjectKey
extends
GlobalKey
{
GlobalObjectKey
(
this
.
value
)
:
super
.
constructor
();
final
Object
value
;
String
toString
()
=>
'[GlobalKey
${value.runtimeType}
(
${value.hashCode}
)]'
;
bool
operator
==(
other
)
=>
other
is
GlobalObjectKey
&&
identical
(
other
.
value
,
value
);
int
get
hashCode
=>
identityHashCode
(
value
);
}
/// A base class for elements of the widget tree
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录