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
e8343c0e
Unverified
Commit
e8343c0e
authored
Oct 14, 2020
by
Albert Wolszon
Committed by
GitHub
Oct 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing margin to SnackBarAction (#67167)
parent
1fb94fb8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
14 deletions
+92
-14
snack_bar.dart
packages/flutter/lib/src/material/snack_bar.dart
+11
-6
snack_bar_test.dart
packages/flutter/test/material/snack_bar_test.dart
+81
-8
No files found.
packages/flutter/lib/src/material/snack_bar.dart
View file @
e8343c0e
...
@@ -427,6 +427,8 @@ class _SnackBarState extends State<SnackBar> {
...
@@ -427,6 +427,8 @@ class _SnackBarState extends State<SnackBar> {
final
EdgeInsetsGeometry
padding
=
widget
.
padding
final
EdgeInsetsGeometry
padding
=
widget
.
padding
??
EdgeInsetsDirectional
.
only
(
start:
horizontalPadding
,
end:
widget
.
action
!=
null
?
0
:
horizontalPadding
);
??
EdgeInsetsDirectional
.
only
(
start:
horizontalPadding
,
end:
widget
.
action
!=
null
?
0
:
horizontalPadding
);
final
double
actionHorizontalMargin
=
(
widget
.
padding
?.
resolve
(
TextDirection
.
ltr
).
right
??
horizontalPadding
)
/
2
;
final
CurvedAnimation
heightAnimation
=
CurvedAnimation
(
parent:
widget
.
animation
!,
curve:
_snackBarHeightCurve
);
final
CurvedAnimation
heightAnimation
=
CurvedAnimation
(
parent:
widget
.
animation
!,
curve:
_snackBarHeightCurve
);
final
CurvedAnimation
fadeInAnimation
=
CurvedAnimation
(
parent:
widget
.
animation
!,
curve:
_snackBarFadeInCurve
);
final
CurvedAnimation
fadeInAnimation
=
CurvedAnimation
(
parent:
widget
.
animation
!,
curve:
_snackBarFadeInCurve
);
final
CurvedAnimation
fadeOutAnimation
=
CurvedAnimation
(
final
CurvedAnimation
fadeOutAnimation
=
CurvedAnimation
(
...
@@ -450,14 +452,17 @@ class _SnackBarState extends State<SnackBar> {
...
@@ -450,14 +452,17 @@ class _SnackBarState extends State<SnackBar> {
),
),
),
),
if
(
widget
.
action
!=
null
)
if
(
widget
.
action
!=
null
)
TextButtonTheme
(
Padding
(
data:
TextButtonThemeData
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
actionHorizontalMargin
),
style:
TextButton
.
styleFrom
(
child:
TextButtonTheme
(
primary:
buttonColor
,
data:
TextButtonThemeData
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
horizontalPadding
),
style:
TextButton
.
styleFrom
(
primary:
buttonColor
,
padding:
EdgeInsets
.
symmetric
(
horizontal:
horizontalPadding
),
),
),
),
child:
widget
.
action
!,
),
),
child:
widget
.
action
!,
),
),
],
],
),
),
...
...
packages/flutter/test/material/snack_bar_test.dart
View file @
e8343c0e
...
@@ -972,8 +972,8 @@ void main() {
...
@@ -972,8 +972,8 @@ void main() {
expect
(
textBottomLeft
.
dx
-
snackBarBottomLeft
.
dx
,
24.0
+
10.0
);
// margin + left padding
expect
(
textBottomLeft
.
dx
-
snackBarBottomLeft
.
dx
,
24.0
+
10.0
);
// margin + left padding
expect
(
snackBarBottomLeft
.
dy
-
textBottomLeft
.
dy
,
17.0
+
40.0
);
// margin + bottom padding
expect
(
snackBarBottomLeft
.
dy
-
textBottomLeft
.
dy
,
17.0
+
40.0
);
// margin + bottom padding
expect
(
actionTextBottomLeft
.
dx
-
textBottomRight
.
dx
,
24.0
);
expect
(
actionTextBottomLeft
.
dx
-
textBottomRight
.
dx
,
24.0
+
12.0
);
// action padding + margin
expect
(
snackBarBottomRight
.
dx
-
actionTextBottomRight
.
dx
,
24.0
+
30.0
);
// margin
+ right padding
expect
(
snackBarBottomRight
.
dx
-
actionTextBottomRight
.
dx
,
24.0
+
12.0
+
30.0
);
// action (padding + margin)
+ right padding
expect
(
snackBarBottomRight
.
dy
-
actionTextBottomRight
.
dy
,
17.0
+
40.0
);
// margin + bottom padding
expect
(
snackBarBottomRight
.
dy
-
actionTextBottomRight
.
dy
,
17.0
+
40.0
);
// margin + bottom padding
});
});
...
@@ -1027,8 +1027,8 @@ void main() {
...
@@ -1027,8 +1027,8 @@ void main() {
expect
(
textBottomLeft
.
dx
-
snackBarBottomLeft
.
dx
,
24.0
+
10.0
);
// margin + left padding
expect
(
textBottomLeft
.
dx
-
snackBarBottomLeft
.
dx
,
24.0
+
10.0
);
// margin + left padding
expect
(
snackBarBottomLeft
.
dy
-
textBottomLeft
.
dy
,
17.0
);
// margin (with no bottom padding)
expect
(
snackBarBottomLeft
.
dy
-
textBottomLeft
.
dy
,
17.0
);
// margin (with no bottom padding)
expect
(
actionTextBottomLeft
.
dx
-
textBottomRight
.
dx
,
24.0
);
expect
(
actionTextBottomLeft
.
dx
-
textBottomRight
.
dx
,
24.0
+
12.0
);
// action padding + margin
expect
(
snackBarBottomRight
.
dx
-
actionTextBottomRight
.
dx
,
24.0
+
30.0
);
// margin
+ right padding
expect
(
snackBarBottomRight
.
dx
-
actionTextBottomRight
.
dx
,
24.0
+
12.0
+
30.0
);
// action (padding + margin)
+ right padding
expect
(
snackBarBottomRight
.
dy
-
actionTextBottomRight
.
dy
,
17.0
);
// margin (with no bottom padding)
expect
(
snackBarBottomRight
.
dy
-
actionTextBottomRight
.
dy
,
17.0
);
// margin (with no bottom padding)
});
});
...
@@ -1132,8 +1132,8 @@ void main() {
...
@@ -1132,8 +1132,8 @@ void main() {
expect
(
textBottomLeft
.
dx
-
snackBarBottomLeft
.
dx
,
31.0
+
10.0
);
// margin + left padding
expect
(
textBottomLeft
.
dx
-
snackBarBottomLeft
.
dx
,
31.0
+
10.0
);
// margin + left padding
expect
(
snackBarBottomLeft
.
dy
-
textBottomLeft
.
dy
,
27.0
);
// margin (with no bottom padding)
expect
(
snackBarBottomLeft
.
dy
-
textBottomLeft
.
dy
,
27.0
);
// margin (with no bottom padding)
expect
(
actionTextBottomLeft
.
dx
-
textBottomRight
.
dx
,
16.0
);
expect
(
actionTextBottomLeft
.
dx
-
textBottomRight
.
dx
,
16.0
+
8.0
);
// action padding + margin
expect
(
snackBarBottomRight
.
dx
-
actionTextBottomRight
.
dx
,
31.0
+
30.0
);
// margin + right padding
expect
(
snackBarBottomRight
.
dx
-
actionTextBottomRight
.
dx
,
31.0
+
30.0
+
8.0
);
// margin + right (padding + margin)
expect
(
snackBarBottomRight
.
dy
-
actionTextBottomRight
.
dy
,
27.0
);
// margin (with no bottom padding)
expect
(
snackBarBottomRight
.
dy
-
actionTextBottomRight
.
dy
,
27.0
);
// margin (with no bottom padding)
});
});
...
@@ -1190,8 +1190,8 @@ void main() {
...
@@ -1190,8 +1190,8 @@ void main() {
expect
(
textBottomLeft
.
dx
-
snackBarBottomLeft
.
dx
,
31.0
+
10.0
);
// margin + left padding
expect
(
textBottomLeft
.
dx
-
snackBarBottomLeft
.
dx
,
31.0
+
10.0
);
// margin + left padding
expect
(
snackBarBottomLeft
.
dy
-
textBottomLeft
.
dy
,
27.0
);
// margin (with no bottom padding)
expect
(
snackBarBottomLeft
.
dy
-
textBottomLeft
.
dy
,
27.0
);
// margin (with no bottom padding)
expect
(
actionTextBottomLeft
.
dx
-
textBottomRight
.
dx
,
16.0
);
expect
(
actionTextBottomLeft
.
dx
-
textBottomRight
.
dx
,
16.0
+
8.0
);
// action (margin + padding)
expect
(
snackBarBottomRight
.
dx
-
actionTextBottomRight
.
dx
,
31.0
+
30.0
);
// margin + right padding
expect
(
snackBarBottomRight
.
dx
-
actionTextBottomRight
.
dx
,
31.0
+
30.0
+
8.0
);
// margin + right (padding + margin)
expect
(
snackBarBottomRight
.
dy
-
actionTextBottomRight
.
dy
,
27.0
);
// margin (with no bottom padding)
expect
(
snackBarBottomRight
.
dy
-
actionTextBottomRight
.
dy
,
27.0
);
// margin (with no bottom padding)
});
});
...
@@ -1942,6 +1942,79 @@ void main() {
...
@@ -1942,6 +1942,79 @@ void main() {
expect
(
snackBarBottomRight
.
dy
,
equals
(
fabTopRight
.
dy
));
expect
(
snackBarBottomRight
.
dy
,
equals
(
fabTopRight
.
dy
));
},
},
);
);
testWidgets
(
'SnackBar has correct end padding when it contains an action with fixed behavior'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
Builder
(
builder:
(
BuildContext
context
)
{
return
GestureDetector
(
onTap:
()
{
Scaffold
.
of
(
context
)!.
showSnackBar
(
SnackBar
(
content:
const
Text
(
'Some content'
),
behavior:
SnackBarBehavior
.
fixed
,
action:
SnackBarAction
(
label:
'ACTION'
,
onPressed:
()
{},
),
));
},
child:
const
Text
(
'X'
),
);
},
),
),
),
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
Offset
snackBarTopRight
=
tester
.
getTopRight
(
find
.
byType
(
SnackBar
));
final
Offset
actionTopRight
=
tester
.
getTopRight
(
find
.
byType
(
SnackBarAction
));
expect
(
snackBarTopRight
.
dx
-
actionTopRight
.
dx
,
12.0
);
},
);
testWidgets
(
'SnackBar has correct end padding when it contains an action with floating behavior'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
Builder
(
builder:
(
BuildContext
context
)
{
return
GestureDetector
(
onTap:
()
{
Scaffold
.
of
(
context
)!.
showSnackBar
(
SnackBar
(
content:
const
Text
(
'Some content'
),
behavior:
SnackBarBehavior
.
floating
,
action:
SnackBarAction
(
label:
'ACTION'
,
onPressed:
()
{},
),
));
},
child:
const
Text
(
'X'
),
);
},
),
),
),
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
Offset
snackBarTopRight
=
tester
.
getTopRight
(
find
.
byType
(
SnackBar
));
final
Offset
actionTopRight
=
tester
.
getTopRight
(
find
.
byType
(
SnackBarAction
));
expect
(
snackBarTopRight
.
dx
-
actionTopRight
.
dx
,
8.0
+
15.0
);
// button margin + horizontal scaffold outside margin
},
);
});
});
testWidgets
(
'SnackBars hero across transitions when using ScaffoldMessenger'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'SnackBars hero across transitions when using ScaffoldMessenger'
,
(
WidgetTester
tester
)
async
{
...
...
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