From 586a59211df425b8a1f9b6be1b02662bf88ddc0b Mon Sep 17 00:00:00 2001 From: Tirth Date: Sat, 25 Jan 2025 11:20:26 +0530 Subject: [PATCH] Rename 'SelectionChangedCause.scribble' to 'SelectionChangedCause.stylusHandwriting' (#161518) Rename 'SelectionChangedCause.scribble' to 'SelectionChangedCause.stylusHandwriting' Fixes #159223 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --- packages/flutter/lib/fix_data/fix_services.yaml | 14 ++++++++++++++ packages/flutter/lib/src/cupertino/text_field.dart | 2 +- packages/flutter/lib/src/material/text_field.dart | 3 ++- packages/flutter/lib/src/services/text_input.dart | 14 +++++++++++--- .../flutter/lib/src/widgets/editable_text.dart | 6 +++--- .../flutter/lib/src/widgets/text_selection.dart | 2 +- .../test/widgets/editable_text_scribble_test.dart | 6 +++--- packages/flutter/test_fixes/services/services.dart | 3 +++ .../test_fixes/services/services.dart.expect | 3 +++ 9 files changed, 41 insertions(+), 12 deletions(-) diff --git a/packages/flutter/lib/fix_data/fix_services.yaml b/packages/flutter/lib/fix_data/fix_services.yaml index b029bfa55b..8c3e6735e1 100644 --- a/packages/flutter/lib/fix_data/fix_services.yaml +++ b/packages/flutter/lib/fix_data/fix_services.yaml @@ -84,4 +84,18 @@ transforms: kind: 'fragment' value: 'arguments[0]' + # Changes made in https://github.com/flutter/flutter/pull/161518 + - title: "Migrate 'SelectionChangedCause.scribble' to 'SelectionChangedCause.stylusHandwriting'" + date: 2025-01-13 + element: + uris: [ 'services.dart' ] + constant: 'scribble' + inEnum: 'SelectionChangedCause' + changes: + - kind: 'replacedBy' + newElement: + uris: [ 'services.dart' ] + constant: 'stylusHandwriting' + inEnum: 'SelectionChangedCause' + # Before adding a new fix: read instructions at the top of this file. diff --git a/packages/flutter/lib/src/cupertino/text_field.dart b/packages/flutter/lib/src/cupertino/text_field.dart index b48e4ba413..0abad2588d 100644 --- a/packages/flutter/lib/src/cupertino/text_field.dart +++ b/packages/flutter/lib/src/cupertino/text_field.dart @@ -1191,7 +1191,7 @@ class _CupertinoTextFieldState extends State return false; } - if (cause == SelectionChangedCause.scribble) { + if (cause == SelectionChangedCause.stylusHandwriting) { return true; } diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index d03d479103..70db04ae2c 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -1341,7 +1341,8 @@ class _TextFieldState extends State return false; } - if (cause == SelectionChangedCause.longPress || cause == SelectionChangedCause.scribble) { + if (cause == SelectionChangedCause.longPress || + cause == SelectionChangedCause.stylusHandwriting) { return true; } diff --git a/packages/flutter/lib/src/services/text_input.dart b/packages/flutter/lib/src/services/text_input.dart index 7e5a38c59a..01da51f85e 100644 --- a/packages/flutter/lib/src/services/text_input.dart +++ b/packages/flutter/lib/src/services/text_input.dart @@ -1097,13 +1097,21 @@ enum SelectionChangedCause { /// of text. drag, - // TODO(justinmc): Rename this to stylusHandwriting. - // https://github.com/flutter/flutter/issues/159223 /// The user used stylus handwriting to change the selection. /// /// Currently, this is only supported on iPadOS 14+ via the Scribble feature, /// or on Android API 34+ via the Scribe feature. - scribble, + stylusHandwriting; + + /// The user used stylus handwriting to change the selection. + /// + /// Currently, this is only supported on iPadOS 14+ via the Scribble feature, + /// or on Android API 34+ via the Scribe feature. + @Deprecated( + 'Use stylusHandwriting instead. ' + 'This feature was deprecated after v3.28.0-0.1.pre.', + ) + static const SelectionChangedCause scribble = stylusHandwriting; } /// A mixin for manipulating the selection, provided for toolbar or shortcut diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index aa99784d69..56df83a96c 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -3383,7 +3383,7 @@ class EditableTextState extends State // `selection` is the only change. SelectionChangedCause cause; if (_textInputConnection?.scribbleInProgress ?? false) { - cause = SelectionChangedCause.scribble; + cause = SelectionChangedCause.stylusHandwriting; } else if (_pointOffsetOrigin != null) { // For floating cursor selection when force pressing the space bar. cause = SelectionChangedCause.forcePress; @@ -4178,7 +4178,7 @@ class EditableTextState extends State case SelectionChangedCause.drag: case SelectionChangedCause.forcePress: case SelectionChangedCause.longPress: - case SelectionChangedCause.scribble: + case SelectionChangedCause.stylusHandwriting: case SelectionChangedCause.tap: case SelectionChangedCause.toolbar: requestKeyboard(); @@ -6025,7 +6025,7 @@ class _ScribbleFocusableState extends State<_ScribbleFocusable> implements Scrib @override void onScribbleFocus(Offset offset) { widget.focusNode.requestFocus(); - renderEditable?.selectPositionAt(from: offset, cause: SelectionChangedCause.scribble); + renderEditable?.selectPositionAt(from: offset, cause: SelectionChangedCause.stylusHandwriting); widget.updateSelectionRects(); } diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart index dfd7b230d3..db1bb2da6e 100644 --- a/packages/flutter/lib/src/widgets/text_selection.dart +++ b/packages/flutter/lib/src/widgets/text_selection.dart @@ -2317,7 +2317,7 @@ class TextSelectionGestureDetectorBuilder { if (stylusEnabled) { Scribe.isFeatureAvailable().then((bool isAvailable) { if (isAvailable) { - renderEditable.selectPosition(cause: SelectionChangedCause.scribble); + renderEditable.selectPosition(cause: SelectionChangedCause.stylusHandwriting); Scribe.startStylusHandwriting(); } }); diff --git a/packages/flutter/test/widgets/editable_text_scribble_test.dart b/packages/flutter/test/widgets/editable_text_scribble_test.dart index 6b4dd3b1f0..0cf275aa7c 100644 --- a/packages/flutter/test/widgets/editable_text_scribble_test.dart +++ b/packages/flutter/test/widgets/editable_text_scribble_test.dart @@ -173,7 +173,7 @@ void main() { ); await tester.pumpAndSettle(); - expect(selectionCause, SelectionChangedCause.scribble); + expect(selectionCause, SelectionChangedCause.stylusHandwriting); await tester.testTextInput.finishScribbleInteraction(); }, @@ -210,10 +210,10 @@ void main() { ); expect(focusNode.hasFocus, true); - expect(selectionCause, SelectionChangedCause.scribble); + expect(selectionCause, SelectionChangedCause.stylusHandwriting); // On web, we should rely on the browser's implementation of Scribble, so the selection changed cause - // will never be SelectionChangedCause.scribble. + // will never be SelectionChangedCause.stylusHandwriting. }, skip: kIsWeb, // [intended] variant: const TargetPlatformVariant({TargetPlatform.iOS}), diff --git a/packages/flutter/test_fixes/services/services.dart b/packages/flutter/test_fixes/services/services.dart index fe96f3f55d..341177dc0d 100644 --- a/packages/flutter/test_fixes/services/services.dart +++ b/packages/flutter/test_fixes/services/services.dart @@ -42,4 +42,7 @@ void main() { ]); await SystemChrome.setEnabledSystemUIOverlays([]); await SystemChrome.setEnabledSystemUIOverlays(error: ''); + + // Changes made in https://github.com/flutter/flutter/pull/161518 + const CopySelectionTextIntent.cut(SelectionChangedCause.scribble); } diff --git a/packages/flutter/test_fixes/services/services.dart.expect b/packages/flutter/test_fixes/services/services.dart.expect index 70d003c069..627e007d3a 100644 --- a/packages/flutter/test_fixes/services/services.dart.expect +++ b/packages/flutter/test_fixes/services/services.dart.expect @@ -42,4 +42,7 @@ void main() { ]); await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, error: ''); + + // Changes made in https://github.com/flutter/flutter/pull/161518 + const CopySelectionTextIntent.cut(SelectionChangedCause.stylusHandwriting); }