Comments (6)
Personally I think it would be cleanest to make this a method extending Array<ViewDistributionItem>
, so you could do something like:
applySubviewDistribution(
[ firstView, secondView, ].compacted()
)
The method name is a bit complicated though... it's not exactly hidden views, since it checks more than the isHidden
property. I'm having trouble thinking of a good description of it right now, but I agree that "compacting" is too vague.
from paralayout.
Today it's collapsing
, which implies that all of the views are collapsed, so compacting
is at least an improvement. We could use something like compactingInvisible
, or removingInvisible()
. There's some ambiguity there as to whether it removes all spacers, so could also do removingInvisibleViews()
. Some adjacent spacers will also be removed, but that's sort of just a side effect so I think it might be fine.
from paralayout.
I wonder if it's worth being more explicit about what it does, either by breaking it into separate methods or adding parameters to control the behavior? That's probably unnecessary, since you'll likely want all or nothing, but it would at least make the API clearer.
from paralayout.
In that vein I could see something like items.filterViews { $0.isVisible }
where filterViews
only calls the block for view items, and isVisible
is whatever logic we want for whether or not to show a view item.
from paralayout.
What if we did something like this:
public struct ViewVisibilityFactor: OptionSet {
public static let viewNotInHierarchy = VisibilityFactor(rawValue: 1 << 0)
public static let viewIsHidden = VisibilityFactor(rawValue: 1 << 1)
public static let viewHasZeroAlpha = VisibilityFactor(rawValue: 1 << 2)
public static let labelHasEmptyText = ...
public static let imageViewHasNilImage = ...
public static let all = [.viewNotInHierarchy, ...]
}
func filterViews(removing: VisibilityFactor) {}
public enum SpacerCollapsingBehavior {
case summingAdjacentSpacers
case selectingLargerOfAdjacentSpacers
case selectingSmallerOfAdjacentSpacers
}
func collapseSpacers(by behavior: SpacerCollapsingBehavior, removingFixedSpacersAdjacentToFlexibleSpacers: Bool) {}
from paralayout.
Since this hasn't made any progress in a while, I propose we remove the API for now from the 1.0 release. We can then add in more specific functionality (such as filtering view and collapsing spacers) as we establish clear use cases.
from paralayout.
Related Issues (20)
- Enum cases for insets and offsets should default to zero
- Add ResultBuilder-backed API for subview distribution HOT 1
- Support visionOS
- Support tvOS
- Account for distribution item insets when applying orthogonal alignment in distribution HOT 1
- Fixed spacing of 0 can be ignored between elements
- Remove assertions in slicing method
- Layers should also be alignable and distributable
- Rename non-mutating pixel rounding methods
- Improve support for handling layout directions
- Perform layout with bounds and center instead of frame
- Add distribution items for distributing a UILabel via its font bounds
- Improve alignment behavior around scroll views HOT 2
- Spreading subviews does not respect specified margin
- Spreading subviews does not respect specified value for sizeToBounds
- Consider better name for cases in TargetAlignmentBehavior HOT 5
- Converge on consistent preposition for describing alignment target HOT 1
- Paralayout positioning methods don't trigger updates to `safeAreaInsets` HOT 1
- View distribution still uses frame for orthogonal alignment HOT 1
- Horizontal view distribution works incorrectly in right-to-left layout
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from paralayout.