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
6fc7199d
Unverified
Commit
6fc7199d
authored
May 30, 2018
by
Jonah Williams
Committed by
GitHub
May 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add outer gesture detector to increase mini-fab size to 48x48 (#17921)
parent
62febaa1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
28 deletions
+110
-28
button.dart
packages/flutter/lib/src/material/button.dart
+46
-27
floating_action_button.dart
...ages/flutter/lib/src/material/floating_action_button.dart
+3
-1
raw_material_button_test.dart
packages/flutter/test/material/raw_material_button_test.dart
+61
-0
No files found.
packages/flutter/lib/src/material/button.dart
View file @
6fc7199d
...
...
@@ -38,6 +38,7 @@ class RawMaterialButton extends StatefulWidget {
this
.
elevation
:
2.0
,
this
.
highlightElevation
:
8.0
,
this
.
disabledElevation
:
0.0
,
this
.
outerPadding
,
this
.
padding
:
EdgeInsets
.
zero
,
this
.
constraints
:
const
BoxConstraints
(
minWidth:
88.0
,
minHeight:
36.0
),
this
.
shape
:
const
RoundedRectangleBorder
(),
...
...
@@ -57,6 +58,10 @@ class RawMaterialButton extends StatefulWidget {
/// If this is set to null, the button will be disabled, see [enabled].
final
VoidCallback
onPressed
;
/// Padding to increase the size of the gesture detector which doesn't
/// increase the visible material of the button.
final
EdgeInsets
outerPadding
;
/// Called by the underlying [InkWell] widget's [InkWell.onHighlightChanged]
/// callback.
final
ValueChanged
<
bool
>
onHighlightChanged
;
...
...
@@ -153,39 +158,53 @@ class _RawMaterialButtonState extends State<RawMaterialButton> {
?
(
_highlight
?
widget
.
highlightElevation
:
widget
.
elevation
)
:
widget
.
disabledElevation
;
return
new
Semantics
(
container:
true
,
button:
true
,
enabled:
widget
.
enabled
,
child:
new
ConstrainedBox
(
constraints:
widget
.
constraints
,
child:
new
Material
(
elevation:
elevation
,
textStyle:
widget
.
textStyle
,
shape:
widget
.
shape
,
color:
widget
.
fillColor
,
type:
widget
.
fillColor
==
null
?
MaterialType
.
transparency
:
MaterialType
.
button
,
animationDuration:
widget
.
animationDuration
,
child:
new
InkWell
(
onHighlightChanged:
_handleHighlightChanged
,
splashColor:
widget
.
splashColor
,
highlightColor:
widget
.
highlightColor
,
onTap:
widget
.
onPressed
,
child:
IconTheme
.
merge
(
data:
new
IconThemeData
(
color:
widget
.
textStyle
?.
color
),
child:
new
Container
(
padding:
widget
.
padding
,
child:
new
Center
(
widthFactor:
1.0
,
heightFactor:
1.0
,
child:
widget
.
child
,
),
Widget
result
=
new
ConstrainedBox
(
constraints:
widget
.
constraints
,
child:
new
Material
(
elevation:
elevation
,
textStyle:
widget
.
textStyle
,
shape:
widget
.
shape
,
color:
widget
.
fillColor
,
type:
widget
.
fillColor
==
null
?
MaterialType
.
transparency
:
MaterialType
.
button
,
animationDuration:
widget
.
animationDuration
,
child:
new
InkWell
(
onHighlightChanged:
_handleHighlightChanged
,
splashColor:
widget
.
splashColor
,
highlightColor:
widget
.
highlightColor
,
onTap:
widget
.
onPressed
,
child:
IconTheme
.
merge
(
data:
new
IconThemeData
(
color:
widget
.
textStyle
?.
color
),
child:
new
Container
(
padding:
widget
.
padding
,
child:
new
Center
(
widthFactor:
1.0
,
heightFactor:
1.0
,
child:
widget
.
child
,
),
),
),
),
),
);
if
(
widget
.
outerPadding
!=
null
)
{
result
=
new
GestureDetector
(
behavior:
HitTestBehavior
.
translucent
,
excludeFromSemantics:
true
,
onTap:
widget
.
onPressed
,
child:
new
Padding
(
padding:
widget
.
outerPadding
,
child:
result
),
);
}
return
new
Semantics
(
container:
true
,
button:
true
,
enabled:
widget
.
enabled
,
child:
result
,
);
}
}
...
...
packages/flutter/lib/src/material/floating_action_button.dart
View file @
6fc7199d
...
...
@@ -187,7 +187,8 @@ class FloatingActionButton extends StatefulWidget {
///
/// By default, floating action buttons are non-mini and have a height and
/// width of 56.0 logical pixels. Mini floating action buttons have a height
/// and width of 40.0 logical pixels.
/// and width of 40.0 logical pixels with a layout width and height of 48.0
/// logical pixels.
final
bool
mini
;
/// The margin to keep around the floating action button when creating a
...
...
@@ -267,6 +268,7 @@ class _FloatingActionButtonState extends State<FloatingActionButton> {
onHighlightChanged:
_handleHighlightChanged
,
elevation:
_highlight
?
widget
.
highlightElevation
:
widget
.
elevation
,
constraints:
widget
.
_sizeConstraints
,
outerPadding:
widget
.
mini
?
const
EdgeInsets
.
all
(
4.0
)
:
null
,
fillColor:
widget
.
backgroundColor
??
theme
.
accentColor
,
textStyle:
theme
.
accentTextTheme
.
button
.
copyWith
(
color:
foregroundColor
,
...
...
packages/flutter/test/material/raw_material_button_test.dart
0 → 100644
View file @
6fc7199d
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'../widgets/semantics_tester.dart'
;
void
main
(
)
{
testWidgets
(
'outerPadding expands hit test area'
,
(
WidgetTester
tester
)
async
{
int
pressed
=
0
;
await
tester
.
pumpWidget
(
new
RawMaterialButton
(
onPressed:
()
{
pressed
++;
},
constraints:
new
BoxConstraints
.
tight
(
const
Size
(
10.0
,
10.0
)),
outerPadding:
const
EdgeInsets
.
all
(
50.0
),
child:
const
Text
(
'+'
,
textDirection:
TextDirection
.
ltr
),
));
await
tester
.
tapAt
(
const
Offset
(
100.0
,
100.0
));
expect
(
pressed
,
1
);
});
testWidgets
(
'outerPadding expands semantics area'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
new
Center
(
child:
new
RawMaterialButton
(
onPressed:
()
{},
constraints:
new
BoxConstraints
.
tight
(
const
Size
(
10.0
,
10.0
)),
outerPadding:
const
EdgeInsets
.
all
(
50.0
),
child:
const
Text
(
'+'
,
textDirection:
TextDirection
.
ltr
),
),
),
);
expect
(
semantics
,
hasSemantics
(
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
(
id:
1
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isButton
,
SemanticsFlag
.
hasEnabledState
,
SemanticsFlag
.
isEnabled
,
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
],
label:
'+'
,
textDirection:
TextDirection
.
ltr
,
rect:
Rect
.
fromLTRB
(
0.0
,
0.0
,
110.0
,
110.0
),
children:
<
TestSemantics
>[],
),
]
),
ignoreTransform:
true
));
semantics
.
dispose
();
});
}
\ No newline at end of file
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