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
57d6cc42
Commit
57d6cc42
authored
Oct 03, 2016
by
Chris Bracken
Committed by
GitHub
Oct 03, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use platform-specific back icon in Scaffold (#6182)
parent
b329894b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletion
+47
-1
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+12
-1
scaffold_test.dart
packages/flutter/test/material/scaffold_test.dart
+35
-0
No files found.
packages/flutter/lib/src/material/scaffold.dart
View file @
57d6cc42
...
@@ -614,8 +614,19 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
...
@@ -614,8 +614,19 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
}
else
{
}
else
{
_shouldShowBackArrow
??=
Navigator
.
canPop
(
context
);
_shouldShowBackArrow
??=
Navigator
.
canPop
(
context
);
if
(
_shouldShowBackArrow
)
{
if
(
_shouldShowBackArrow
)
{
IconData
backIcon
;
switch
(
Theme
.
of
(
context
).
platform
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
backIcon
=
Icons
.
arrow_back
;
break
;
case
TargetPlatform
.
iOS
:
backIcon
=
Icons
.
arrow_back_ios
;
break
;
}
assert
(
backIcon
!=
null
);
leading
=
new
IconButton
(
leading
=
new
IconButton
(
icon:
new
Icon
(
Icons
.
arrow_back
),
icon:
new
Icon
(
backIcon
),
alignment:
FractionalOffset
.
centerLeft
,
alignment:
FractionalOffset
.
centerLeft
,
onPressed:
()
=>
Navigator
.
pop
(
context
),
onPressed:
()
=>
Navigator
.
pop
(
context
),
tooltip:
'Back'
// TODO(ianh): Figure out how to localize this string
tooltip:
'Back'
// TODO(ianh): Figure out how to localize this string
...
...
packages/flutter/test/material/scaffold_test.dart
View file @
57d6cc42
...
@@ -238,4 +238,39 @@ void main() {
...
@@ -238,4 +238,39 @@ void main() {
expect
(
appBarBottomRight
,
equals
(
sheetTopRight
));
expect
(
appBarBottomRight
,
equals
(
sheetTopRight
));
});
});
group
(
'back arrow'
,
()
{
Future
<
Null
>
expectBackIcon
(
WidgetTester
tester
,
TargetPlatform
platform
,
IconData
expectedIcon
)
async
{
GlobalKey
rootKey
=
new
GlobalKey
();
final
Map
<
String
,
WidgetBuilder
>
routes
=
<
String
,
WidgetBuilder
>{
'/'
:
(
_
)
=>
new
Container
(
key:
rootKey
,
child:
new
Text
(
'Home'
)),
'/scaffold'
:
(
_
)
=>
new
Scaffold
(
appBar:
new
AppBar
(),
body:
new
Text
(
'Scaffold'
),
)
};
await
tester
.
pumpWidget
(
new
MaterialApp
(
theme:
new
ThemeData
(
platform:
platform
),
routes:
routes
)
);
Navigator
.
pushNamed
(
rootKey
.
currentContext
,
'/scaffold'
);
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
Icon
icon
=
tester
.
widget
(
find
.
byType
(
Icon
));
expect
(
icon
.
icon
,
expectedIcon
);
}
testWidgets
(
'Back arrow uses correct default on Android'
,
(
WidgetTester
tester
)
async
{
await
expectBackIcon
(
tester
,
TargetPlatform
.
android
,
Icons
.
arrow_back
);
});
testWidgets
(
'Back arrow uses correct default on Fuchsia'
,
(
WidgetTester
tester
)
async
{
await
expectBackIcon
(
tester
,
TargetPlatform
.
fuchsia
,
Icons
.
arrow_back
);
});
testWidgets
(
'Back arrow uses correct default on iOS'
,
(
WidgetTester
tester
)
async
{
await
expectBackIcon
(
tester
,
TargetPlatform
.
iOS
,
Icons
.
arrow_back_ios
);
});
});
}
}
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