Skip to content

Conversation

@LouiseHsu
Copy link
Contributor

This PR adds framework support for the Look Up feature in iOS.

Simulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2023-07-11.at.15.23.56.mp4

The corresponding merged engine PR can be found here.
This PR addresses #82907
More details are available in this design doc.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. a: internationalization Supporting other languages or locales. (aka i18n) f: cupertino flutter/packages/flutter/cupertino repository labels Jul 13, 2023
@LouiseHsu LouiseHsu requested a review from hellohuanlin July 18, 2023 21:56
return false;
}
return !widget.obscureText
&& !textEditingValue.selection.isCollapsed;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does collapsed mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collapsed means when the selection is empty - i.e when the selection "bars" don't contain at least one character/whitespace


/// Look Up current selection.
Future<void> lookUpSelection(SelectionChangedCause cause) async {
if (widget.obscureText) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we assert it's not obscured here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In production mode, if this somehow gets called when obscureText is true, then I guess we should do nothing and not make the platform channel call? If so then we still need this early return. Maybe an assertion and an early return both?

if (widget.obscureText) {
return;
}
final String text = textEditingValue.selection.textInside(textEditingValue.text);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to check text not empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't be able to get here if the text is empty cuz I think that would mean the selection is collapsed - but I will add a check just in case 👀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for a check. I guess someone could just directly call this when the selection is collapsed since it's public.

);

final RenderEditable renderEditable = findRenderEditable(tester);
final bool isTargetPlatformMobile = defaultTargetPlatform == TargetPlatform.iOS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isTargetPlatformIOS?

"searchTextFieldPlaceholderLabel": "సెర్చ్ చేయి",
"noSpellCheckReplacementsLabel": "No Replacements Found"
"noSpellCheckReplacementsLabel": "No Replacements Found",
"lookUpButtonLabel": "Look Up"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of these files seem to be localized properly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not entirely sure how to handle the translation. @justinmc probably knows

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I added both material and cupertino translations - is that right or do I only need one of them?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right but I always mess this up. @thkim1011 can you confirm this localization string was added correctly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string looks like it was added properly. One thing I am concerned about is that in the material localizations, "Select all" is cased with a lowercase "a" in "all" so I'm wondering if it should be "Look up" instead with a lowercase "u".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a little different because Look Up is the name of a feature in iOS, and Select all is more of a... description? What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw the native iOS behavior is upper case for both "Select All" and "Look Up". Not sure about android tho.

@LouiseHsu LouiseHsu requested a review from justinmc July 25, 2023 17:54
@github-actions github-actions bot added tool Affects the "flutter" command-line tool. See also t: labels. engine flutter/engine related. See also e: labels. a: animation Animation APIs f: scrolling Viewports, list views, slivers, etc. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: routes Navigator, Router, and related APIs. f: focus Focus traversal, gaining or losing focus c: tech-debt Technical debt, code quality, testing, etc. labels Jul 25, 2023
@LouiseHsu LouiseHsu force-pushed the louisehsu/add-lookup-to-selection-controls branch from 072404e to 766e7ab Compare July 25, 2023 23:49
@LouiseHsu LouiseHsu removed the tool Affects the "flutter" command-line tool. See also t: labels. label Jul 25, 2023
@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests tool Affects the "flutter" command-line tool. See also t: labels. engine flutter/engine related. See also e: labels. a: animation Animation APIs a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: scrolling Viewports, list views, slivers, etc. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: integration_test The flutter/packages/integration_test plugin labels Jul 27, 2023
@LouiseHsu LouiseHsu force-pushed the louisehsu/add-lookup-to-selection-controls branch from e0a2548 to c2d9cdd Compare July 27, 2023 21:38
@LouiseHsu LouiseHsu removed the request for review from christopherfujino July 27, 2023 22:04
@github-actions github-actions bot added a: desktop Running on desktop c: tech-debt Technical debt, code quality, testing, etc. labels Jul 31, 2023
@LouiseHsu LouiseHsu force-pushed the louisehsu/add-lookup-to-selection-controls branch from c13d248 to 7b87fe4 Compare July 31, 2023 23:17
@LouiseHsu LouiseHsu added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 1, 2023
auto-submit bot pushed a commit that referenced this pull request Aug 2, 2023
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](flutter/engine#43308).
This PR addresses #82907 
More details are available in this [design doc.](flutter.dev/go/add-missing-features-to-selection-controls)

This is the same PR as #130532, this is an attempt to fix the Google Testing issue
@LouiseHsu LouiseHsu closed this Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: animation Animation APIs a: desktop Running on desktop a: internationalization Supporting other languages or locales. (aka i18n) a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App c: tech-debt Technical debt, code quality, testing, etc. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos engine flutter/engine related. See also e: labels. f: cupertino flutter/packages/flutter/cupertino repository f: integration_test The flutter/packages/integration_test plugin f: material design flutter/packages/flutter/material repository. f: routes Navigator, Router, and related APIs. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants