Update FAB elevation to match spec (#69312)
* Update floating_action_button.dart * Fix default hover elevation * revert letter spacing change * add test * Update floating_action_button.dart * Update floating_action_button_test.dart
This commit is contained in:
@@ -415,10 +415,8 @@ class FloatingActionButton extends StatelessWidget {
|
||||
final BoxConstraints _sizeConstraints;
|
||||
|
||||
static const double _defaultElevation = 6;
|
||||
// TODO(gspencer): verify focus and hover elevation values are correct
|
||||
// according to spec.
|
||||
static const double _defaultFocusElevation = 8;
|
||||
static const double _defaultHoverElevation = 10;
|
||||
static const double _defaultFocusElevation = 6;
|
||||
static const double _defaultHoverElevation = 8;
|
||||
static const double _defaultHighlightElevation = 12;
|
||||
static const ShapeBorder _defaultShape = CircleBorder();
|
||||
static const ShapeBorder _defaultExtendedShape = StadiumBorder();
|
||||
|
||||
@@ -312,6 +312,50 @@ void main() {
|
||||
expect(tester.widget<PhysicalShape>(find.byType(PhysicalShape)).elevation, 6.0);
|
||||
});
|
||||
|
||||
testWidgets('Floating Action Button states elevation', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode();
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: FloatingActionButton.extended(
|
||||
label: const Text('tooltip'),
|
||||
onPressed: () {},
|
||||
focusNode: focusNode,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final Finder fabFinder = find.byType(PhysicalShape);
|
||||
PhysicalShape getFABWidget(Finder finder) => tester.widget<PhysicalShape>(finder);
|
||||
|
||||
// Default, not disabled.
|
||||
expect(getFABWidget(fabFinder).elevation, 6);
|
||||
|
||||
// Focused.
|
||||
focusNode.requestFocus();
|
||||
await tester.pumpAndSettle();
|
||||
expect(getFABWidget(fabFinder).elevation, 6);
|
||||
|
||||
// Hovered.
|
||||
final Offset center = tester.getCenter(fabFinder);
|
||||
final TestGesture gesture = await tester.createGesture(
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
await gesture.addPointer();
|
||||
addTearDown(gesture.removePointer);
|
||||
await gesture.moveTo(center);
|
||||
await tester.pumpAndSettle();
|
||||
expect(getFABWidget(fabFinder).elevation, 8);
|
||||
|
||||
// Highlighted (pressed).
|
||||
await gesture.down(center);
|
||||
await tester.pump(); // Start the splash and highlight animations.
|
||||
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
|
||||
expect(getFABWidget(fabFinder).elevation, 12);
|
||||
});
|
||||
|
||||
testWidgets('FlatActionButton mini size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
|
||||
final Key key1 = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
|
||||
Reference in New Issue
Block a user