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
3365b01f
Commit
3365b01f
authored
Oct 25, 2017
by
amirh
Committed by
GitHub
Oct 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add button semantics to CupertinoButton (#12715)
fixes #11992
parent
cbfed196
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
34 deletions
+73
-34
button.dart
packages/flutter/lib/src/cupertino/button.dart
+36
-33
button_test.dart
packages/flutter/test/cupertino/button_test.dart
+37
-1
No files found.
packages/flutter/lib/src/cupertino/button.dart
View file @
3365b01f
...
...
@@ -195,39 +195,42 @@ class _CupertinoButtonState extends State<CupertinoButton> with SingleTickerProv
onTapUp:
enabled
?
_handleTapUp
:
null
,
onTapCancel:
enabled
?
_handleTapCancel
:
null
,
onTap:
widget
.
onPressed
,
child:
new
ConstrainedBox
(
constraints:
widget
.
minSize
==
null
?
const
BoxConstraints
()
:
new
BoxConstraints
(
minWidth:
widget
.
minSize
,
minHeight:
widget
.
minSize
,
),
child:
new
FadeTransition
(
opacity:
_opacityTween
.
animate
(
new
CurvedAnimation
(
parent:
_animationController
,
curve:
Curves
.
decelerate
,
)),
child:
new
DecoratedBox
(
decoration:
new
BoxDecoration
(
borderRadius:
widget
.
borderRadius
,
color:
backgroundColor
!=
null
&&
!
enabled
?
_kDisabledBackground
:
backgroundColor
,
),
child:
new
Padding
(
padding:
widget
.
padding
??
(
backgroundColor
!=
null
?
_kBackgroundButtonPadding
:
_kButtonPadding
),
child:
new
Center
(
widthFactor:
1.0
,
heightFactor:
1.0
,
child:
new
DefaultTextStyle
(
style:
backgroundColor
!=
null
?
_kBackgroundButtonTextStyle
:
enabled
?
_kButtonTextStyle
:
_kDisabledButtonTextStyle
,
child:
widget
.
child
,
child:
new
Semantics
(
button:
true
,
child:
new
ConstrainedBox
(
constraints:
widget
.
minSize
==
null
?
const
BoxConstraints
()
:
new
BoxConstraints
(
minWidth:
widget
.
minSize
,
minHeight:
widget
.
minSize
,
),
child:
new
FadeTransition
(
opacity:
_opacityTween
.
animate
(
new
CurvedAnimation
(
parent:
_animationController
,
curve:
Curves
.
decelerate
,
)),
child:
new
DecoratedBox
(
decoration:
new
BoxDecoration
(
borderRadius:
widget
.
borderRadius
,
color:
backgroundColor
!=
null
&&
!
enabled
?
_kDisabledBackground
:
backgroundColor
,
),
child:
new
Padding
(
padding:
widget
.
padding
??
(
backgroundColor
!=
null
?
_kBackgroundButtonPadding
:
_kButtonPadding
),
child:
new
Center
(
widthFactor:
1.0
,
heightFactor:
1.0
,
child:
new
DefaultTextStyle
(
style:
backgroundColor
!=
null
?
_kBackgroundButtonTextStyle
:
enabled
?
_kButtonTextStyle
:
_kDisabledButtonTextStyle
,
child:
widget
.
child
,
),
),
),
),
...
...
packages/flutter/test/cupertino/button_test.dart
View file @
3365b01f
...
...
@@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
show
SemanticsFlags
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'../widgets/semantics_tester.dart'
;
const
TextStyle
testStyle
=
const
TextStyle
(
fontFamily:
'Ahem'
,
fontSize:
10.0
,
...
...
@@ -164,6 +169,37 @@ void main() {
));
expect
(
opacity
.
opacity
,
pressedOpacity
);
});
testWidgets
(
'Cupertino button is semantically a button'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
boilerplate
(
child:
new
Center
(
child:
new
CupertinoButton
(
onPressed:
()
{
},
child:
const
Text
(
'ABC'
)
),
),
),
);
expect
(
semantics
,
hasSemantics
(
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
.
rootChild
(
actions:
SemanticsAction
.
tap
.
index
,
label:
'ABC'
,
flags:
SemanticsFlags
.
isButton
.
index
,
)
],
),
ignoreId:
true
,
ignoreRect:
true
,
ignoreTransform:
true
,
));
semantics
.
dispose
();
});
}
Widget
boilerplate
(
{
Widget
child
})
{
...
...
@@ -171,4 +207,4 @@ Widget boilerplate({ Widget child }) {
textDirection:
TextDirection
.
ltr
,
child:
new
Center
(
child:
child
),
);
}
\ 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