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
3265e159
Unverified
Commit
3265e159
authored
May 21, 2019
by
Shi-Hao Hong
Committed by
GitHub
May 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SliverAppBar shape property (#33073)
parent
277d5fe5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
11 deletions
+88
-11
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+11
-0
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+77
-11
No files found.
packages/flutter/lib/src/material/app_bar.dart
View file @
3265e159
...
...
@@ -687,6 +687,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
@required
this
.
floating
,
@required
this
.
pinned
,
@required
this
.
snapConfiguration
,
@required
this
.
shape
,
})
:
assert
(
primary
||
topPadding
==
0.0
),
_bottomHeight
=
bottom
?.
preferredSize
?.
height
??
0.0
;
...
...
@@ -711,6 +712,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
final
double
topPadding
;
final
bool
floating
;
final
bool
pinned
;
final
ShapeBorder
shape
;
final
double
_bottomHeight
;
...
...
@@ -765,6 +767,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
primary:
primary
,
centerTitle:
centerTitle
,
titleSpacing:
titleSpacing
,
shape:
shape
,
toolbarOpacity:
toolbarOpacity
,
bottomOpacity:
pinned
?
1.0
:
(
visibleMainHeight
/
_bottomHeight
).
clamp
(
0.0
,
1.0
),
),
...
...
@@ -908,6 +911,7 @@ class SliverAppBar extends StatefulWidget {
this
.
floating
=
false
,
this
.
pinned
=
false
,
this
.
snap
=
false
,
this
.
shape
,
})
:
assert
(
automaticallyImplyLeading
!=
null
),
assert
(
forceElevated
!=
null
),
assert
(
primary
!=
null
),
...
...
@@ -1125,6 +1129,12 @@ class SliverAppBar extends StatefulWidget {
/// behavior of the app bar in combination with [floating].
final
bool
pinned
;
/// The material's shape as well its shadow.
///
/// A shadow is only displayed if the [elevation] is greater than
/// zero.
final
ShapeBorder
shape
;
/// If [snap] and [floating] are true then the floating app bar will "snap"
/// into view.
///
...
...
@@ -1221,6 +1231,7 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
topPadding:
topPadding
,
floating:
widget
.
floating
,
pinned:
widget
.
pinned
,
shape:
widget
.
shape
,
snapConfiguration:
_snapConfiguration
,
),
),
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
3265e159
...
...
@@ -1425,7 +1425,6 @@ void main() {
testWidgets
(
'Changing SliverAppBar snap from true to false'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/17598
const
double
appBarHeight
=
256.0
;
bool
snap
=
true
;
...
...
@@ -1486,32 +1485,99 @@ void main() {
await
tester
.
pump
();
});
testWidgets
(
'AppBar shape default'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
AppBar
(
leading:
const
Text
(
'L'
),
title:
const
Text
(
'No Scaffold'
),
actions:
const
<
Widget
>[
Text
(
'A1'
),
Text
(
'A2'
)],
),
),
);
final
Finder
appBarFinder
=
find
.
byType
(
AppBar
);
AppBar
getAppBarWidget
(
Finder
finder
)
=>
tester
.
widget
<
AppBar
>(
finder
);
expect
(
getAppBarWidget
(
appBarFinder
).
shape
,
null
);
final
Finder
materialFinder
=
find
.
byType
(
Material
);
Material
getMaterialWidget
(
Finder
finder
)
=>
tester
.
widget
<
Material
>(
finder
);
expect
(
getMaterialWidget
(
materialFinder
).
shape
,
null
);
});
testWidgets
(
'AppBar with shape'
,
(
WidgetTester
tester
)
async
{
const
RoundedRectangleBorder
roundedRectangleBorder
=
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
15.0
)));
const
RoundedRectangleBorder
roundedRectangleBorder
=
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
15.0
))
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
AppBar
(
leading:
const
Text
(
'L'
),
title:
const
Text
(
'No Scaffold'
),
shape:
roundedRectangleBorder
,
actions:
const
<
Widget
>[
Text
(
'A1'
),
Text
(
'A2'
)],
shape:
roundedRectangleBorder
,
),
),
);
final
Finder
appBarFinder
=
find
.
byType
(
AppBar
);
AppBar
getAppBarWidget
(
Finder
finder
)
=>
tester
.
widget
<
AppBar
>(
finder
);
expect
(
getAppBarWidget
(
appBarFinder
).
shape
,
roundedRectangleBorder
);
AppBar
getAppBarWidget
()
{
return
tester
.
widget
<
AppBar
>(
appBarFinder
);
}
final
Finder
materialFinder
=
find
.
byType
(
Material
);
Material
getMaterialWidget
(
Finder
finder
)
=>
tester
.
widget
<
Material
>(
finder
);
expect
(
getMaterialWidget
(
materialFinder
).
shape
,
roundedRectangleBorder
);
});
testWidgets
(
'SliverAppBar shape default'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
CustomScrollView
(
slivers:
<
Widget
>[
SliverAppBar
(
leading:
Text
(
'L'
),
title:
Text
(
'No Scaffold'
),
actions:
<
Widget
>[
Text
(
'A1'
),
Text
(
'A2'
)],
),
],
),
),
);
expect
(
getAppBarWidget
().
shape
,
roundedRectangleBorder
);
final
Finder
sliverAppBarFinder
=
find
.
byType
(
SliverAppBar
);
SliverAppBar
getSliverAppBarWidget
(
Finder
finder
)
=>
tester
.
widget
<
SliverAppBar
>(
finder
);
expect
(
getSliverAppBarWidget
(
sliverAppBarFinder
).
shape
,
null
);
final
Finder
materialFinder
=
find
.
byType
(
Material
);
Material
getMaterialWidget
(
)
{
return
tester
.
widget
<
Material
>(
materialFinder
);
}
Material
getMaterialWidget
(
Finder
finder
)
=>
tester
.
widget
<
Material
>(
finder
);
expect
(
getMaterialWidget
(
materialFinder
).
shape
,
null
);
});
expect
(
getMaterialWidget
().
shape
,
roundedRectangleBorder
);
testWidgets
(
'SliverAppBar with shape'
,
(
WidgetTester
tester
)
async
{
const
RoundedRectangleBorder
roundedRectangleBorder
=
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
15.0
)),
);
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
CustomScrollView
(
slivers:
<
Widget
>[
SliverAppBar
(
leading:
Text
(
'L'
),
title:
Text
(
'No Scaffold'
),
actions:
<
Widget
>[
Text
(
'A1'
),
Text
(
'A2'
)],
shape:
roundedRectangleBorder
,
),
],
),
),
);
final
Finder
sliverAppBarFinder
=
find
.
byType
(
SliverAppBar
);
SliverAppBar
getSliverAppBarWidget
(
Finder
finder
)
=>
tester
.
widget
<
SliverAppBar
>(
finder
);
expect
(
getSliverAppBarWidget
(
sliverAppBarFinder
).
shape
,
roundedRectangleBorder
);
final
Finder
materialFinder
=
find
.
byType
(
Material
);
Material
getMaterialWidget
(
Finder
finder
)
=>
tester
.
widget
<
Material
>(
finder
);
expect
(
getMaterialWidget
(
materialFinder
).
shape
,
roundedRectangleBorder
);
});
}
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