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
96ec30b8
Commit
96ec30b8
authored
Aug 17, 2016
by
Hans Muller
Committed by
GitHub
Aug 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Pesto appbar heroics (#5447)
parent
ade895de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
17 deletions
+43
-17
pesto_demo.dart
examples/flutter_gallery/lib/demo/pesto_demo.dart
+7
-11
pesto_test.dart
examples/flutter_gallery/test/pesto_test.dart
+36
-6
No files found.
examples/flutter_gallery/lib/demo/pesto_demo.dart
View file @
96ec30b8
...
...
@@ -9,11 +9,9 @@ import 'package:flutter/material.dart';
const
String
_kUserName
=
'Jonathan'
;
const
String
_kUserEmail
=
'jonathan@example.com'
;
const
String
_kUserImage
=
'packages/flutter_gallery_assets/pesto/avatar.jpg'
;
// Map of logo images keyed by the minimum height their container needs to be.
final
Map
<
double
,
String
>
_kLogoImages
=
<
double
,
String
>{
0.0
:
'packages/flutter_gallery_assets/pesto/logo_small.png'
,
70.0
:
'packages/flutter_gallery_assets/pesto/logo_medium.png'
};
const
String
_kSmallLogoImage
=
'packages/flutter_gallery_assets/pesto/logo_small.png'
;
const
String
_kMediumLogoImage
=
'packages/flutter_gallery_assets/pesto/logo_medium.png'
;
final
ThemeData
_kTheme
=
new
ThemeData
(
brightness:
Brightness
.
light
,
...
...
@@ -94,20 +92,18 @@ class _PestoDemoState extends State<PestoDemo> {
flexibleSpace:
new
LayoutBuilder
(
builder:
(
BuildContext
context
,
BoxConstraints
constraints
)
{
final
Size
size
=
constraints
.
biggest
;
double
appBarHeight
=
size
.
height
-
statusBarHeight
;
double
bestHeight
=
_kLogoImages
.
keys
.
lastWhere
(
(
double
height
)
=>
appBarHeight
>=
height
);
final
double
appBarHeight
=
size
.
height
-
statusBarHeight
;
final
String
logo
=
appBarHeight
>=
70.0
?
_kMediumLogoImage
:
_kSmallLogoImage
;
// Extra padding. Calculated to give about 16px on the bottom for the
// `small` logo at its native size, and 30px for the `medium`.
double
extraPadding
=
min
(
0.19
*
appBarHeight
+
5.4
,
40.0
);
final
double
extraPadding
=
min
(
0.19
*
appBarHeight
+
5.4
,
40.0
);
return
new
Padding
(
padding:
new
EdgeInsets
.
only
(
top:
statusBarHeight
+
0.5
*
extraPadding
,
bottom:
extraPadding
),
child:
new
Center
(
child:
new
Image
.
asset
(
_kLogoImages
[
bestHeight
]
,
fit:
ImageFit
.
scaleDown
)
child:
new
Image
.
asset
(
logo
,
fit:
ImageFit
.
scaleDown
)
)
);
}
...
...
examples/flutter_gallery/test/pesto_test.dart
View file @
96ec30b8
...
...
@@ -4,7 +4,7 @@
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_gallery/
main.dart'
as
flutter_gallery_main
;
import
'package:flutter_gallery/
gallery/app.dart'
;
Finder
byTooltip
(
WidgetTester
tester
,
String
message
)
{
return
find
.
byWidgetPredicate
((
Widget
widget
)
{
...
...
@@ -17,14 +17,13 @@ Finder findNavigationMenuButton(WidgetTester tester) {
}
void
main
(
)
{
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
binding
.
allowAllFrames
=
true
;
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
binding
.
allowAllFrames
=
true
;
// Regression test for https://github.com/flutter/flutter/pull/5168
testWidgets
(
'Pesto route management'
,
(
WidgetTester
tester
)
async
{
flutter_gallery_main
.
main
();
// builds the app and schedules a frame but doesn't trigger one
await
tester
.
pumpWidget
(
new
GalleryApp
());
await
tester
.
pump
();
// see https://github.com/flutter/flutter/issues/1865
await
tester
.
pump
();
// triggers a frame
...
...
@@ -52,4 +51,35 @@ void main() {
expect
(
find
.
text
(
'Flutter Gallery'
),
findsOneWidget
);
});
// Regression test for https://github.com/flutter/flutter/pull/5168
testWidgets
(
'Pesto appbar heroics'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
// The bug only manifests itself when the screen's orientation is portait
new
Center
(
child:
new
SizedBox
(
width:
400.0
,
height:
800.0
,
child:
new
GalleryApp
()
)
)
);
await
tester
.
pump
();
// see https://github.com/flutter/flutter/issues/1865
await
tester
.
pump
();
// triggers a frame
await
tester
.
tap
(
find
.
text
(
'Pesto'
));
await
tester
.
pump
();
// Launch pesto
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// transition is complete
await
tester
.
tap
(
find
.
text
(
'Pesto Bruchetta'
));
await
tester
.
pump
();
// Launch the recipe page
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// transition is complete
await
tester
.
scroll
(
find
.
text
(
'Pesto Bruchetta'
),
const
Offset
(
0.0
,
-
300.0
));
await
tester
.
pump
();
Navigator
.
pop
(
find
.
byType
(
Scaffold
).
evaluate
().
single
);
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// transition is complete
});
}
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