Unverified Commit 4621dff8 authored by Anurag Roy's avatar Anurag Roy Committed by GitHub

Deprecate `useDeleteButtonTooltip` for Chips (#96174)

parent e854b8cc
......@@ -14,6 +14,114 @@
version: 1
transforms:
# Changes made in https://github.com/flutter/flutter/pull/96174
- title: "Migrate 'useDeleteButtonTooltip' to 'deleteButtonTooltipMessage'"
date: 2022-01-05
element:
uris: [ 'material.dart' ]
constructor: ''
inClass: 'Chip'
changes:
- kind: 'addParameter'
index: 9
name: 'deleteButtonTooltipMessage'
style: optional_named
argumentValue:
expression: "''"
requiredIf: "useDeleteButtonTooltip == 'false' && deleteButtonTooltipMessage == ''"
- kind: 'removeParameter'
name: 'useDeleteButtonTooltip'
variables:
useDeleteButtonTooltip:
kind: 'fragment'
value: 'arguments[useDeleteButtonTooltip]'
deleteButtonTooltipMessage:
kind: 'fragment'
value: 'arguments[deleteButtonTooltipMessage]'
# Changes made in https://github.com/flutter/flutter/pull/96174
- title: "Migrate 'useDeleteButtonTooltip' to 'deleteButtonTooltipMessage'"
date: 2022-01-05
element:
uris: [ 'material.dart' ]
constructor: ''
inClass: 'InputChip'
changes:
- kind: 'addParameter'
index: 9
name: 'deleteButtonTooltipMessage'
style: optional_named
argumentValue:
expression: "''"
requiredIf: "useDeleteButtonTooltip == 'false' && deleteButtonTooltipMessage == ''"
- kind: 'removeParameter'
name: 'useDeleteButtonTooltip'
variables:
useDeleteButtonTooltip:
kind: 'fragment'
value: 'arguments[useDeleteButtonTooltip]'
deleteButtonTooltipMessage:
kind: 'fragment'
value: 'arguments[deleteButtonTooltipMessage]'
# Changes made in https://github.com/flutter/flutter/pull/96174
- title: "Migrate 'useDeleteButtonTooltip' to 'deleteButtonTooltipMessage'"
date: 2022-01-05
element:
uris: [ 'material.dart' ]
constructor: ''
inClass: 'RawChip'
changes:
- kind: 'addParameter'
index: 9
name: 'deleteButtonTooltipMessage'
style: optional_named
argumentValue:
expression: "''"
requiredIf: "useDeleteButtonTooltip == 'false' && deleteButtonTooltipMessage == ''"
- kind: 'removeParameter'
name: 'useDeleteButtonTooltip'
variables:
useDeleteButtonTooltip:
kind: 'fragment'
value: 'arguments[useDeleteButtonTooltip]'
deleteButtonTooltipMessage:
kind: 'fragment'
value: 'arguments[deleteButtonTooltipMessage]'
# Changes made in https://github.com/flutter/flutter/pull/96174
- title: "Migrate 'useDeleteButtonTooltip' to 'deleteButtonTooltipMessage'"
date: 2022-01-05
element:
uris: [ 'material.dart' ]
field: 'useDeleteButtonTooltip'
inClass: 'Chip'
changes:
- kind: 'rename'
newName: 'deleteButtonTooltipMessage'
# Changes made in https://github.com/flutter/flutter/pull/96174
- title: "Migrate 'useDeleteButtonTooltip' to 'deleteButtonTooltipMessage'"
date: 2022-01-05
element:
uris: [ 'material.dart' ]
field: 'useDeleteButtonTooltip'
inClass: 'InputChip'
changes:
- kind: 'rename'
newName: 'deleteButtonTooltipMessage'
# Changes made in https://github.com/flutter/flutter/pull/96174
- title: "Migrate 'useDeleteButtonTooltip' to 'deleteButtonTooltipMessage'"
date: 2022-01-05
element:
uris: [ 'material.dart' ]
field: 'useDeleteButtonTooltip'
inClass: 'RawChip'
changes:
- kind: 'rename'
newName: 'deleteButtonTooltipMessage'
# Changes made in https://github.com/flutter/flutter/pull/96957
- title: "Migrate to 'thumbVisibility'"
date: 2022-01-20
......
......@@ -237,19 +237,24 @@ abstract class DeletableChipAttributes {
/// non-null.
Color? get deleteIconColor;
/// Whether to use a tooltip on the chip's delete button showing the
/// [deleteButtonTooltipMessage].
///
/// Must not be null. Defaults to true.
bool get useDeleteButtonTooltip;
/// The message to be used for the chip's delete button tooltip.
///
/// This will be shown only if [useDeleteButtonTooltip] is true.
/// If provided with an empty string, the tooltip of the delete button will be
/// disabled.
///
/// If not specified, the default [MaterialLocalizations.deleteButtonTooltip] will
/// be used.
/// If null, the default [MaterialLocalizations.deleteButtonTooltip] will be
/// used.
String? get deleteButtonTooltipMessage;
/// Whether to use a tooltip on the chip's delete button showing the
/// [deleteButtonTooltipMessage].
///
/// Defaults to true.
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
bool get useDeleteButtonTooltip;
}
/// An interface for material design chips that can have check marks.
......@@ -557,7 +562,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
this.deleteIcon,
this.onDeleted,
this.deleteIconColor,
this.useDeleteButtonTooltip = true,
this.deleteButtonTooltipMessage,
this.side,
this.shape,
......@@ -570,11 +574,15 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
this.materialTapTargetSize,
this.elevation,
this.shadowColor,
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
this.useDeleteButtonTooltip = true,
}) : assert(label != null),
assert(autofocus != null),
assert(clipBehavior != null),
assert(elevation == null || elevation >= 0.0),
assert(useDeleteButtonTooltip != null),
super(key: key);
@override
......@@ -608,8 +616,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
@override
final Color? deleteIconColor;
@override
final bool useDeleteButtonTooltip;
@override
final String? deleteButtonTooltipMessage;
@override
final MaterialTapTargetSize? materialTapTargetSize;
......@@ -617,6 +623,12 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
final double? elevation;
@override
final Color? shadowColor;
@override
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
final bool useDeleteButtonTooltip;
@override
Widget build(BuildContext context) {
......@@ -721,7 +733,6 @@ class InputChip extends StatelessWidget
this.deleteIcon,
this.onDeleted,
this.deleteIconColor,
this.useDeleteButtonTooltip = true,
this.deleteButtonTooltipMessage,
this.onPressed,
this.pressElevation,
......@@ -743,6 +754,11 @@ class InputChip extends StatelessWidget
this.showCheckmark,
this.checkmarkColor,
this.avatarBorder = const CircleBorder(),
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
this.useDeleteButtonTooltip = true,
}) : assert(selected != null),
assert(isEnabled != null),
assert(label != null),
......@@ -750,7 +766,6 @@ class InputChip extends StatelessWidget
assert(autofocus != null),
assert(pressElevation == null || pressElevation >= 0.0),
assert(elevation == null || elevation >= 0.0),
assert(useDeleteButtonTooltip != null),
super(key: key);
@override
......@@ -774,8 +789,6 @@ class InputChip extends StatelessWidget
@override
final Color? deleteIconColor;
@override
final bool useDeleteButtonTooltip;
@override
final String? deleteButtonTooltipMessage;
@override
final VoidCallback? onPressed;
......@@ -817,6 +830,12 @@ class InputChip extends StatelessWidget
final Color? checkmarkColor;
@override
final ShapeBorder avatarBorder;
@override
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
final bool useDeleteButtonTooltip;
@override
Widget build(BuildContext context) {
......@@ -1469,7 +1488,6 @@ class RawChip extends StatefulWidget
Widget? deleteIcon,
this.onDeleted,
this.deleteIconColor,
this.useDeleteButtonTooltip = true,
this.deleteButtonTooltipMessage,
this.onPressed,
this.onSelected,
......@@ -1493,6 +1511,11 @@ class RawChip extends StatefulWidget
this.showCheckmark = true,
this.checkmarkColor,
this.avatarBorder = const CircleBorder(),
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
this.useDeleteButtonTooltip = true,
}) : assert(label != null),
assert(isEnabled != null),
assert(selected != null),
......@@ -1500,7 +1523,6 @@ class RawChip extends StatefulWidget
assert(autofocus != null),
assert(pressElevation == null || pressElevation >= 0.0),
assert(elevation == null || elevation >= 0.0),
assert(useDeleteButtonTooltip != null),
deleteIcon = deleteIcon ?? _kDefaultDeleteIcon,
super(key: key);
......@@ -1519,8 +1541,6 @@ class RawChip extends StatefulWidget
@override
final Color? deleteIconColor;
@override
final bool useDeleteButtonTooltip;
@override
final String? deleteButtonTooltipMessage;
@override
final ValueChanged<bool>? onSelected;
......@@ -1568,6 +1588,12 @@ class RawChip extends StatefulWidget
final Color? checkmarkColor;
@override
final ShapeBorder avatarBorder;
@override
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
final bool useDeleteButtonTooltip;
/// If set, this indicates that the chip should be disabled if all of the
/// tap callbacks ([onSelected], [onPressed]) are null.
......
......@@ -200,6 +200,7 @@ Widget _chipWithOptionalDeleteButton({
TextDirection textDirection = TextDirection.ltr,
bool useDeleteButtonTooltip = true,
String? chipTooltip,
String? deleteButtonTooltipMessage,
VoidCallback? onPressed = _doNothing,
}) {
return _wrapForChip(
......@@ -212,6 +213,7 @@ Widget _chipWithOptionalDeleteButton({
onDeleted: deletable ? _doNothing : null,
deleteIcon: Icon(Icons.close, key: deleteButtonKey),
useDeleteButtonTooltip: useDeleteButtonTooltip,
deleteButtonTooltipMessage: deleteButtonTooltipMessage,
label: Text(
deletable
? 'Chip with Delete Button'
......@@ -3494,7 +3496,7 @@ void main() {
);
});
testWidgets('Chip delete button tooltip can be disabled', (WidgetTester tester) async {
testWidgets('Chip delete button tooltip can be disabled using useDeleteButtonTooltip', (WidgetTester tester) async {
await tester.pumpWidget(
_chipWithOptionalDeleteButton(
deletable: true,
......@@ -3519,13 +3521,38 @@ void main() {
await tapGesture.up();
});
testWidgets('useDeleteButtonTooltip only applies to tooltip', (WidgetTester tester) async {
testWidgets('Chip delete button tooltip is disabled if deleteButtonTooltipMessage is empty', (WidgetTester tester) async {
final UniqueKey deleteButtonKey = UniqueKey();
await tester.pumpWidget(
_chipWithOptionalDeleteButton(
deleteButtonKey: deleteButtonKey,
deletable: true,
useDeleteButtonTooltip: false,
deleteButtonTooltipMessage: '',
),
);
// Hover over the delete icon of the chip
final Offset centerOfDeleteButton = tester.getCenter(find.byKey(deleteButtonKey));
final TestGesture hoverGesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await hoverGesture.moveTo(centerOfDeleteButton);
addTearDown(hoverGesture.removePointer);
await tester.pump();
// Wait for some more time while hovering over the delete button
await tester.pumpAndSettle();
// There should be no delete button tooltip
expect(findTooltipContainer(''), findsNothing);
});
testWidgets('Disabling delete button tooltip does not disable chip tooltip', (WidgetTester tester) async {
final UniqueKey deleteButtonKey = UniqueKey();
await tester.pumpWidget(
_chipWithOptionalDeleteButton(
deleteButtonKey: deleteButtonKey,
deletable: true,
deleteButtonTooltipMessage: '',
chipTooltip: 'Chip Tooltip',
),
);
......@@ -3543,12 +3570,12 @@ void main() {
await tester.pumpAndSettle();
// There should be no delete tooltip
expect(findTooltipContainer('Delete'), findsNothing);
expect(findTooltipContainer(''), findsNothing);
// There should be a chip tooltip, however.
expect(findTooltipContainer('Chip Tooltip'), findsOneWidget);
});
testWidgets('Setting useDeleteButtonTooltip also allows Chip tooltip', (WidgetTester tester) async {
testWidgets('Triggering delete button tooltip does not trigger Chip tooltip', (WidgetTester tester) async {
final UniqueKey deleteButtonKey = UniqueKey();
await tester.pumpWidget(
_chipWithOptionalDeleteButton(
......
......@@ -530,4 +530,25 @@ void main() {
scrollbarTheme.isAlwaysShown;
RawScrollbar rawScrollbar = RawScrollbar(isAlwaysShown: true);
nowShowing = rawScrollbar.isAlwaysShown;
// Changes made in https://github.com/flutter/flutter/pull/96174
Chip chip = Chip();
chip = Chip(useDeleteButtonTooltip: false);
chip = Chip(useDeleteButtonTooltip: true);
chip = Chip(useDeleteButtonTooltip: false, deleteButtonTooltipMessage: 'Delete Tooltip');
chip.useDeleteButtonTooltip;
// Changes made in https://github.com/flutter/flutter/pull/96174
InputChip inputChip = InputChip();
inputChip = InputChip(useDeleteButtonTooltip: false);
inputChip = InputChip(useDeleteButtonTooltip: true);
inputChip = InputChip(useDeleteButtonTooltip: false, deleteButtonTooltipMessage: 'Delete Tooltip');
inputChip.useDeleteButtonTooltip;
// Changes made in https://github.com/flutter/flutter/pull/96174
RawChip rawChip = Rawchip();
rawChip = RawChip(useDeleteButtonTooltip: false);
rawChip = RawChip(useDeleteButtonTooltip: true);
rawChip = RawChip(useDeleteButtonTooltip: false, deleteButtonTooltipMessage: 'Delete Tooltip');
rawChip.useDeleteButtonTooltip;
}
......@@ -503,4 +503,25 @@ void main() {
scrollbarTheme.thumbVisibility;
RawScrollbar rawScrollbar = RawScrollbar(thumbVisibility: true);
nowShowing = rawScrollbar.thumbVisibility;
// Changes made in https://github.com/flutter/flutter/pull/96174
Chip chip = Chip();
chip = Chip(deleteButtonTooltipMessage: '');
chip = Chip();
chip = Chip(deleteButtonTooltipMessage: 'Delete Tooltip');
chip.deleteButtonTooltipMessage;
// Changes made in https://github.com/flutter/flutter/pull/96174
InputChip inputChip = InputChip();
inputChip = InputChip(deleteButtonTooltipMessage: '');
inputChip = InputChip();
inputChip = InputChip(deleteButtonTooltipMessage: 'Delete Tooltip');
inputChip.deleteButtonTooltipMessage;
// Changes made in https://github.com/flutter/flutter/pull/96174
RawChip rawChip = Rawchip();
rawChip = RawChip(deleteButtonTooltipMessage: '');
rawChip = RawChip();
rawChip = RawChip(deleteButtonTooltipMessage: 'Delete Tooltip');
rawChip.deleteButtonTooltipMessage;
}
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