Unverified Commit 4b678271 authored by Bruno Leroux's avatar Bruno Leroux Committed by GitHub

Add Tooltip default vertical padding (#103395)

parent 384800b5
...@@ -134,7 +134,8 @@ class Tooltip extends StatefulWidget { ...@@ -134,7 +134,8 @@ class Tooltip extends StatefulWidget {
/// The amount of space by which to inset the tooltip's [child]. /// The amount of space by which to inset the tooltip's [child].
/// ///
/// Defaults to 16.0 logical pixels in each direction. /// On mobile, defaults to 16.0 logical pixels horizontally and 4.0 vertically.
/// On desktop, defaults to 8.0 logical pixels horizontally and 4.0 vertically.
final EdgeInsetsGeometry? padding; final EdgeInsetsGeometry? padding;
/// The empty space that surrounds the tooltip. /// The empty space that surrounds the tooltip.
...@@ -403,11 +404,11 @@ class TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -403,11 +404,11 @@ class TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
case TargetPlatform.macOS: case TargetPlatform.macOS:
case TargetPlatform.linux: case TargetPlatform.linux:
case TargetPlatform.windows: case TargetPlatform.windows:
return const EdgeInsets.symmetric(horizontal: 8.0); return const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0);
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.iOS: case TargetPlatform.iOS:
return const EdgeInsets.symmetric(horizontal: 16.0); return const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0);
} }
} }
......
...@@ -801,15 +801,16 @@ void main() { ...@@ -801,15 +801,16 @@ void main() {
tooltipKey.currentState?.ensureTooltipVisible(); tooltipKey.currentState?.ensureTooltipVisible();
await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0) await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0)
final RenderBox tip = tester.renderObject( final RenderBox tip = tester.renderObject(_findTooltipContainer(tooltipText));
_findTooltipContainer(tooltipText),
);
expect(tip.size.height, equals(32.0)); expect(tip.size.height, equals(32.0));
expect(tip.size.width, equals(74.0)); expect(tip.size.width, equals(74.0));
expect(tip, paints..rrect( expect(tip, paints..rrect(
rrect: RRect.fromRectAndRadius(tip.paintBounds, const Radius.circular(4.0)), rrect: RRect.fromRectAndRadius(tip.paintBounds, const Radius.circular(4.0)),
color: const Color(0xe6616161), color: const Color(0xe6616161),
)); ));
final Container tooltipContainer = tester.firstWidget<Container>(_findTooltipContainer(tooltipText));
expect(tooltipContainer.padding, const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0));
}); });
testWidgets('Tooltip default size, shape, and color test for Desktop', (WidgetTester tester) async { testWidgets('Tooltip default size, shape, and color test for Desktop', (WidgetTester tester) async {
...@@ -830,14 +831,15 @@ void main() { ...@@ -830,14 +831,15 @@ void main() {
final RenderParagraph tooltipRenderParagraph = tester.renderObject<RenderParagraph>(find.text(tooltipText)); final RenderParagraph tooltipRenderParagraph = tester.renderObject<RenderParagraph>(find.text(tooltipText));
expect(tooltipRenderParagraph.textSize.height, equals(12.0)); expect(tooltipRenderParagraph.textSize.height, equals(12.0));
final RenderBox tooltipContainer = tester.renderObject( final RenderBox tooltipRenderBox = tester.renderObject(_findTooltipContainer(tooltipText));
_findTooltipContainer(tooltipText), expect(tooltipRenderBox.size.height, equals(24.0));
); expect(tooltipRenderBox, paints..rrect(
expect(tooltipContainer.size.height, equals(24.0)); rrect: RRect.fromRectAndRadius(tooltipRenderBox.paintBounds, const Radius.circular(4.0)),
expect(tooltipContainer, paints..rrect(
rrect: RRect.fromRectAndRadius(tooltipContainer.paintBounds, const Radius.circular(4.0)),
color: const Color(0xe6616161), color: const Color(0xe6616161),
)); ));
final Container tooltipContainer = tester.firstWidget<Container>(_findTooltipContainer(tooltipText));
expect(tooltipContainer.padding, const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0));
}, variant: const TargetPlatformVariant(<TargetPlatform>{TargetPlatform.macOS, TargetPlatform.linux, TargetPlatform.windows})); }, variant: const TargetPlatformVariant(<TargetPlatform>{TargetPlatform.macOS, TargetPlatform.linux, TargetPlatform.windows}));
testWidgets('Can tooltip decoration be customized', (WidgetTester tester) async { testWidgets('Can tooltip decoration be customized', (WidgetTester tester) async {
...@@ -1437,7 +1439,7 @@ void main() { ...@@ -1437,7 +1439,7 @@ void main() {
tip = tester.renderObject( tip = tester.renderObject(
_findTooltipContainer(tooltipText), _findTooltipContainer(tooltipText),
); );
expect(tip.size.height, equals(56.0)); expect(tip.size.height, equals(64.0));
}); });
testWidgets('Tooltip text displays with richMessage', (WidgetTester tester) async { testWidgets('Tooltip text displays with richMessage', (WidgetTester tester) async {
......
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