Unverified Commit a8e6fd5b authored by Darren Austin's avatar Darren Austin Committed by GitHub

Material 3 common buttons should use sparkle splash effect on Android. (#101075)

parent 9da7317d
...@@ -306,7 +306,7 @@ class ElevatedButton extends ButtonStyleButton { ...@@ -306,7 +306,7 @@ class ElevatedButton extends ButtonStyleButton {
animationDuration: kThemeChangeDuration, animationDuration: kThemeChangeDuration,
enableFeedback: true, enableFeedback: true,
alignment: Alignment.center, alignment: Alignment.center,
splashFactory: InkRipple.splashFactory, splashFactory: theme.useMaterial3 ? theme.splashFactory : InkRipple.splashFactory,
); );
} }
......
...@@ -281,7 +281,7 @@ class OutlinedButton extends ButtonStyleButton { ...@@ -281,7 +281,7 @@ class OutlinedButton extends ButtonStyleButton {
animationDuration: kThemeChangeDuration, animationDuration: kThemeChangeDuration,
enableFeedback: true, enableFeedback: true,
alignment: Alignment.center, alignment: Alignment.center,
splashFactory: InkRipple.splashFactory, splashFactory: theme.useMaterial3 ? theme.splashFactory : InkRipple.splashFactory,
); );
} }
......
...@@ -294,7 +294,7 @@ class TextButton extends ButtonStyleButton { ...@@ -294,7 +294,7 @@ class TextButton extends ButtonStyleButton {
animationDuration: kThemeChangeDuration, animationDuration: kThemeChangeDuration,
enableFeedback: true, enableFeedback: true,
alignment: Alignment.center, alignment: Alignment.center,
splashFactory: InkRipple.splashFactory, splashFactory: theme.useMaterial3 ? theme.splashFactory : InkRipple.splashFactory,
); );
} }
......
...@@ -26,6 +26,7 @@ import 'drawer_theme.dart'; ...@@ -26,6 +26,7 @@ import 'drawer_theme.dart';
import 'elevated_button_theme.dart'; import 'elevated_button_theme.dart';
import 'expansion_tile_theme.dart'; import 'expansion_tile_theme.dart';
import 'floating_action_button_theme.dart'; import 'floating_action_button_theme.dart';
import 'ink_ripple.dart';
import 'ink_sparkle.dart'; import 'ink_sparkle.dart';
import 'ink_splash.dart'; import 'ink_splash.dart';
import 'ink_well.dart' show InteractiveInkFeatureFactory; import 'ink_well.dart' show InteractiveInkFeatureFactory;
...@@ -446,7 +447,9 @@ class ThemeData with Diagnosticable { ...@@ -446,7 +447,9 @@ class ThemeData with Diagnosticable {
visualDensity ??= VisualDensity.adaptivePlatformDensity; visualDensity ??= VisualDensity.adaptivePlatformDensity;
useMaterial3 ??= false; useMaterial3 ??= false;
final bool useInkSparkle = platform == TargetPlatform.android && !kIsWeb; final bool useInkSparkle = platform == TargetPlatform.android && !kIsWeb;
splashFactory ??= (useMaterial3 && useInkSparkle) ? InkSparkle.splashFactory : InkSplash.splashFactory; splashFactory ??= useMaterial3
? useInkSparkle ? InkSparkle.splashFactory : InkRipple.splashFactory
: InkSplash.splashFactory;
// COLOR // COLOR
assert(colorScheme?.brightness == null || brightness == null || colorScheme!.brightness == brightness); assert(colorScheme?.brightness == null || brightness == null || colorScheme!.brightness == brightness);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// 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 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -1272,6 +1273,55 @@ void main() { ...@@ -1272,6 +1273,55 @@ void main() {
} }
}); });
testWidgets('ElevatedButton uses InkSparkle only for Android non-web when useMaterial3 is true', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Center(
child: ElevatedButton(
onPressed: () { },
child: const Text('button'),
),
),
),
);
final InkWell buttonInkWell = tester.widget<InkWell>(find.descendant(
of: find.byType(ElevatedButton),
matching: find.byType(InkWell),
));
if (debugDefaultTargetPlatformOverride! == TargetPlatform.android && !kIsWeb) {
expect(buttonInkWell.splashFactory, equals(InkSparkle.splashFactory));
} else {
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
}
}, variant: TargetPlatformVariant.all());
testWidgets('ElevatedButton uses InkRipple when useMaterial3 is false', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: false);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Center(
child: ElevatedButton(
onPressed: () { },
child: const Text('button'),
),
),
),
);
final InkWell buttonInkWell = tester.widget<InkWell>(find.descendant(
of: find.byType(ElevatedButton),
matching: find.byType(InkWell),
));
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
}, variant: TargetPlatformVariant.all());
testWidgets('ElevatedButton.icon does not overflow', (WidgetTester tester) async { testWidgets('ElevatedButton.icon does not overflow', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/77815 // Regression test for https://github.com/flutter/flutter/issues/77815
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// 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 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -1445,7 +1446,56 @@ void main() { ...@@ -1445,7 +1446,56 @@ void main() {
} }
}); });
testWidgets('OultinedButton.icon does not overflow', (WidgetTester tester) async { testWidgets('OutlinedButton uses InkSparkle only for Android non-web when useMaterial3 is true', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Center(
child: OutlinedButton(
onPressed: () { },
child: const Text('button'),
),
),
),
);
final InkWell buttonInkWell = tester.widget<InkWell>(find.descendant(
of: find.byType(OutlinedButton),
matching: find.byType(InkWell),
));
if (debugDefaultTargetPlatformOverride! == TargetPlatform.android && !kIsWeb) {
expect(buttonInkWell.splashFactory, equals(InkSparkle.splashFactory));
} else {
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
}
}, variant: TargetPlatformVariant.all());
testWidgets('OutlinedButton uses InkRipple when useMaterial3 is false', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: false);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Center(
child: OutlinedButton(
onPressed: () { },
child: const Text('button'),
),
),
),
);
final InkWell buttonInkWell = tester.widget<InkWell>(find.descendant(
of: find.byType(OutlinedButton),
matching: find.byType(InkWell),
));
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
}, variant: TargetPlatformVariant.all());
testWidgets('OutlinedButton.icon does not overflow', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/77815 // Regression test for https://github.com/flutter/flutter/issues/77815
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// 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 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -1238,6 +1239,55 @@ void main() { ...@@ -1238,6 +1239,55 @@ void main() {
} }
}); });
testWidgets('TextButton uses InkSparkle only for Android non-web when useMaterial3 is true', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Center(
child: TextButton(
onPressed: () { },
child: const Text('button'),
),
),
),
);
final InkWell buttonInkWell = tester.widget<InkWell>(find.descendant(
of: find.byType(TextButton),
matching: find.byType(InkWell),
));
if (debugDefaultTargetPlatformOverride! == TargetPlatform.android && !kIsWeb) {
expect(buttonInkWell.splashFactory, equals(InkSparkle.splashFactory));
} else {
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
}
}, variant: TargetPlatformVariant.all());
testWidgets('TextButton uses InkRipple when useMaterial3 is false', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: false);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Center(
child: TextButton(
onPressed: () { },
child: const Text('button'),
),
),
),
);
final InkWell buttonInkWell = tester.widget<InkWell>(find.descendant(
of: find.byType(TextButton),
matching: find.byType(InkWell),
));
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
}, variant: TargetPlatformVariant.all());
testWidgets('TextButton.icon does not overflow', (WidgetTester tester) async { testWidgets('TextButton.icon does not overflow', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/77815 // Regression test for https://github.com/flutter/flutter/issues/77815
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -333,7 +333,7 @@ void main() { ...@@ -333,7 +333,7 @@ void main() {
switch (debugDefaultTargetPlatformOverride!) { switch (debugDefaultTargetPlatformOverride!) {
case TargetPlatform.android: case TargetPlatform.android:
if (kIsWeb) { if (kIsWeb) {
expect(theme.splashFactory, equals(InkSplash.splashFactory)); expect(theme.splashFactory, equals(InkRipple.splashFactory));
} else { } else {
expect(theme.splashFactory, equals(InkSparkle.splashFactory)); expect(theme.splashFactory, equals(InkSparkle.splashFactory));
} }
...@@ -343,7 +343,7 @@ void main() { ...@@ -343,7 +343,7 @@ void main() {
case TargetPlatform.linux: case TargetPlatform.linux:
case TargetPlatform.macOS: case TargetPlatform.macOS:
case TargetPlatform.windows: case TargetPlatform.windows:
expect(theme.splashFactory, equals(InkSplash.splashFactory)); expect(theme.splashFactory, equals(InkRipple.splashFactory));
} }
}, variant: TargetPlatformVariant.all()); }, variant: TargetPlatformVariant.all());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment