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 @@ ...@@ -14,6 +14,114 @@
version: 1 version: 1
transforms: 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 # Changes made in https://github.com/flutter/flutter/pull/96957
- title: "Migrate to 'thumbVisibility'" - title: "Migrate to 'thumbVisibility'"
date: 2022-01-20 date: 2022-01-20
......
...@@ -237,19 +237,24 @@ abstract class DeletableChipAttributes { ...@@ -237,19 +237,24 @@ abstract class DeletableChipAttributes {
/// non-null. /// non-null.
Color? get deleteIconColor; 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. /// 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 /// If null, the default [MaterialLocalizations.deleteButtonTooltip] will be
/// be used. /// used.
String? get deleteButtonTooltipMessage; 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. /// An interface for material design chips that can have check marks.
...@@ -557,7 +562,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri ...@@ -557,7 +562,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
this.deleteIcon, this.deleteIcon,
this.onDeleted, this.onDeleted,
this.deleteIconColor, this.deleteIconColor,
this.useDeleteButtonTooltip = true,
this.deleteButtonTooltipMessage, this.deleteButtonTooltipMessage,
this.side, this.side,
this.shape, this.shape,
...@@ -570,11 +574,15 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri ...@@ -570,11 +574,15 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
this.materialTapTargetSize, this.materialTapTargetSize,
this.elevation, this.elevation,
this.shadowColor, this.shadowColor,
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
this.useDeleteButtonTooltip = true,
}) : assert(label != null), }) : assert(label != null),
assert(autofocus != null), assert(autofocus != null),
assert(clipBehavior != null), assert(clipBehavior != null),
assert(elevation == null || elevation >= 0.0), assert(elevation == null || elevation >= 0.0),
assert(useDeleteButtonTooltip != null),
super(key: key); super(key: key);
@override @override
...@@ -608,8 +616,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri ...@@ -608,8 +616,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
@override @override
final Color? deleteIconColor; final Color? deleteIconColor;
@override @override
final bool useDeleteButtonTooltip;
@override
final String? deleteButtonTooltipMessage; final String? deleteButtonTooltipMessage;
@override @override
final MaterialTapTargetSize? materialTapTargetSize; final MaterialTapTargetSize? materialTapTargetSize;
...@@ -617,6 +623,12 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri ...@@ -617,6 +623,12 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
final double? elevation; final double? elevation;
@override @override
final Color? shadowColor; final Color? shadowColor;
@override
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
final bool useDeleteButtonTooltip;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -721,7 +733,6 @@ class InputChip extends StatelessWidget ...@@ -721,7 +733,6 @@ class InputChip extends StatelessWidget
this.deleteIcon, this.deleteIcon,
this.onDeleted, this.onDeleted,
this.deleteIconColor, this.deleteIconColor,
this.useDeleteButtonTooltip = true,
this.deleteButtonTooltipMessage, this.deleteButtonTooltipMessage,
this.onPressed, this.onPressed,
this.pressElevation, this.pressElevation,
...@@ -743,6 +754,11 @@ class InputChip extends StatelessWidget ...@@ -743,6 +754,11 @@ class InputChip extends StatelessWidget
this.showCheckmark, this.showCheckmark,
this.checkmarkColor, this.checkmarkColor,
this.avatarBorder = const CircleBorder(), 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(selected != null),
assert(isEnabled != null), assert(isEnabled != null),
assert(label != null), assert(label != null),
...@@ -750,7 +766,6 @@ class InputChip extends StatelessWidget ...@@ -750,7 +766,6 @@ class InputChip extends StatelessWidget
assert(autofocus != null), assert(autofocus != null),
assert(pressElevation == null || pressElevation >= 0.0), assert(pressElevation == null || pressElevation >= 0.0),
assert(elevation == null || elevation >= 0.0), assert(elevation == null || elevation >= 0.0),
assert(useDeleteButtonTooltip != null),
super(key: key); super(key: key);
@override @override
...@@ -774,8 +789,6 @@ class InputChip extends StatelessWidget ...@@ -774,8 +789,6 @@ class InputChip extends StatelessWidget
@override @override
final Color? deleteIconColor; final Color? deleteIconColor;
@override @override
final bool useDeleteButtonTooltip;
@override
final String? deleteButtonTooltipMessage; final String? deleteButtonTooltipMessage;
@override @override
final VoidCallback? onPressed; final VoidCallback? onPressed;
...@@ -817,6 +830,12 @@ class InputChip extends StatelessWidget ...@@ -817,6 +830,12 @@ class InputChip extends StatelessWidget
final Color? checkmarkColor; final Color? checkmarkColor;
@override @override
final ShapeBorder avatarBorder; final ShapeBorder avatarBorder;
@override
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
final bool useDeleteButtonTooltip;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -1469,7 +1488,6 @@ class RawChip extends StatefulWidget ...@@ -1469,7 +1488,6 @@ class RawChip extends StatefulWidget
Widget? deleteIcon, Widget? deleteIcon,
this.onDeleted, this.onDeleted,
this.deleteIconColor, this.deleteIconColor,
this.useDeleteButtonTooltip = true,
this.deleteButtonTooltipMessage, this.deleteButtonTooltipMessage,
this.onPressed, this.onPressed,
this.onSelected, this.onSelected,
...@@ -1493,6 +1511,11 @@ class RawChip extends StatefulWidget ...@@ -1493,6 +1511,11 @@ class RawChip extends StatefulWidget
this.showCheckmark = true, this.showCheckmark = true,
this.checkmarkColor, this.checkmarkColor,
this.avatarBorder = const CircleBorder(), 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(label != null),
assert(isEnabled != null), assert(isEnabled != null),
assert(selected != null), assert(selected != null),
...@@ -1500,7 +1523,6 @@ class RawChip extends StatefulWidget ...@@ -1500,7 +1523,6 @@ class RawChip extends StatefulWidget
assert(autofocus != null), assert(autofocus != null),
assert(pressElevation == null || pressElevation >= 0.0), assert(pressElevation == null || pressElevation >= 0.0),
assert(elevation == null || elevation >= 0.0), assert(elevation == null || elevation >= 0.0),
assert(useDeleteButtonTooltip != null),
deleteIcon = deleteIcon ?? _kDefaultDeleteIcon, deleteIcon = deleteIcon ?? _kDefaultDeleteIcon,
super(key: key); super(key: key);
...@@ -1519,8 +1541,6 @@ class RawChip extends StatefulWidget ...@@ -1519,8 +1541,6 @@ class RawChip extends StatefulWidget
@override @override
final Color? deleteIconColor; final Color? deleteIconColor;
@override @override
final bool useDeleteButtonTooltip;
@override
final String? deleteButtonTooltipMessage; final String? deleteButtonTooltipMessage;
@override @override
final ValueChanged<bool>? onSelected; final ValueChanged<bool>? onSelected;
...@@ -1568,6 +1588,12 @@ class RawChip extends StatefulWidget ...@@ -1568,6 +1588,12 @@ class RawChip extends StatefulWidget
final Color? checkmarkColor; final Color? checkmarkColor;
@override @override
final ShapeBorder avatarBorder; 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 /// If set, this indicates that the chip should be disabled if all of the
/// tap callbacks ([onSelected], [onPressed]) are null. /// tap callbacks ([onSelected], [onPressed]) are null.
......
...@@ -200,6 +200,7 @@ Widget _chipWithOptionalDeleteButton({ ...@@ -200,6 +200,7 @@ Widget _chipWithOptionalDeleteButton({
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
bool useDeleteButtonTooltip = true, bool useDeleteButtonTooltip = true,
String? chipTooltip, String? chipTooltip,
String? deleteButtonTooltipMessage,
VoidCallback? onPressed = _doNothing, VoidCallback? onPressed = _doNothing,
}) { }) {
return _wrapForChip( return _wrapForChip(
...@@ -212,6 +213,7 @@ Widget _chipWithOptionalDeleteButton({ ...@@ -212,6 +213,7 @@ Widget _chipWithOptionalDeleteButton({
onDeleted: deletable ? _doNothing : null, onDeleted: deletable ? _doNothing : null,
deleteIcon: Icon(Icons.close, key: deleteButtonKey), deleteIcon: Icon(Icons.close, key: deleteButtonKey),
useDeleteButtonTooltip: useDeleteButtonTooltip, useDeleteButtonTooltip: useDeleteButtonTooltip,
deleteButtonTooltipMessage: deleteButtonTooltipMessage,
label: Text( label: Text(
deletable deletable
? 'Chip with Delete Button' ? 'Chip with Delete Button'
...@@ -3494,7 +3496,7 @@ void main() { ...@@ -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( await tester.pumpWidget(
_chipWithOptionalDeleteButton( _chipWithOptionalDeleteButton(
deletable: true, deletable: true,
...@@ -3519,13 +3521,38 @@ void main() { ...@@ -3519,13 +3521,38 @@ void main() {
await tapGesture.up(); 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(); final UniqueKey deleteButtonKey = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
_chipWithOptionalDeleteButton( _chipWithOptionalDeleteButton(
deleteButtonKey: deleteButtonKey, deleteButtonKey: deleteButtonKey,
deletable: true, 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', chipTooltip: 'Chip Tooltip',
), ),
); );
...@@ -3543,12 +3570,12 @@ void main() { ...@@ -3543,12 +3570,12 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// There should be no delete tooltip // There should be no delete tooltip
expect(findTooltipContainer('Delete'), findsNothing); expect(findTooltipContainer(''), findsNothing);
// There should be a chip tooltip, however. // There should be a chip tooltip, however.
expect(findTooltipContainer('Chip Tooltip'), findsOneWidget); 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(); final UniqueKey deleteButtonKey = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
_chipWithOptionalDeleteButton( _chipWithOptionalDeleteButton(
......
...@@ -530,4 +530,25 @@ void main() { ...@@ -530,4 +530,25 @@ void main() {
scrollbarTheme.isAlwaysShown; scrollbarTheme.isAlwaysShown;
RawScrollbar rawScrollbar = RawScrollbar(isAlwaysShown: true); RawScrollbar rawScrollbar = RawScrollbar(isAlwaysShown: true);
nowShowing = rawScrollbar.isAlwaysShown; 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() { ...@@ -503,4 +503,25 @@ void main() {
scrollbarTheme.thumbVisibility; scrollbarTheme.thumbVisibility;
RawScrollbar rawScrollbar = RawScrollbar(thumbVisibility: true); RawScrollbar rawScrollbar = RawScrollbar(thumbVisibility: true);
nowShowing = rawScrollbar.thumbVisibility; 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