252 Commits

Author SHA1 Message Date
LouiseHsu
d9cb50e63d
[framework] Add Search Web to selection controls for iOS (#131898)
This PR adds framework support for the Search Web feature in iOS. 

https://github.com/flutter/flutter/assets/36148254/c159f0d9-8f14-45e7-b295-e065b0826fab

The corresponding merged engine PR can be found [here](https://github.com/flutter/engine/pull/43324).
This PR addresses https://github.com/flutter/flutter/issues/82907 
More details are available in this [design doc](https://docs.google.com/document/d/1QizXwBiO-2REIcEovl5pK06BaLPOWYmNwOE5jactJZA/edit?resourcekey=0-1pb9mJiAq29Gesmt25GAug)
2023-08-08 17:34:17 +00:00
Kate Lovett
f054f5aa09
Move mock canvas to flutter_test (#131631)
Fixes https://github.com/flutter/flutter/issues/59413

This relocates `mock_canvas.dart` and `recording_canvas.dart` from `flutter/test/rendering` to `flutter_test`. 

The testing functionality afforded by mock_canvas should be available to everyone, not just the framework. :)

mock_canvas.dart needed a bit of cleanup - things like formatting and super parameters.
2023-08-07 23:43:03 +00:00
LouiseHsu
f019789565
[framework] Add Look Up to selection controls for iOS (#131798)
This PR adds framework support for the Look Up feature in iOS. 

https://github.com/flutter/flutter/assets/36148254/d301df79-4e23-454f-8742-2f8e39c2960c

The corresponding merged engine PR can be found [here](https://github.com/flutter/engine/pull/43308).
This PR addresses https://github.com/flutter/flutter/issues/82907 
More details are available in this [design doc.](flutter.dev/go/add-missing-features-to-selection-controls)

This is the same PR as https://github.com/flutter/flutter/pull/130532, this is an attempt to fix the Google Testing issue
2023-08-02 20:20:39 +00:00
luckysmg
e0ad12969f
[framework] Add textField OCR support for framework side (#96637)
iOS OCR keyboard input support.
2023-07-06 08:51:06 -07:00
Luccas Clezar
a90c33fd61
iOS TextSelectionToolbar fidelity (#127757)
CupertinoTextSelectionToolbar is different from the native one, with some UI and UX issues. More details on the linked issue.

https://github.com/flutter/flutter/issues/127756

Currently the only problem that I listed on the linked issue that I couldn't fix was the horizontal scrolling, but to workaround this I added a GestureDetector to change pages when swiping the toolbar. It's not exactly the same as native as there is no scroll animation, but it works.

I'm creating this PR a little early to have some feedback as these changes were more complex than the ones in my last PR. Probably best if @justinmc is involved 😅

|Version|Video|
|-|-|
|Flutter Old|<video src="https://github.com/flutter/flutter/assets/12024080/7cf81075-46ec-4970-b118-cc27b60ddac0"></video>|
|Flutter New|<video src="https://github.com/flutter/flutter/assets/12024080/c9e27a53-f94c-4cb0-9b76-e47b73841dcb"></video>|
|Native|<video src="https://github.com/flutter/flutter/assets/12024080/468c7d5b-ba93-4bd4-8f6e-8ec2644b9866"></video>|
2023-06-27 17:50:07 +00:00
Tomasz Gucio
99c7e9f088
Add spaces after flow control statements (#126320) 2023-05-15 11:07:30 +02:00
Justin McCandless
6ffcc9e55a
Hide the context menu on tap down (#126295)
Desktop text selection toolbar no longer flashes before closing.
2023-05-12 10:04:27 -07:00
Renzo Olivares
1a51dc2131
Fix iOS touch drag behavior (#125169)
Before this change on a quick touch drag the cursor, where the touch is not on the previous collapsed selection, the cursor would move to the tapped position.

After this change on a quick touch drag the cursor does not move unless the touch is on the previously collapsed selection. This is inline with native behavior.

Before|After|Native
--|--|--
<video src="https://user-images.githubusercontent.com/948037/233224775-f33b42b5-5638-416c-9278-39ecd964e3bb.mov" />|<video src="https://user-images.githubusercontent.com/948037/233224760-2d1af657-8d99-45fc-8499-9567f17d533e.mov" />|<video src="https://user-images.githubusercontent.com/948037/233224790-f5997cfa-7370-4891-8952-11ef8057a729.mov" />
2023-04-24 19:25:21 +00:00
chunhtai
8a815c1d1d
Remove unecessary reference to ClipboardStatusNotifier (#125255)
fixes https://github.com/flutter/flutter/issues/99360
2023-04-21 22:38:06 +00:00
Justin McCandless
8784eb1d8e
Red spell check selection on iOS (#125162)
iOS now hides the selection handles and shows red selection when tapping a misspelled word, like native.
2023-04-21 09:15:08 -07:00
Renzo Olivares
01b4dd5eee
Toolbar should re-appear on drag end (#125165)
#125151 introduced the magnifier on touch drag gestures, but when showing the magnifier the toolbar is implicitly hidden, this change makes the toolbar re-appear on drag end for double tap + drag.
2023-04-20 22:34:35 +00:00
Renzo Olivares
8ed26d8b8e
Show magnifier on touch drag gestures (#125151)
This change shows the magnifier on touch drag gestures for Android and iOS and hides it when the drag ends.

Fixes #118268
2023-04-20 04:49:05 +00:00
chunhtai
9884b5f55e
Fixes IgnorePointer and AbsorbPointer to only block user interactions… (#120619)
Fixes IgnorePointer and AbsorbPointer to only block user interactions…
2023-04-07 15:51:05 +00:00
Renzo Olivares
90f8ac5b41
TapAndDragGestureRecognizer should declare victory immediately when drag is detected (#123055)
TapAndDragGestureRecognizer should declare victory immediately when drag is detected
2023-04-05 23:00:52 +00:00
Renzo Olivares
142dd6022f
Match iOS Longpress behavior with native (#123630)
Match iOS Longpress behavior with native
2023-03-29 20:22:03 +00:00
Renzo Olivares
04f6acd881
Add TextField triple tap/click gestures (#119046)
Add TextField triple tap/click gestures
2023-03-27 22:39:52 +00:00
Benjamin Quinn
5ef9b847aa
Expose toggle to textfield's opacity animation. (#122474)
Expose toggle to textfield's opacity animation.
2023-03-23 19:49:58 +00:00
Michael Goderbauer
fda9ecfef7
Remove 1745 decorative breaks (#123259)
Remove 1745 decorative breaks
2023-03-22 21:12:22 +00:00
pdblasi-google
baaa43c69a
Reland: Updates flutter/test/cupertino to no longer use TestWindow (#122620)
Reland: Updates `flutter/test/cupertino` to no longer use `TestWindow`
2023-03-14 19:45:47 +00:00
LongCatIsLooong
1306d7f158
Fix Caret Height On Empty Lines (#120834)
* improve caret caching, fix caret for empty text/line, `getLocalRectForCaret` now reports the real rect that will be painted.
move caret x-coordinate clamping to RenderEditable since TextPainter doesn't know about clipping.

* comments

* review
2023-03-13 15:37:42 -07:00
Casey Hillers
1f42612323
Revert PRs relating to single window assumption (#122369)
* Revert "Remove references to BindingBase.window (#122119)"

This reverts commit c7681f00cf1fb1c63bebb27d715f29feb77b78b7.

* Revert "Remove another reference to BindingBase.window (#122341)"

This reverts commit 6ec444506375cfa94535a45c2320e01094c295e0.

* Revert "Reland (2): Removes single window assumptions from `flutter_test` (#122233)"

This reverts commit eb3d317ea06e59fadc379210f5c6e685505d8e0f.

* Revert "Remove single view assumption from TestViewConfiguration (#122352)"

This reverts commit 927289fb4e5b25a71f794bc808a8c31554859a50.

* Revert "Updates `flutter/test/cupertino` to no longer use `TestWindow` (#122325)"

This reverts commit 67e17e45f05271c6c409183c1d33806683cb9e4d.

* Revert "Updates `flutter/test/gestures` to no longer reference `TestWindow` (#122327)"

This reverts commit c2a5111cc0f9bcb104982b38a1a0a9c4210b601f.

* Revert "Updates `flutter/test/rendering` to no longer use `TestWindow` (#122347)"

This reverts commit 28b65e089b3f8e8c21572cd8a73184858b6360c3.

* Revert "Updates `flutter_localizations/test` to stop using `TestWindow` (#122321)"

This reverts commit 01367d52d7886f51a8921c9dc4a8e4c541686e98.
2023-03-09 22:53:38 -08:00
pdblasi-google
67e17e45f0
Updates flutter/test/cupertino to no longer use TestWindow (#122325)
Updates `flutter/test/cupertino` to no longer use `TestWindow`
2023-03-09 22:21:31 +00:00
LongCatIsLooong
f4551e6450
Reland "Update test font (#121306)" (#122068)
Reland "Update test font (#121306)"
2023-03-09 19:05:32 +00:00
LongCatIsLooong
33ffdd704f
Revert "Update test font (#121306)" (#122053)
This reverts commit 9f69a3679bc441d3ff985362e47b80ee2a51c60f.
2023-03-06 14:15:58 -08:00
LongCatIsLooong
9f69a3679b
Update test font (#121306)
Update test font
2023-03-06 21:46:51 +00:00
takashi kasai
909e29edc5
moving the left handle automatically scrolls EditableText to the right handle, which doesn't happen on native (#105836)
Fixes a scrolling issue when dragging selection handles.
2023-03-01 11:52:27 -08:00
Lioness100
26b6c1bedd
Fix typos (#121171)
* Fix typos

* lowercase animated & opacity

* Undo typo fix

---------

Co-authored-by: Michael Goderbauer <goderbauer@google.com>
2023-02-23 19:43:21 +00:00
Ian Hickson
07c548c698
Apply BindingBase.checkInstance to TestDefaultBinaryMessengerBinding (#116937) 2023-02-13 23:55:58 +00:00
Michael Goderbauer
b0f1714b7b
Make Flex,Row,Column const for real (#119673)
* Make Flex,Row,Column const for real

* dart fix --apply

* fix snippets

* fix integration test

* add comment
2023-02-02 19:33:57 +00:00
Renzo Olivares
9080d1acc5
Reland "Add support for double tap and drag for text selection #109573" (#117502)
* Revert "Revert "Add support for double tap and drag for text selection (#109573)" (#117497)"

This reverts commit 39fa0117a919bd401c4c8734c97ddb46fbc45cb7.

* Allow TapAndDragGestureRecognizer to accept pointer events from any devices -- the TapGestureRecognizer it replaces was previously doing this

Co-authored-by: Renzo Olivares <roliv@google.com>
2023-01-04 00:54:10 +00:00
Justin McCandless
6781576e80
Reland iOS 16 context menu (#117234)
Updates the iOS text selection toolbar to look like iOS 16 (reland)
2022-12-22 15:55:28 -08:00
Renzo Olivares
39fa0117a9
Revert "Add support for double tap and drag for text selection (#109573)" (#117497)
This reverts commit cd0f15a770992ec41445bd212aac73572c278fd1.

Co-authored-by: Renzo Olivares <roliv@google.com>
2022-12-21 23:29:07 +00:00
Renzo Olivares
cd0f15a770
Add support for double tap and drag for text selection (#109573)
* Replace PanGestureRecognizer in TextSelection with TapAndDragGestureRecognizer

* add tracking of _DragState to new tap_and_drag recognizer and remove some legacy double tap code from text_selection.dart and add logs"

* add dragTapCount, a tap count that is persistent for an entire drag and is set to null on drag end vs the regular tap count which is reset on a timer

* basic double tap to drag functionality and add a local dragTapCount in text_selection.dart to use with the timer callback

* Add offsetFromOrigin and localOffsetFromOrigin to DragUpdateDetails similar to LongPressMoveUpdateDetails, eliminates the need to hold the state of lastDragStartDetails

* make a generic baselongpressgesturerecognizer

* Revert "make a generic baselongpressgesturerecognizer"

This reverts commit aad8f7433bd01e4cd016d527af832c3b1f15fac5.

* rename tap_and_drag to selection_recognizers

* add mixin for consecutivetap

* tap and long press gesture recognizer

* Revert "Revert "make a generic baselongpressgesturerecognizer""

This reverts commit 181350c36718f644eada3e45c1b7b5939f90a340.

* Revert "Revert "Revert "make a generic baselongpressgesturerecognizer"""

This reverts commit 4d69775967858dfd66dd9429e1713da598908a85.

* Add support for secondary button clicks on drag gesture recognizer and separate drag end and tap up callback

* get test running

* rename tapCount to consecutiveTapCount

* dispose timer properly

* add some comments to tests

* Add comments

* Make ConsecutiveTapMixin private and move logic to increment tap count into mixin

* stop tracking pointer when gesture is rejected and detect drags on touch devices

* onCancel for TapAndDrag

* have the TapAndDragGestureRecognizer handle tap downs and tap ups on touch and mouse devices

* add drag to move cursor for android and iOS, and pointer device kind to DragUpdateDetails

* get tests running

* refactor TapAndDragGestureRecognizer moving some logic into _check methods

* Handle cancel properly on TapAndDragGestureRecognizer, having both onTapCancel and onDragCancel, also fix tests

* Fix test mouse drag selects and cannot drag cursor, save _initialPosition based on dragStartBehavior (either on tapDown or dragStart)

* determine if drag has a sufficient global distance to accept and fix some cancel behavior, making _checkCancel clearer

* give up pointer on drag end

* properly stop tracking pointer, fixes test for right click on Apple and non-apple platforms

* clean up some comments from last commit

* remove drag on touch for now

* fix Can select text by dragging with a mouse due to dragStart only being fired on the first PointerMoveEvent, the previous pan gesture recognizer would fire both dragStart and dragUpdate

* Revert "fix Can select text by dragging with a mouse due to dragStart only being fired on the first PointerMoveEvent, the previous pan gesture recognizer would fire both dragStart and dragUpdate"

This reverts commit 124dc79bc3389672c76d7c014ce04edab297abc6.

* correctly use _initialPosition for checkStart and call _checkUpdate after _checkStart if localDelta is not zero

* updates

* fix double tap chains

* Add docs

* Address analyzer

* more analyzer, only issues left are with print statements

* add deadlineTimer to fix conflict with ForcePressGestureRecognizer

* Revert "add deadlineTimer to fix conflict with ForcePressGestureRecognizer"

This reverts commit 3b29ddfff4cde4845edd481ecefb789fea2a0781.

* remove unecessary changes to tests

* secondaryButton should not drag

* Revert "Revert "add deadlineTimer to fix conflict with ForcePressGestureRecognizer""

This reverts commit 0a008f029f5796acd48c17c1897c0b700d5ef3a7.

* updates

* Revert "updates"

This reverts commit 4803b8443a2b67f0b8d29e9a01f712dfcb0f588c.

* Revert "Revert "Revert "add deadlineTimer to fix conflict with ForcePressGestureRecognizer"""

This reverts commit 79251a7af88d5dbb1460a960afc77e65dea18bff.

* fix shift + tap + drag tests, this was happening because a double tap + drag was being registered and not a single tap, added a duration to pumpAndSettle to fix this

* remove TapAndLongPressGestureRecognizer

* fix cupertino text field tests related to shift + tap + drag

* deadline timer try 2

* more logs

* Should reset taps when tap cancel is called, and should wait until gesture is accepted to initiate a drag

* should clear _down and _up when gesture is rejected

* remove erroneous log

* fix selectable text double tap chains test

* dont restart timer until tap up

* reset consecutiveTapCount on drag end

* fix selectableText test

* fix material text field tests

* reject TapAndDragGestureRecognizer when it is neither a tap nor a drag

* remove prints

* clean up

* shift aware

* clean up

* fix cupertino test

* fix text field focus tests

* Add 100ms delay to cupertino test, to prevent a double tap

* clean up test comments

* add comment to test

* uncomment test

* remove longpress changes

* Fix drag on mobile

* remove debug

* Fix drag to move cursor on iOS

* left over from drag fix

* add tests for drag on touch devices

* add test for double tap + drag mouse devices

* add tests

* Fix bug where initialPosition was used before it was set

* Address some review comments and fix issue where if double tap was held too long then long press gesture recognizer would take over

* remove _isDoubleTap flag since it is no longer needed due to previous commit

* Add docs for onTapCancel and onDragCancel

* analyzer fixes

* Do not test selection handles on macOS, since macOS does not support touch

* Add assert for dragStartBehavior

* add double tap + drag tests to cupertino

* use kDoubleTapTimeout instead of const Duration(milliseconds: 300) for readability

* analyzer issues

* update docs

* update more docs

* address comments

* more doc updates

* fix docs

* unused import

* fix docs

* Add more tests

* Add more tests and reject a tap up if we have exceeded the tap tolerance

* updates

* Address comments

* fix test naming

* update documentation

* move selection_recognizers to selection_gestures

* fix analyzer

* fix analyzer

* keysPressedOnDown instead of isShiftPressed

* update docs

* update docs

* Add drag update throttle to TapAndDragGestureRecognizer

* update comments

* missed from merge

* Replace _ConsecutiveTapMixin with _TapStatusTrackerMixin

* updates

* correctly cancel tap when when past tap tolerance with new implementation

* Should call tap and drag cancel if we are giving up a pointer without succesfully tracking a PointerUpEvent

* comments

* move pastTapTolerance to tap tracker

* move pastTapTolerance to tap tracker

* clean up check for nulls and remove use of consecutiveTapCountWhileDragging

* move call to super.acceptGesture to top

* remove print

* clean up

* Fix tests where both PanGestureRecognizer and TapAndDragGestureRecognizer lost

* clean up

* _GestureState -> _DragState

* more docs clean up

* more clean up

* Add onSecondaryTapCancel

* Add docs

* more docs

* Fix broken isPointerAllowed when attempting a right click drag - the _initialButtons is never reset

* revert debug flag

* make primaryPointer private

* Add support for upper count limit in TapAndDragGestureRecognizer, the tap counter should not be allowed to grow infinitely unless that is desired

* fix analyzer

* Use new TapDrag details objects and callbacks

* clean up docs

* clean up and add test for upperLimit

* Add docs for TapAndDragGestureRecognizer and remove some ambiguity of onStart onUpdate and onEnd parameters

* Address review comments

* analyzer fixes

* Call cancel before rejecting the gesture so we can still access _initialButtons

* Recognizer should reject any pointer differing from the original

* Revert "Recognizer should reject any pointer differing from the original"

This reverts commit afd9807480bd11e119bdd2b7d520631511973bab.

* Address reviewer comments

* Correct cancel behavior

* Fix consecutive tap + drag because _dragStart state was not being set when consecutive tap is greater than one

* Add more tests

* Add documentation on behavior with TapGestureRecognizer and DragGestureRecognizer

* more docs

* more docs

* remove comments

* updates

* fix multiple pointer behavior

* only handle the primary pointer

* Clean up dangerous assumptions in gesture details objects

* forgot from rebase

* update docs

* updates

* Clean up some redundant code

* remove whitespace

* fix tests as a result of #115849

* update test docs

* Fix same test from last commit for material variants

* More clean up of redundant code and update docs

* Clean up didStopTrackingLastPointer and untie TapAndDragGestureRecognizer cancel behavior from TapStatusTrackerMixin.currentUp state

* untie pastTapTolerance

* updates

* Add slopTolerance

* update docs

* Have secondary tap handled by TapGestureRecognizer

* update docs

* fix analyzer and address comments

* Add more docs

* Update cancel behavior tol not call on tap cancel when a drag has been accepted

* Change cancel behavior to only cancel if the tap down callback has been sent and merge tapcancel and dragcancel

* update docs;

* Rename selection_gestures to tap_and_drag_gestures

* Address some reviewer comments

* make deadline and slopTolerance private

* updates

* updates

* Address review comments

* remove _initialButtons

* fix docs

* trackTrap -> trackTap

* fix analyzer

* Add test to verify that tap up is called when recognizer accepts before handleEvent is called

* implement Diagnosticable for Details objects;

* sentTapDown == wonArenaForPrimaryPointer, so the implementation now only uses sentTapDown

* Count user tap up immediately and do not wait to win the arena

* Do not need to call super from TapAndDragGestureRecognizer.acceptGesture anymore because mixin implementation is gone

* Do not start selection drag on Android, iOS, and Fuchshsia touch devices if renderEditable does not have focus, this fixes many scubas

* Address reviewer comments

* fix test

* TapAndDragGestureRecognizer should wait for other recognizer to lose before winning the arena

* Address review comments

* Dont check for drag if the start was already found

* Only check for a drag if it has not already been found"

* fix from rebase

Co-authored-by: Renzo Olivares <roliv@google.com>
2022-12-21 01:01:04 +00:00
Michael Goderbauer
b308555ed1
Enable dangling_library_doc_comments and library_annotations lints (#117365) 2022-12-20 16:03:21 -08:00
Justin McCandless
014b441ddf
Revert "iOS 16 context menu (#115805)" (#116312)
This reverts commit 1cb16a1e396fdfaedae0bb291aae562fa88d1d81.
2022-12-01 02:24:18 +00:00
Justin McCandless
1cb16a1e39
iOS 16 context menu (#115805)
Updates the text selection toolbar on iOS light mode to match changes in native iOS 16.
2022-11-29 14:00:04 -08:00
Mitchell Goodwin
b22ab5117f
Reland Cupertino text input padding (#115164)
* Update Cupertino text input padding

* Remove comment

* Update tests
2022-11-28 14:12:49 -07:00
chunhtai
224fae5063
Fix iOS selectWordEdge doesn't account for affinity (#115849)
* Fix iOS selectWordEdge doesn't account for affinity

* fix test

* update
2022-11-28 17:32:17 +00:00
陈昱
497a52809d
Fix TextField/CupertinoTextField hint style overflow not work. (#114335)
* fix text field hint style overflow not work, keep default ellipsis.

* fix cupertino text field hint style overflow not work, keep default ellipsis.

* add Cupertino placeholder style test.
2022-11-07 17:45:56 +00:00
Justin McCandless
93b0042559
Handle dragging improvements (#114042)
Improves the feel of dragging text selection vertically between lines on mobile.
2022-11-01 12:36:51 -07:00
Justin McCandless
0b451b6dfd
Context Menus (#107193)
* Can show context menus anywhere in the app, not just on text.
* Unifies all desktop/mobile context menus to go through one class (ContextMenuController).
* All context menus are now just plain widgets that can be fully customized.
* Existing default context menus can be customized and reused.
2022-10-28 12:40:09 -07:00
Zachary Anderson
e334ac1122
Revert "Update Cupertino text input padding (#113958)" (#114102)
This reverts commit 51acda81f289ddaea04ea9f8b587dc20f1479764.
2022-10-26 12:59:05 -07:00
Mitchell Goodwin
51acda81f2
Update Cupertino text input padding (#113958)
* Update Cupertino text input padding

* Remove comment
2022-10-26 11:49:26 -07:00
陈昱
b375b4ac87
Fix an issue that Dragging the iOS text selection handles is jumpy and iOS text selection update incorrectly. (#109136)
Better text selection handle dragging experience on iOS.
2022-10-25 08:58:53 -07:00
Renzo Olivares
3c2f500b1b
Fix edge scrolling on platforms that select word by word on long press move (#113128) 2022-10-24 21:14:54 +00:00
Renzo Olivares
4abe6fdafa
Reland "Single tap on the previous selection should toggle the toolbar on iOS #108913" (#111995) 2022-10-17 20:07:21 +00:00
LongCatIsLooong
78e94155a0
[RenderEditable] report real height when maxLines == 1. (#112029) 2022-09-28 21:40:47 +00:00
Anthony Oleinik
4ceeca0833
Added example for Magnifier and TextMagnifier (#110218) 2022-09-23 20:29:32 +00:00
chunhtai
bcc1dc6b99
Makes TextBoundary and its subclasses public (#110367) 2022-09-16 22:05:04 +00:00
godofredoc
61db3bc8c5
Revert "Single tap on the previous selection should toggle the toolbar on iOS…" (#111662) 2022-09-15 16:44:17 +00:00