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

Set initial height based on content height #38

Closed
Ruslanbek0809 opened this issue Mar 15, 2022 · 7 comments
Closed

Set initial height based on content height #38

Ruslanbek0809 opened this issue Mar 15, 2022 · 7 comments
Assignees
Labels
enhancement New feature or request P3 Priority 3 Maybe it will be done later

Comments

@Ruslanbek0809
Copy link

No description provided.

@Ruslanbek0809 Ruslanbek0809 added the enhancement New feature or request label Mar 15, 2022
@MbIXjkee MbIXjkee added question Further information is requested and removed new issues labels Mar 22, 2022
@MbIXjkee
Copy link
Contributor

Hi! What functional do you want, please describe more detail?

@Ruslanbek0809
Copy link
Author

Hi, surf studio team! It would be great if the initial height adjusts for incoming content height. I see you guys from Russia. You can check this for the Yandex Yeda app. When the bottom sheet appears, its initial height is adjusted based on incoming content height.

@MbIXjkee
Copy link
Contributor

Do you mean that the content of the bottomsheet will not scroll and is always smaller than the screen size?

@Ruslanbek0809
Copy link
Author

Yeah. For example, in Yandex Yeda if there are not any meal parameters and it has an only description, its bottom sheet will be smaller than the screen size and adjusts based on its description height

@MbIXjkee MbIXjkee added P3 Priority 3 Maybe it will be done later and removed question Further information is requested labels Mar 24, 2022
@KristinaZoteva
Copy link
Contributor

KristinaZoteva commented Apr 7, 2022

@MbIXjkee Задача: Сделать так что бы размер BottomSheet мог зависеть от входящих данных, т е если размер входящих данных меньше чем высота BottomSheet которую мы задаем, то BottomSheet должен иметь высоту достаточную для отображения данных.
FlexibleBottomSheet принимает в себя minHeight, maxHeight, initHeight, builder(или bodyBuilder и headerBuilder). Билдеры возвращают контент, который должен отображаться в FlexibleBottomSheet, размер FlexibleBottomSheet зависит от переданных minHeight, maxHeight, initHeight, если их не передать, то эти значения будут работать со значениями по умолчанию(0.25, 0.5 и 1). FlexibleBottomSheet передает билдеры в виджет _Content, а он в свою очередь строит сам контент.

Для решения этого вопроса было попробовано:
В виджет FlexibleBottomSheet добавить post frame callback, который вызывается после построения макета и рассчитывает размер виджета _Content, затем делает setState и перестраивается с новыми значениями maxHeight и initHeight.
Так как виджет обернут в Expanded и Column действия выше не работают, потому что Expanded заставляет _Content занимать все доступное пространство, независимо от его реальных размеров. Я убрала виджеты Expanded и Column и обернула _Content в Scaffold, вместе с ними я попробовала убрать виджет, которых достраивал внизу пустой контейнер при открытой клавиатуре. Со Scaffold была такая же ситуация как и с Expanded. В виджет _Content я решила передать функцию которая будет вызываться после его построения и принимать в себя размер возвращаемого билдерами виджетов, для этого я обернула билдер в SizedBox и передала ему ключ по которому в post frame callback рассчитывается высота виджетов, возвращаемых билдером и вызывается функция переданная в _Content с нужной высотой, а в этой функции осуществляется setState с новыми данными в maxHeight и initHeight. Для того что бы это работало пользователь должен передать скроллящийся виджет с указанным shrinkWrap: true(например: ListView( shrinkWrap: true)) и maxHeight и initHeight должны быть равны, а поле isExpand должно быть false чтобы определить что нам нужен размер исходя из размера контента. Этот вариант работал, но т к мы убрали контейнер, который достраивался снизу для того чтобы нужное поле TextField было в фокусе, а Scaffold в не поднимает BottomSheet над клавиатурой, сломался тот функционал, который корректно работал с открытием клавиатуры.

После проверки работы BottomSheet без моих изменений выяснилось, что функционал, который не работал выше, не работал с самого начала, связанное issues #48

@MbIXjkee
Copy link
Contributor

Added in https://github.com/surfstudio/flutter-bottom-sheet/releases/tag/v3.0.0
Example also available.

@Ruslanbek0809
Copy link
Author

Added in https://github.com/surfstudio/flutter-bottom-sheet/releases/tag/v3.0.0 Example also available.

Thanx. You are a life savior, man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P3 Priority 3 Maybe it will be done later
Projects
None yet
Development

No branches or pull requests

4 participants