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
df7fdb5b
Commit
df7fdb5b
authored
Jul 25, 2015
by
Hixie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pushDialog(navigator, (navigator) => new Dialog(...)).then((result) => process(result));
parent
82f5f14b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
35 deletions
+61
-35
main.dart
packages/flutter/example/address_book/lib/main.dart
+3
-5
feed.dart
packages/flutter/example/fitness/lib/feed.dart
+3
-6
stock_settings.dart
packages/flutter/example/stocks/lib/stock_settings.dart
+9
-6
dialog.dart
packages/flutter/lib/widgets/dialog.dart
+16
-0
navigator.dart
packages/flutter/lib/widgets/navigator.dart
+13
-11
widget.dart
packages/flutter/lib/widgets/widget.dart
+17
-7
No files found.
packages/flutter/example/address_book/lib/main.dart
View file @
df7fdb5b
...
...
@@ -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 {
),
]
);
})
)
;
});
}
);
}
...
...
packages/flutter/example/fitness/lib/feed.dart
View file @
df7fdb5b
...
...
@@ -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
);
}
),
]
...
...
packages/flutter/example/stocks/lib/stock_settings.dart
View file @
df7fdb5b
...
...
@@ -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
;
}
}
...
...
packages/flutter/lib/widgets/dialog.dart
View file @
df7fdb5b
...
...
@@ -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
;
}
packages/flutter/lib/widgets/navigator.dart
View file @
df7fdb5b
...
...
@@ -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
);
});
}
...
...
packages/flutter/lib/widgets/widget.dart
View file @
df7fdb5b
...
...
@@ -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
...
...
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