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

WrapContent does not ignore hidden views #189

Closed
marclefrancois opened this issue Mar 19, 2019 · 4 comments
Closed

WrapContent does not ignore hidden views #189

marclefrancois opened this issue Mar 19, 2019 · 4 comments

Comments

@marclefrancois
Copy link

Just came across an unexpected behaviour.

Lets says i have a view with 3 subviews that i layout side by side. if i hide one of the views, wrapContent on the parent view does not skip the hidden View so the parent ends up being too wide.

I was wondering if adding the following at the beginning of the wrapContent method would be desirable:

let subviews = view.subviews.filter { (view) -> Bool in
            return view.isVisible
        }

It requires adding isVisible to the Layoutable protocol which is fairly easy

Thanks !

@lucdion
Copy link
Member

lucdion commented Mar 20, 2019

Hi @marclefrancois!

I need to think about it, but:

  1. Changing the default behaviour of the wrapContent method is not a solution, it would create a behaviour breaking change. I'm fine with compilation breaking change, but changing the behaviour, its from my point of view totally wrong. We need a way to opt-in.
  2. What if someone wants to opposite? I.e. they want to wrap visible and unvisible views.

Possible solutions I see:

  1. Add new WrapType enumeration values for wrapContent(:WrapType). For example .horizontallyVisibleOnly or .horizontallyVisible. Ex: view.pin.wrapContent(.horizontallyVisibleOnly)
  2. Add a wrapContent(:[Layoutable]) method, receiving a list of views that you want a wrap.
  3. ... 🤔

@marclefrancois
Copy link
Author

marclefrancois commented Mar 20, 2019

Thanks for the answer @lucdion !

Off the top of my head i kinda prefer option 1.

Or maybe it could be a secondParameter wrapContent(.horizontally, visibleOnly: true)

Or maybe it could be a another method: wrapVisibleContent(.horizontally)

@wjling
Copy link

wjling commented Apr 6, 2022

It will be very useful to ignore hidden views.

@lucdion
Copy link
Member

lucdion commented Mar 1, 2023

Very old topic. Closing it, sorry

@lucdion lucdion closed this as completed Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants