Skip to content

Added preferred height#129

Open
kombatkos wants to merge 3 commits into
dev/version-1from
Add-preferredHeight
Open

Added preferred height#129
kombatkos wants to merge 3 commits into
dev/version-1from
Add-preferredHeight

Conversation

@kombatkos
Copy link
Copy Markdown
Collaborator

@kombatkos kombatkos commented Mar 21, 2022

Что сделано:

  • Добавил публичное опциональное проперти preferredHeight. Так как кострейнт высоты TextView приватный и не доступен для использования, было принято решение добавить свойство для его регулировки.

Когда это нужно

  • Когда на проекте есть многострочный TextView с разной начальной высотой

@kombatkos kombatkos self-assigned this Mar 21, 2022

// MARK: - Public Properties

public var preferredHeight: CGFloat?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

предложил бы переименовать в preferredTextHeight
(типа что именно TEXT height, а то там этих настроек высоты уже столько, что черт ногу сломит 😢 )

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

и комментов подлить, зачем, почему и к чему приведет

}

textViewHeightConstraint.constant = textHeight
textViewHeightConstraint.constant = preferredHeight ?? textHeight
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

а вот это вот не уверен, что совсем верно
textheight участвует в вычислении actualViewHeight -> надо бы подменить до того, как она будет еще где-то использована, по идее - в строке

let textHeight = min(textViewHeight(), maxTextContainerHeight ?? CGFloat.greatestFiniteMagnitude)

это сделать можно

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

а то может привести к какому-то такому результату
Снимок экрана 2022-03-21 в 15 13 38

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Проверил на проекте и на тимплейтах, все работает!

2022-03-21.22.42.18.mov
2022-03-21.22.36.20.mov

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