Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recreate Renzo-Olivares's simplistic_editor fix #1996

Merged
merged 4 commits into from
Nov 11, 2023

Conversation

domesticmouse
Copy link
Contributor

@domesticmouse domesticmouse commented Aug 30, 2023

Replaces #1979

Pre-launch Checklist

  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I read the Contributors Guide.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-devrel channel on Discord.

@domesticmouse
Copy link
Contributor Author

@Renzo-Olivares please check that I have recreated #1979 faithfully. Thanks!

Copy link
Contributor

@Renzo-Olivares Renzo-Olivares left a comment

Choose a reason for hiding this comment

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

LGTM thanks for taking care of this!

@domesticmouse
Copy link
Contributor Author

@Renzo-Olivares Can the onShare and onSearchWeb be null handlers? Or do we need something more complete?

@Renzo-Olivares
Copy link
Contributor

From my knowledge onShare and onSearchWeb aren't available in stable yet. Should we still add them here?

@domesticmouse
Copy link
Contributor Author

From my knowledge onShare and onSearchWeb aren't available in stable yet. Should we still add them here?

I'm setting this PR up as a patch to land when the Q4 stable release happens.

Assuming onShare and onSearchWeb are slated to release in the Q4 stable then yup, we should add them to this PR.

@Renzo-Olivares
Copy link
Contributor

Renzo-Olivares commented Sep 1, 2023

In that case then onShare and onSearchWeb should have more complete implementations. Something along these lines. This is taken straight from editable_text.dart in the framework. These default implementations should probably be made more re-usable.

  @override
  bool get searchWebEnabled {
    if (defaultTargetPlatform != TargetPlatform.iOS) {
      return false;
    }

    return !textEditingValue.selection.isCollapsed
        && textEditingValue.selection.textInside(textEditingValue.text).trim() != '';
  }

  @override
  bool get shareEnabled {
    if (defaultTargetPlatform != TargetPlatform.iOS) {
      return false;
    }

    return !textEditingValue.selection.isCollapsed
        && textEditingValue.selection.textInside(textEditingValue.text).trim() != '';
  }

  /// Launch a web search on the current selection,
  /// as in the "Search Web" edit menu button on iOS.
  ///
  /// Currently this is only implemented for iOS.
  Future<void> _searchWebForSelection(SelectionChangedCause cause) async {
    final String text = textEditingValue.selection.textInside(textEditingValue.text);
    if (text.isNotEmpty) {
      await SystemChannels.platform.invokeMethod(
        'SearchWeb.invoke',
        text,
      );
    }
  }

  /// Launch the share interface for the current selection,
  /// as in the "Share" edit menu button on iOS.
  ///
  /// Currently this is only implemented for iOS.
  Future<void> _shareSelection(SelectionChangedCause cause) async {
    final String text = textEditingValue.selection.textInside(textEditingValue.text);
    if (text.isNotEmpty) {
      await SystemChannels.platform.invokeMethod(
        'Share.invoke',
        text,
      );
    }
  }

@domesticmouse domesticmouse changed the base branch from main to beta November 9, 2023 06:58
@domesticmouse domesticmouse merged commit 02067cb into beta Nov 11, 2023
2 of 6 checks passed
@domesticmouse domesticmouse deleted the simplistic-editor-fix branch November 11, 2023 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants