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

Add popover toolbar builder that uses Flutter's new support for an iOS 16+ system toolbar (Resolves #2032) #2058

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

matthew-carroll
Copy link
Contributor

@matthew-carroll matthew-carroll commented May 29, 2024

Add popover toolbar builder that uses Flutter's new support for an iOS 16+ system toolbar (Resolves #2032)

Also renamed some files for that were still using the unnecessary underscore "_" prefix.

The following code snippet should let you try the new SuperIOSTextField toolbar:

class _iOSSuperTextField extends StatefulWidget {
  const _iOSSuperTextField();

  @override
  State<_iOSSuperTextField> createState() => _iOSSuperTextFieldState();
}

class _iOSSuperTextFieldState extends State<_iOSSuperTextField> {
  final _textFieldKey = GlobalKey();
  final _focusNode = FocusNode();
  final _textController = ImeAttributedTextEditingController(
    controller: AttributedTextEditingController(
      text: AttributedText("This is some text to copy and paste."),
    ),
  );

  @override
  void dispose() {
    _textController.dispose();
    _focusNode.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return TapRegion(
      groupId: "textfields",
      onTapOutside: (_) => _focusNode.unfocus(),
      child: TextFieldBorder(
        focusNode: _focusNode,
        borderBuilder: _borderBuilder,
        child: SuperIOSTextField(
          key: _textFieldKey,
          focusNode: _focusNode,
          tapRegionGroupId: "textfields",
          textController: _textController,
          textStyleBuilder: _textStyleBuilder,
          hintBuilder: _createHintBuilder("Enter single line text..."),
          padding: const EdgeInsets.all(4),
          minLines: 1,
          maxLines: 1,
          caretStyle: CaretStyle().copyWith(color: Colors.red),
          selectionColor: Colors.red,
          handlesColor: Colors.red,
          popoverToolbarBuilder: iOSSystemPopoverToolbarWithBackupFlutterVersion,
        ),
      ),
    );
  }
}

@matthew-carroll
Copy link
Contributor Author

@BazinC - I added iOS system menu support to SuperIOSTextfield - would you like to try that out on the text field before I add it to SuperEditor?

Copy link
Collaborator

@angelosilvestre angelosilvestre left a comment

Choose a reason for hiding this comment

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

LGTM with a single comment.


/// An [IOSPopoverToolbarBuilder] that displays the iOS system popover toolbar, if the version of
/// iOS is recent enough, otherwise builds [defaultIosPopoverToolbarBuilder].
Widget iOSSystemPopoverToolbarWithBackupFlutterVersion(BuildContext context, IOSEditingOverlayController controller) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is WithBackupFlutterVersion an appropriate name? I think iOSSystemPopoverToolbarWithFallback would be simpler.

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.

[iOS] Support native edit menu + Secure Paste
2 participants