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

feat: Add onComplete callback and a newLineNotifier to TextBoxComponent and ScrollTextBoxComponent #3105

Merged
merged 11 commits into from
Mar 28, 2024

Conversation

KurtLa
Copy link
Contributor

@KurtLa KurtLa commented Mar 27, 2024

Description

Provides an onComplete callback to trigger actions after text is fully displayed. Furthermore adds a Notifier newLineNotifier for notifications when a new line starts.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Fixes #3088

Copy link
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

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

Other than the naming it looks good!
Could you add a small test too?

@KurtLa
Copy link
Contributor Author

KurtLa commented Mar 27, 2024

@spydon
Sure, what do you want to cover with that test and where do you want it?

@spydon
Copy link
Member

spydon commented Mar 27, 2024

@spydon
Sure, what do you want to cover with that test and where do you want it?

You can create it in a new file with the name of the component, next to this one:
https://github.com/flame-engine/flame/blob/main/packages%2Fflame%2Ftest%2Fcomponents%2Ftext_box_component_test.dart

Since your PR only covers onComplete it would be enough to just test that onComplete is called in all cases, like when it has to scroll and when it doesn't have to scroll.

Copy link
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

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

A few minor comments, otherwise it looks good!

Comment on lines 19 to 21
late final ValueNotifier<int> _newLineNotifier;

ValueNotifier<int> get newLineNotifier => _newLineNotifier;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
late final ValueNotifier<int> _newLineNotifier;
ValueNotifier<int> get newLineNotifier => _newLineNotifier;
late final ValueNotifier<int> newLineNotifier;

It should be fine to have just this one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, you're right :)

packages/flame/lib/src/components/text_box_component.dart Outdated Show resolved Hide resolved
@spydon spydon enabled auto-merge (squash) March 28, 2024 16:19
@spydon spydon merged commit 233cc94 into flame-engine:main Mar 28, 2024
8 checks passed
@KurtLa KurtLa changed the title feat: Add onFinished callback to ScrollTextBoxComponent feat: Add onComplete callback and a newLineNotifier to TextBoxComponent and ScrollTextBoxComponent Mar 28, 2024
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.

Unable scroll the text of the ScrollTextBoxComponent if I do not use timePerChar
2 participants