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
3b278c56
Commit
3b278c56
authored
Nov 30, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #641 from Hixie/yak2-navigator-transactions
NavigatorTransaction
parents
97cca4d4
f9ea1ce8
Changes
29
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
263 additions
and
156 deletions
+263
-156
feed.dart
examples/fitness/lib/feed.dart
+5
-6
meal.dart
examples/fitness/lib/meal.dart
+3
-2
measurement.dart
examples/fitness/lib/measurement.dart
+3
-2
settings.dart
examples/fitness/lib/settings.dart
+4
-4
gallery_page.dart
examples/material_gallery/lib/gallery_page.dart
+1
-1
stock_home.dart
examples/stocks/lib/stock_home.dart
+5
-6
stock_menu.dart
examples/stocks/lib/stock_menu.dart
+6
-8
stock_settings.dart
examples/stocks/lib/stock_settings.dart
+3
-3
stock_symbol_viewer.dart
examples/stocks/lib/stock_symbol_viewer.dart
+1
-1
navigation.dart
examples/widgets/navigation.dart
+5
-5
bottom_sheet.dart
packages/flutter/lib/src/material/bottom_sheet.dart
+3
-3
date_picker_dialog.dart
packages/flutter/lib/src/material/date_picker_dialog.dart
+2
-2
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+1
-1
drawer.dart
packages/flutter/lib/src/material/drawer.dart
+2
-2
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+3
-5
material_app.dart
packages/flutter/lib/src/material/material_app.dart
+4
-2
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+2
-2
time_picker_dialog.dart
packages/flutter/lib/src/material/time_picker_dialog.dart
+2
-2
drag_target.dart
packages/flutter/lib/src/widgets/drag_target.dart
+1
-2
modal_barrier.dart
packages/flutter/lib/src/widgets/modal_barrier.dart
+1
-1
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+157
-52
overlay.dart
packages/flutter/lib/src/widgets/overlay.dart
+2
-0
routes.dart
packages/flutter/lib/src/widgets/routes.dart
+4
-4
drawer_test.dart
packages/unit/test/widget/drawer_test.dart
+1
-1
heroes_test.dart
packages/unit/test/widget/heroes_test.dart
+2
-2
navigator_test.dart
packages/unit/test/widget/navigator_test.dart
+2
-2
page_transitions_test.dart
packages/unit/test/widget/page_transitions_test.dart
+8
-9
remember_scroll_position_test.dart
packages/unit/test/widget/remember_scroll_position_test.dart
+6
-2
routes_test.dart
packages/unit/test/widget/routes_test.dart
+24
-24
No files found.
examples/fitness/lib/feed.dart
View file @
3b278c56
...
...
@@ -60,7 +60,7 @@ class FeedFragmentState extends State<FeedFragment> {
setState
(()
{
_fitnessMode
=
value
;
});
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
}
void
_showDrawer
()
{
...
...
@@ -91,8 +91,7 @@ class FeedFragmentState extends State<FeedFragment> {
}
void
_handleShowSettings
()
{
Navigator
.
of
(
context
)..
pop
()
..
pushNamed
(
'/settings'
);
Navigator
.
popAndPushNamed
(
context
,
'/settings'
);
}
// TODO(jackson): We should be localizing
...
...
@@ -190,7 +189,7 @@ class FeedFragmentState extends State<FeedFragment> {
void
_handleActionButtonPressed
()
{
showDialog
(
context:
context
,
child:
new
AddItemDialog
()).
then
((
routeName
)
{
if
(
routeName
!=
null
)
Navigator
.
of
(
context
).
pushNamed
(
routeName
);
Navigator
.
pushNamed
(
context
,
routeName
);
});
}
...
...
@@ -249,13 +248,13 @@ class AddItemDialogState extends State<AddItemDialog> {
new
FlatButton
(
child:
new
Text
(
'CANCEL'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
}
),
new
FlatButton
(
child:
new
Text
(
'ADD'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
_addItemRoute
);
Navigator
.
pop
(
context
,
_addItemRoute
);
}
),
]
...
...
examples/fitness/lib/meal.dart
View file @
3b278c56
...
...
@@ -55,14 +55,15 @@ class MealFragmentState extends State<MealFragment> {
void
_handleSave
()
{
config
.
onCreated
(
new
Meal
(
when:
new
DateTime
.
now
(),
description:
_description
));
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
}
Widget
buildToolBar
()
{
return
new
ToolBar
(
left:
new
IconButton
(
icon:
"navigation/close"
,
onPressed:
Navigator
.
of
(
context
).
pop
),
onPressed:
()
=>
Navigator
.
pop
(
context
)
),
center:
new
Text
(
'New Meal'
),
right:
<
Widget
>[
// TODO(abarth): Should this be a FlatButton?
...
...
examples/fitness/lib/measurement.dart
View file @
3b278c56
...
...
@@ -77,14 +77,15 @@ class MeasurementFragmentState extends State<MeasurementFragment> {
));
}
config
.
onCreated
(
new
Measurement
(
when:
_when
,
weight:
parsedWeight
));
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
}
Widget
buildToolBar
()
{
return
new
ToolBar
(
left:
new
IconButton
(
icon:
"navigation/close"
,
onPressed:
Navigator
.
of
(
context
).
pop
),
onPressed:
()
=>
Navigator
.
pop
(
context
)
),
center:
new
Text
(
'New Measurement'
),
right:
<
Widget
>[
// TODO(abarth): Should this be a FlatButton?
...
...
examples/fitness/lib/settings.dart
View file @
3b278c56
...
...
@@ -28,7 +28,7 @@ class SettingsFragmentState extends State<SettingsFragment> {
return
new
ToolBar
(
left:
new
IconButton
(
icon:
"navigation/arrow_back"
,
onPressed:
()
=>
Navigator
.
of
(
context
).
pop
(
)
onPressed:
()
=>
Navigator
.
pop
(
context
)
),
center:
new
Text
(
'Settings'
)
);
...
...
@@ -47,7 +47,7 @@ class SettingsFragmentState extends State<SettingsFragment> {
void
_handleGoalWeightChanged
(
String
goalWeight
)
{
// TODO(jackson): Looking for null characters to detect enter key is a hack
if
(
goalWeight
.
endsWith
(
"
\
u{0}"
))
{
Navigator
.
of
(
context
).
pop
(
double
.
parse
(
goalWeight
.
replaceAll
(
"
\
u{0}"
,
""
)));
Navigator
.
pop
(
context
,
double
.
parse
(
goalWeight
.
replaceAll
(
"
\
u{0}"
,
""
)));
}
else
{
setState
(()
{
try
{
...
...
@@ -74,13 +74,13 @@ class SettingsFragmentState extends State<SettingsFragment> {
new
FlatButton
(
child:
new
Text
(
'CANCEL'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
}
),
new
FlatButton
(
child:
new
Text
(
'SAVE'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
_goalWeight
);
Navigator
.
pop
(
context
,
_goalWeight
);
}
),
]
...
...
examples/material_gallery/lib/gallery_page.dart
View file @
3b278c56
...
...
@@ -21,7 +21,7 @@ class GalleryPage extends StatelessComponent {
for
(
WidgetDemo
demo
in
demos
)
{
items
.
add
(
new
DrawerItem
(
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
demo
.
routeName
);
Navigator
.
pushNamed
(
context
,
demo
.
routeName
);
},
child:
new
Text
(
demo
.
title
)
));
...
...
examples/stocks/lib/stock_home.dart
View file @
3b278c56
...
...
@@ -41,7 +41,7 @@ class StockHomeState extends State<StockHome> {
}
void
_handleSearchEnd
()
{
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
}
void
_handleSearchQueryChanged
(
String
query
)
{
...
...
@@ -92,13 +92,13 @@ class StockHomeState extends State<StockHome> {
new
FlatButton
(
child:
new
Text
(
'USE IT'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
false
);
Navigator
.
pop
(
context
,
false
);
}
),
new
FlatButton
(
child:
new
Text
(
'OH WELL'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
false
);
Navigator
.
pop
(
context
,
false
);
}
),
]
...
...
@@ -142,8 +142,7 @@ class StockHomeState extends State<StockHome> {
}
void
_handleShowSettings
()
{
Navigator
.
of
(
context
)..
pop
()
..
pushNamed
(
'/settings'
);
Navigator
.
popAndPushNamed
(
context
,
'/settings'
);
}
Widget
buildToolBar
()
{
...
...
@@ -207,7 +206,7 @@ class StockHomeState extends State<StockHome> {
onOpen:
(
Stock
stock
,
Key
arrowKey
)
{
Set
<
Key
>
mostValuableKeys
=
new
Set
<
Key
>();
mostValuableKeys
.
add
(
arrowKey
);
Navigator
.
of
(
context
).
pushNamed
(
'/stock/
${stock.symbol}
'
,
mostValuableKeys:
mostValuableKeys
);
Navigator
.
pushNamed
(
context
,
'/stock/
${stock.symbol}
'
,
mostValuableKeys:
mostValuableKeys
);
},
onShow:
(
Stock
stock
,
Key
arrowKey
)
{
scaffoldKey
.
currentState
.
showBottomSheet
((
BuildContext
context
)
=>
new
StockSymbolBottomSheet
(
stock:
stock
));
...
...
examples/stocks/lib/stock_menu.dart
View file @
3b278c56
...
...
@@ -23,10 +23,9 @@ Future showStockMenu({BuildContext context, bool autorefresh, ValueChanged<bool>
new
Checkbox
(
value:
autorefresh
,
onChanged:
(
bool
value
)
{
Navigator
.
of
(
context
).
setState
(()
{
autorefresh
=
value
;
});
Navigator
.
of
(
context
).
pop
(
_MenuItems
.
autorefreshCheckbox
);
// TODO(ianh): https://github.com/flutter/flutter/issues/187
autorefresh
=
value
;
Navigator
.
pop
(
context
,
_MenuItems
.
autorefreshCheckbox
);
}
)
]
...
...
@@ -43,9 +42,8 @@ Future showStockMenu({BuildContext context, bool autorefresh, ValueChanged<bool>
]
))
{
case
_MenuItems
.
autorefresh
:
Navigator
.
of
(
context
).
setState
(()
{
autorefresh
=
!
autorefresh
;
});
// TODO(ianh): https://github.com/flutter/flutter/issues/187
autorefresh
=
!
autorefresh
;
continue
autorefreshNotify
;
autorefreshNotify:
case
_MenuItems
.
autorefreshCheckbox
:
...
...
@@ -75,7 +73,7 @@ Future showStockMenu({BuildContext context, bool autorefresh, ValueChanged<bool>
new
FlatButton
(
child:
new
Text
(
'OH WELL'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
false
);
Navigator
.
pop
(
context
,
false
);
}
),
]
...
...
examples/stocks/lib/stock_settings.dart
View file @
3b278c56
...
...
@@ -44,13 +44,13 @@ class StockSettingsState extends State<StockSettings> {
new
FlatButton
(
child:
new
Text
(
'NO THANKS'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
false
);
Navigator
.
pop
(
context
,
false
);
}
),
new
FlatButton
(
child:
new
Text
(
'AGREE'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
true
);
Navigator
.
pop
(
context
,
true
);
}
),
]
...
...
@@ -72,7 +72,7 @@ class StockSettingsState extends State<StockSettings> {
return
new
ToolBar
(
left:
new
IconButton
(
icon:
'navigation/arrow_back'
,
onPressed:
()
=>
Navigator
.
of
(
context
).
pop
(
)
onPressed:
()
=>
Navigator
.
pop
(
context
)
),
center:
new
Text
(
'Settings'
)
);
...
...
examples/stocks/lib/stock_symbol_viewer.dart
View file @
3b278c56
...
...
@@ -58,7 +58,7 @@ class StockSymbolPage extends StatelessComponent {
left:
new
IconButton
(
icon:
'navigation/arrow_back'
,
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
}
),
center:
new
Text
(
stock
.
name
)
...
...
examples/widgets/navigation.dart
View file @
3b278c56
...
...
@@ -15,11 +15,11 @@ class Home extends StatelessComponent {
),
new
RaisedButton
(
child:
new
Text
(
'GO SHOPPING'
),
onPressed:
()
=>
Navigator
.
of
(
context
).
pushNamed
(
'/shopping'
)
onPressed:
()
=>
Navigator
.
pushNamed
(
context
,
'/shopping'
)
),
new
RaisedButton
(
child:
new
Text
(
'START ADVENTURE'
),
onPressed:
()
=>
Navigator
.
of
(
context
).
pushNamed
(
'/adventure'
)
onPressed:
()
=>
Navigator
.
pushNamed
(
context
,
'/adventure'
)
)
],
padding:
const
EdgeDims
.
all
(
30.0
)
...
...
@@ -41,11 +41,11 @@ class Shopping extends StatelessComponent {
),
new
RaisedButton
(
child:
new
Text
(
'RETURN HOME'
),
onPressed:
()
=>
Navigator
.
of
(
context
).
pop
(
)
onPressed:
()
=>
Navigator
.
pop
(
context
)
),
new
RaisedButton
(
child:
new
Text
(
'GO TO DUNGEON'
),
onPressed:
()
=>
Navigator
.
of
(
context
).
pushNamed
(
'/adventure'
)
onPressed:
()
=>
Navigator
.
pushNamed
(
context
,
'/adventure'
)
)
],
padding:
const
EdgeDims
.
all
(
30.0
)
...
...
@@ -67,7 +67,7 @@ class Adventure extends StatelessComponent {
),
new
RaisedButton
(
child:
new
Text
(
'RUN!!!'
),
onPressed:
()
=>
Navigator
.
of
(
context
).
pop
(
)
onPressed:
()
=>
Navigator
.
pop
(
context
)
)
],
padding:
const
EdgeDims
.
all
(
30.0
)
...
...
packages/flutter/lib/src/material/bottom_sheet.dart
View file @
3b278c56
...
...
@@ -119,7 +119,7 @@ class _ModalBottomSheetState extends State<_ModalBottomSheet> {
Widget
build
(
BuildContext
context
)
{
return
new
GestureDetector
(
onTap:
()
{
Navigator
.
of
(
context
).
pop
();
}
,
onTap:
()
=>
Navigator
.
pop
(
context
)
,
child:
new
BuilderTransition
(
performance:
config
.
route
.
performance
,
variables:
<
AnimatedValue
<
double
>>[
_layout
.
childTop
],
...
...
@@ -130,7 +130,7 @@ class _ModalBottomSheetState extends State<_ModalBottomSheet> {
token:
_layout
.
childTop
.
value
,
child:
new
BottomSheet
(
performance:
config
.
route
.
performance
,
onClosing:
()
{
Navigator
.
of
(
context
).
pop
();
}
,
onClosing:
()
=>
Navigator
.
pop
(
context
)
,
childHeight:
_layout
.
childTop
.
end
,
builder:
config
.
route
.
builder
)
...
...
@@ -167,7 +167,7 @@ Future showModalBottomSheet({ BuildContext context, WidgetBuilder builder }) {
assert
(
context
!=
null
);
assert
(
builder
!=
null
);
final
Completer
completer
=
new
Completer
();
Navigator
.
of
(
context
).
push
(
new
_ModalBottomSheetRoute
(
Navigator
.
push
(
context
,
new
_ModalBottomSheetRoute
(
completer:
completer
,
builder:
builder
));
...
...
packages/flutter/lib/src/material/date_picker_dialog.dart
View file @
3b278c56
...
...
@@ -40,11 +40,11 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
}
void
_handleCancel
()
{
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
}
void
_handleOk
()
{
Navigator
.
of
(
context
).
pop
(
_selectedDate
);
Navigator
.
pop
(
context
,
_selectedDate
);
}
Widget
build
(
BuildContext
context
)
{
...
...
packages/flutter/lib/src/material/dialog.dart
View file @
3b278c56
...
...
@@ -140,6 +140,6 @@ class _DialogRoute<T> extends PopupRoute<T> {
Future
showDialog
(
{
BuildContext
context
,
Widget
child
})
{
Completer
completer
=
new
Completer
();
Navigator
.
of
(
context
).
push
(
new
_DialogRoute
(
completer:
completer
,
child:
child
));
Navigator
.
push
(
context
,
new
_DialogRoute
(
completer:
completer
,
child:
child
));
return
completer
.
future
;
}
packages/flutter/lib/src/material/drawer.dart
View file @
3b278c56
...
...
@@ -71,7 +71,7 @@ class _DrawerRoute extends OverlayRoute {
_state
=
_DrawerState
.
closed
;
switch
(
previousState
)
{
case
_DrawerState
.
showing
:
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
break
;
case
_DrawerState
.
popped
:
finished
();
...
...
@@ -220,5 +220,5 @@ class _DrawerControllerState extends State<_DrawerController> {
}
void
showDrawer
(
{
BuildContext
context
,
Widget
child
,
int
elevation:
16
})
{
Navigator
.
of
(
context
).
push
(
new
_DrawerRoute
(
child:
child
,
elevation:
elevation
));
Navigator
.
push
(
context
,
new
_DrawerRoute
(
child:
child
,
elevation:
elevation
));
}
packages/flutter/lib/src/material/dropdown.dart
View file @
3b278c56
...
...
@@ -93,9 +93,7 @@ class _DropDownMenu<T> extends StatusTransitionComponent {
padding:
_kMenuHorizontalPadding
,
child:
route
.
items
[
itemIndex
]
),
onTap:
()
{
Navigator
.
of
(
context
).
pop
(
route
.
items
[
itemIndex
].
value
);
}
onTap:
()
=>
Navigator
.
pop
(
context
,
route
.
items
[
itemIndex
].
value
)
)
));
}
...
...
@@ -117,7 +115,7 @@ class _DropDownMenu<T> extends StatusTransitionComponent {
reverseCurve:
const
Interval
(
0.0
,
0.001
)
);
final
RenderBox
renderBox
=
Navigator
.
of
(
context
)
.
context
.
findRenderObject
();
final
RenderBox
renderBox
=
route
.
navigator
.
context
.
findRenderObject
();
final
Size
navigatorSize
=
renderBox
.
size
;
final
RelativeRect
menuRect
=
new
RelativeRect
.
fromSize
(
route
.
rect
,
navigatorSize
);
...
...
@@ -216,7 +214,7 @@ class DropDownButton<T> extends StatelessComponent {
final
RenderBox
renderBox
=
indexedStackKey
.
currentContext
.
findRenderObject
();
final
Rect
rect
=
renderBox
.
localToGlobal
(
Point
.
origin
)
&
renderBox
.
size
;
final
Completer
completer
=
new
Completer
<
T
>();
Navigator
.
of
(
context
).
push
(
new
_DropDownRoute
<
T
>(
Navigator
.
push
(
context
,
new
_DropDownRoute
<
T
>(
completer:
completer
,
items:
items
,
selectedIndex:
selectedIndex
,
...
...
packages/flutter/lib/src/material/material_app.dart
View file @
3b278c56
...
...
@@ -81,8 +81,10 @@ class _MaterialAppState extends State<MaterialApp> implements BindingObserver {
assert
(
mounted
);
NavigatorState
navigator
=
_navigator
.
currentState
;
assert
(
navigator
!=
null
);
if
(!
navigator
.
pop
())
activity
.
finishCurrentActivity
();
navigator
.
openTransaction
((
NavigatorTransaction
transaction
)
{
if
(!
transaction
.
pop
())
activity
.
finishCurrentActivity
();
});
return
true
;
}
...
...
packages/flutter/lib/src/material/popup_menu.dart
View file @
3b278c56
...
...
@@ -38,7 +38,7 @@ class _PopupMenu<T> extends StatelessComponent {
performance:
route
.
performance
,
opacity:
new
AnimatedValue
<
double
>(
0.0
,
end:
1.0
,
curve:
new
Interval
(
start
,
end
)),
child:
new
InkWell
(
onTap:
()
{
Navigator
.
of
(
context
).
pop
(
route
.
items
[
i
].
value
);
}
,
onTap:
()
=>
Navigator
.
pop
(
context
,
route
.
items
[
i
].
value
)
,
child:
route
.
items
[
i
]
))
);
...
...
@@ -114,7 +114,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
Future
showMenu
(
{
BuildContext
context
,
ModalPosition
position
,
List
<
PopupMenuItem
>
items
,
int
elevation:
8
})
{
Completer
completer
=
new
Completer
();
Navigator
.
of
(
context
).
push
(
new
_PopupMenuRoute
(
Navigator
.
push
(
context
,
new
_PopupMenuRoute
(
completer:
completer
,
position:
position
,
items:
items
,
...
...
packages/flutter/lib/src/material/time_picker_dialog.dart
View file @
3b278c56
...
...
@@ -36,11 +36,11 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
}
void
_handleCancel
()
{
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
}
void
_handleOk
()
{
Navigator
.
of
(
context
).
pop
(
_selectedTime
);
Navigator
.
pop
(
context
,
_selectedTime
);
}
Widget
build
(
BuildContext
context
)
{
...
...
packages/flutter/lib/src/widgets/drag_target.dart
View file @
3b278c56
...
...
@@ -11,7 +11,6 @@ import 'package:flutter/services.dart';
import
'basic.dart'
;
import
'binding.dart'
;
import
'framework.dart'
;
import
'navigator.dart'
;
import
'overlay.dart'
;
typedef
bool
DragTargetWillAccept
<
T
>(
T
data
);
...
...
@@ -165,7 +164,7 @@ class _DraggableState<T> extends State<DraggableBase<T>> implements GestureArena
new
_DragAvatar
<
T
>(
pointer:
pointer
,
router:
router
,
overlay:
Navigator
.
of
(
context
).
overlay
,
overlay:
Overlay
.
of
(
context
)
,
data:
config
.
data
,
initialPosition:
position
,
dragStartPoint:
dragStartPoint
,
...
...
packages/flutter/lib/src/widgets/modal_barrier.dart
View file @
3b278c56
...
...
@@ -23,7 +23,7 @@ class ModalBarrier extends StatelessComponent {
return
new
Listener
(
onPointerDown:
(
_
)
{
if
(
dismissable
)
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
},
behavior:
HitTestBehavior
.
opaque
,
child:
new
ConstrainedBox
(
...
...
packages/flutter/lib/src/widgets/navigator.dart
View file @
3b278c56
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/widgets/overlay.dart
View file @
3b278c56
...
...
@@ -44,6 +44,8 @@ class Overlay extends StatefulComponent {
final
List
<
OverlayEntry
>
initialEntries
;
static
OverlayState
of
(
BuildContext
context
)
=>
context
.
ancestorStateOfType
(
OverlayState
);
OverlayState
createState
()
=>
new
OverlayState
();
}
...
...
packages/flutter/lib/src/widgets/routes.dart
View file @
3b278c56
...
...
@@ -23,11 +23,11 @@ abstract class OverlayRoute<T> extends Route<T> {
List
<
OverlayEntry
>
get
overlayEntries
=>
_overlayEntries
;
final
List
<
OverlayEntry
>
_overlayEntries
=
<
OverlayEntry
>[];
void
install
(
Overlay
State
overlay
,
Overlay
Entry
insertionPoint
)
{
void
install
(
OverlayEntry
insertionPoint
)
{
assert
(
_overlayEntries
.
isEmpty
);
for
(
WidgetBuilder
builder
in
builders
)
_overlayEntries
.
add
(
new
OverlayEntry
(
builder:
builder
));
overlay
?.
insertAll
(
_overlayEntries
,
above:
insertionPoint
);
navigator
.
overlay
?.
insertAll
(
_overlayEntries
,
above:
insertionPoint
);
}
// Subclasses shouldn't call this if they want to delay the finished() call.
...
...
@@ -108,9 +108,9 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
}
}
void
install
(
Overlay
State
overlay
,
Overlay
Entry
insertionPoint
)
{
void
install
(
OverlayEntry
insertionPoint
)
{
_performance
=
createPerformance
();
super
.
install
(
overlay
,
insertionPoint
);
super
.
install
(
insertionPoint
);
}
void
didPush
()
{
...
...
packages/unit/test/widget/drawer_test.dart
View file @
3b278c56
...
...
@@ -29,7 +29,7 @@ void main() {
expect
(
tester
.
findText
(
'drawer'
),
isNotNull
);
tester
.
pump
(
new
Duration
(
seconds:
1
));
// animation done
expect
(
tester
.
findText
(
'drawer'
),
isNotNull
);
Navigator
.
of
(
context
).
pop
(
);
Navigator
.
pop
(
context
);
tester
.
pump
();
// drawer should be starting to animate away
expect
(
tester
.
findText
(
'drawer'
),
isNotNull
);
tester
.
pump
(
new
Duration
(
seconds:
1
));
// animation done
...
...
packages/unit/test/widget/heroes_test.dart
View file @
3b278c56
...
...
@@ -15,13 +15,13 @@ final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
new
Container
(
height:
100.0
,
width:
100.0
),
new
Card
(
child:
new
Hero
(
tag:
'a'
,
child:
new
Container
(
height:
100.0
,
width:
100.0
,
key:
firstKey
))),
new
Container
(
height:
100.0
,
width:
100.0
),
new
FlatButton
(
child:
new
Text
(
'button'
),
onPressed:
()
=>
Navigator
.
of
(
args
.
context
).
pushNamed
(
'/two'
)),
new
FlatButton
(
child:
new
Text
(
'button'
),
onPressed:
()
=>
Navigator
.
pushNamed
(
args
.
context
,
'/two'
)),
]),
'/two'
:
(
RouteArguments
args
)
=>
new
Block
([
new
Container
(
height:
150.0
,
width:
150.0
),
new
Card
(
child:
new
Hero
(
tag:
'a'
,
child:
new
Container
(
height:
150.0
,
width:
150.0
,
key:
secondKey
))),
new
Container
(
height:
150.0
,
width:
150.0
),
new
FlatButton
(
child:
new
Text
(
'button'
),
onPressed:
()
=>
Navigator
.
of
(
args
.
context
).
pop
(
)),
new
FlatButton
(
child:
new
Text
(
'button'
),
onPressed:
()
=>
Navigator
.
pop
(
args
.
context
)),
]),
};
...
...
packages/unit/test/widget/navigator_test.dart
View file @
3b278c56
...
...
@@ -10,7 +10,7 @@ class FirstComponent extends StatelessComponent {
Widget
build
(
BuildContext
context
)
{
return
new
GestureDetector
(
onTap:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/second'
);
Navigator
.
pushNamed
(
context
,
'/second'
);
},
child:
new
Container
(
decoration:
new
BoxDecoration
(
...
...
@@ -29,7 +29,7 @@ class SecondComponent extends StatefulComponent {
class
SecondComponentState
extends
State
<
SecondComponent
>
{
Widget
build
(
BuildContext
context
)
{
return
new
GestureDetector
(
onTap:
Navigator
.
of
(
context
).
pop
,
onTap:
()
=>
Navigator
.
pop
(
context
)
,
child:
new
Container
(
decoration:
new
BoxDecoration
(
backgroundColor:
new
Color
(
0xFFFF00FF
)
...
...
packages/unit/test/widget/page_transitions_test.dart
View file @
3b278c56
...
...
@@ -16,10 +16,11 @@ class TestOverlayRoute extends OverlayRoute {
void
main
(
)
{
test
(
'Check onstage/offstage handling around transitions'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
GlobalKey
containerKey
=
new
GlobalKey
();
GlobalKey
containerKey1
=
new
GlobalKey
();
GlobalKey
containerKey2
=
new
GlobalKey
();
final
Map
<
String
,
RouteBuilder
>
routes
=
<
String
,
RouteBuilder
>{
'/'
:
(
_
)
=>
new
Container
(
key:
containerKey
,
child:
new
Text
(
'Home'
)),
'/settings'
:
(
_
)
=>
new
Container
(
child:
new
Text
(
'Settings'
)),
'/'
:
(
_
)
=>
new
Container
(
key:
containerKey
1
,
child:
new
Text
(
'Home'
)),
'/settings'
:
(
_
)
=>
new
Container
(
key:
containerKey2
,
child:
new
Text
(
'Settings'
)),
};
tester
.
pumpWidget
(
new
MaterialApp
(
routes:
routes
));
...
...
@@ -28,9 +29,7 @@ void main() {
expect
(
tester
.
findText
(
'Settings'
),
isNull
);
expect
(
tester
.
findText
(
'Overlay'
),
isNull
);
NavigatorState
navigator
=
Navigator
.
of
(
containerKey
.
currentContext
);
navigator
.
pushNamed
(
'/settings'
);
Navigator
.
pushNamed
(
containerKey1
.
currentContext
,
'/settings'
);
tester
.
pump
();
...
...
@@ -50,7 +49,7 @@ void main() {
expect
(
tester
.
findText
(
'Settings'
),
isOnStage
);
expect
(
tester
.
findText
(
'Overlay'
),
isNull
);
navigator
.
push
(
new
TestOverlayRoute
());
Navigator
.
push
(
containerKey2
.
currentContext
,
new
TestOverlayRoute
());
tester
.
pump
();
...
...
@@ -64,7 +63,7 @@ void main() {
expect
(
tester
.
findText
(
'Settings'
),
isOnStage
);
expect
(
tester
.
findText
(
'Overlay'
),
isOnStage
);
navigator
.
pop
(
);
Navigator
.
pop
(
containerKey2
.
currentContext
);
tester
.
pump
();
expect
(
tester
.
findText
(
'Home'
),
isNull
);
...
...
@@ -77,7 +76,7 @@ void main() {
expect
(
tester
.
findText
(
'Settings'
),
isOnStage
);
expect
(
tester
.
findText
(
'Overlay'
),
isNull
);
navigator
.
pop
(
);
Navigator
.
pop
(
containerKey2
.
currentContext
);
tester
.
pump
();
expect
(
tester
.
findText
(
'Home'
),
isOnStage
);
...
...
packages/unit/test/widget/remember_scroll_position_test.dart
View file @
3b278c56
...
...
@@ -74,7 +74,9 @@ void main() {
expect
(
tester
.
findText
(
'16'
),
isNull
);
expect
(
tester
.
findText
(
'100'
),
isNull
);
navigatorKey
.
currentState
.
pushNamed
(
'/second'
);
navigatorKey
.
currentState
.
openTransaction
(
(
NavigatorTransaction
transaction
)
=>
transaction
.
pushNamed
(
'/second'
)
);
tester
.
pump
();
// navigating always takes two frames
tester
.
pump
(
new
Duration
(
seconds:
1
));
...
...
@@ -89,7 +91,9 @@ void main() {
expect
(
tester
.
findText
(
'10'
),
isNull
);
expect
(
tester
.
findText
(
'100'
),
isNull
);
navigatorKey
.
currentState
.
pop
();
navigatorKey
.
currentState
.
openTransaction
(
(
NavigatorTransaction
transaction
)
=>
transaction
.
pop
()
);
tester
.
pump
();
// navigating always takes two frames
tester
.
pump
(
new
Duration
(
seconds:
1
));
...
...
packages/unit/test/widget/routes_test.dart
View file @
3b278c56
...
...
@@ -22,14 +22,14 @@ class TestRoute extends Route<String> {
results
.
add
(
'
$name
:
$s
'
);
}
void
install
(
Overlay
State
overlay
,
Overlay
Entry
insertionPoint
)
{
void
install
(
OverlayEntry
insertionPoint
)
{
log
(
'install'
);
OverlayEntry
entry
=
new
OverlayEntry
(
builder:
(
BuildContext
context
)
=>
new
Container
(),
opaque:
true
);
_entries
.
add
(
entry
);
overlay
?.
insert
(
entry
,
above:
insertionPoint
);
navigator
.
overlay
?.
insert
(
entry
,
above:
insertionPoint
);
routes
.
add
(
this
);
}
...
...
@@ -73,11 +73,11 @@ class TestRoute extends Route<String> {
void
runNavigatorTest
(
WidgetTester
tester
,
NavigatorState
host
,
void
test
(
NavigatorState
transaction
)
,
NavigatorTransactionCallback
test
,
List
<
String
>
expectations
)
{
expect
(
host
,
isNotNull
);
test
(
ho
st
);
host
.
openTransaction
(
te
st
);
expect
(
results
,
equals
(
expectations
));
results
.
clear
();
tester
.
pump
();
...
...
@@ -95,7 +95,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
},
[
'initial: install'
,
...
...
@@ -106,7 +106,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
push
(
second
=
new
TestRoute
(
'second'
));
},
[
...
...
@@ -118,7 +118,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
push
(
new
TestRoute
(
'third'
));
},
[
...
...
@@ -130,7 +130,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
replace
(
oldRoute:
second
,
newRoute:
new
TestRoute
(
'two'
));
},
[
...
...
@@ -143,7 +143,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
pop
(
'hello'
);
},
[
...
...
@@ -155,7 +155,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
pop
(
'good bye'
);
},
[
...
...
@@ -182,7 +182,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
},
[
'first: install'
,
...
...
@@ -193,7 +193,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
push
(
second
=
new
TestRoute
(
'second'
));
},
[
...
...
@@ -205,7 +205,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
push
(
new
TestRoute
(
'third'
));
},
[
...
...
@@ -217,7 +217,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
removeRouteBefore
(
second
);
},
[
...
...
@@ -227,7 +227,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
pop
(
'good bye'
);
},
[
...
...
@@ -239,7 +239,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
push
(
new
TestRoute
(
'three'
));
},
[
...
...
@@ -252,7 +252,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
push
(
four
=
new
TestRoute
(
'four'
));
},
[
...
...
@@ -264,7 +264,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
removeRouteBefore
(
four
);
},
[
...
...
@@ -274,7 +274,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
pop
(
'the end'
);
},
[
...
...
@@ -301,7 +301,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
},
[
'A: install'
,
...
...
@@ -311,7 +311,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
push
(
new
TestRoute
(
'B'
));
},
[
...
...
@@ -324,7 +324,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
push
(
routeC
=
new
TestRoute
(
'C'
));
},
[
...
...
@@ -337,7 +337,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
replaceRouteBefore
(
anchorRoute:
routeC
,
newRoute:
routeB
=
new
TestRoute
(
'b'
));
},
[
...
...
@@ -350,7 +350,7 @@ void main() {
runNavigatorTest
(
tester
,
host
,
(
Navigator
State
transaction
)
{
(
Navigator
Transaction
transaction
)
{
transaction
.
popUntil
(
routeB
);
},
[
...
...
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