parent
cbfed1960f
commit
3365b01f9a
@ -195,39 +195,42 @@ class _CupertinoButtonState extends State<CupertinoButton> with SingleTickerProv
|
|||||||
onTapUp: enabled ? _handleTapUp : null,
|
onTapUp: enabled ? _handleTapUp : null,
|
||||||
onTapCancel: enabled ? _handleTapCancel : null,
|
onTapCancel: enabled ? _handleTapCancel : null,
|
||||||
onTap: widget.onPressed,
|
onTap: widget.onPressed,
|
||||||
child: new ConstrainedBox(
|
child: new Semantics(
|
||||||
constraints: widget.minSize == null
|
button: true,
|
||||||
? const BoxConstraints()
|
child: new ConstrainedBox(
|
||||||
: new BoxConstraints(
|
constraints: widget.minSize == null
|
||||||
minWidth: widget.minSize,
|
? const BoxConstraints()
|
||||||
minHeight: widget.minSize,
|
: new BoxConstraints(
|
||||||
),
|
minWidth: widget.minSize,
|
||||||
child: new FadeTransition(
|
minHeight: widget.minSize,
|
||||||
opacity: _opacityTween.animate(new CurvedAnimation(
|
),
|
||||||
parent: _animationController,
|
child: new FadeTransition(
|
||||||
curve: Curves.decelerate,
|
opacity: _opacityTween.animate(new CurvedAnimation(
|
||||||
)),
|
parent: _animationController,
|
||||||
child: new DecoratedBox(
|
curve: Curves.decelerate,
|
||||||
decoration: new BoxDecoration(
|
)),
|
||||||
borderRadius: widget.borderRadius,
|
child: new DecoratedBox(
|
||||||
color: backgroundColor != null && !enabled
|
decoration: new BoxDecoration(
|
||||||
? _kDisabledBackground
|
borderRadius: widget.borderRadius,
|
||||||
: backgroundColor,
|
color: backgroundColor != null && !enabled
|
||||||
),
|
? _kDisabledBackground
|
||||||
child: new Padding(
|
: backgroundColor,
|
||||||
padding: widget.padding ?? (backgroundColor != null
|
),
|
||||||
? _kBackgroundButtonPadding
|
child: new Padding(
|
||||||
: _kButtonPadding),
|
padding: widget.padding ?? (backgroundColor != null
|
||||||
child: new Center(
|
? _kBackgroundButtonPadding
|
||||||
widthFactor: 1.0,
|
: _kButtonPadding),
|
||||||
heightFactor: 1.0,
|
child: new Center(
|
||||||
child: new DefaultTextStyle(
|
widthFactor: 1.0,
|
||||||
style: backgroundColor != null
|
heightFactor: 1.0,
|
||||||
? _kBackgroundButtonTextStyle
|
child: new DefaultTextStyle(
|
||||||
: enabled
|
style: backgroundColor != null
|
||||||
? _kButtonTextStyle
|
? _kBackgroundButtonTextStyle
|
||||||
: _kDisabledButtonTextStyle,
|
: enabled
|
||||||
child: widget.child,
|
? _kButtonTextStyle
|
||||||
|
: _kDisabledButtonTextStyle,
|
||||||
|
child: widget.child,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -2,10 +2,15 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'dart:ui' show SemanticsFlags;
|
||||||
|
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import '../widgets/semantics_tester.dart';
|
||||||
|
|
||||||
const TextStyle testStyle = const TextStyle(
|
const TextStyle testStyle = const TextStyle(
|
||||||
fontFamily: 'Ahem',
|
fontFamily: 'Ahem',
|
||||||
fontSize: 10.0,
|
fontSize: 10.0,
|
||||||
@ -164,6 +169,37 @@ void main() {
|
|||||||
));
|
));
|
||||||
expect(opacity.opacity, pressedOpacity);
|
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 }) {
|
Widget boilerplate({ Widget child }) {
|
||||||
@ -171,4 +207,4 @@ Widget boilerplate({ Widget child }) {
|
|||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: new Center(child: child),
|
child: new Center(child: child),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user