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

support text wrapping and centering #146

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JeppeLeth
Copy link

Description

Prevent long texts to be covered by the slide icon button as well as gets cut off by supporting text-wrapping.

Used solution proposed by @Nealsoni00 and added ellipsis and dynamic max lines.

Related PRs/Issues

mText cutoff and wrapping issue #140

Screenshot

Used string Sample SlideToActView veeeeeeeeeeeeeeeeeery looooong long loooooong looooooong looooooooong looooong text
image

Prevent long texts to be covered by the slide icon button as well as gets cut off by supporting text-wrapping.
@cortinico cortinico added this to the 0.10.0 milestone Jan 3, 2021
Copy link
Owner

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Thanks for you change @JeppeLeth and sorry for the late review but I was taking some time for Xmas 🎅

Overall the change looks good, but there are a couple of things to address:

  • With this change the text is now not centered anymore. This is a pretty significant behavioural change that I'd rather avoid. I believe we should apply the canvas translation only if the number of lines is above 1.
    Screenshot 2021-01-03 at 18 29 37

  • I believe we should increase the left margin as the text is bleeding below the slider.
    Screenshot 2021-01-03 at 18 31 44

  • The text is having a funny yet weird animation when resetting the slides. This goes along the way that the StaticLayout.Builder.build() method should be invoked only once and not on every onDraw:
    Jan-03-2021 18-32-39

  • Examples should be added, ideally here: https://github.com/cortinico/slidetoact/blob/master/example/src/main/res/layout/content_text_size.xml

Comment on lines +490 to +492
val leftOffset =
(mAreaHeight - 2 * mActualAreaMargin).toFloat() / mAreaHeight.toFloat() *
mBorderRadius.toFloat() * 2
Copy link
Owner

Choose a reason for hiding this comment

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

Can you move this inside the else branch?

val mTextTop = 0 + dY
val mTextRight = mAreaWidth - mActualAreaWidth - dX

canvas.translate(mTextLeft.toFloat(), mTextTop.toFloat())
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
canvas.translate(mTextLeft.toFloat(), mTextTop.toFloat())
canvas.translate(mTextLeft, mTextTop.toFloat())

val mTextRight = mAreaWidth - mActualAreaWidth - dX

canvas.translate(mTextLeft.toFloat(), mTextTop.toFloat())
canvas.translate(((mTextRight - mTextLeft) / 2).toFloat(), 0f)
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
canvas.translate(((mTextRight - mTextLeft) / 2).toFloat(), 0f)
canvas.translate(((mTextRight - mTextLeft) / 2), 0f)

@cortinico
Copy link
Owner

Please let me know if you need some support going forward 🙏

not-chicken added a commit to not-chicken/slidetoact that referenced this pull request Aug 24, 2022
@cortinico cortinico modified the milestones: 0.10.0, 0.11.0 Feb 16, 2023
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