GithubHelp home page GithubHelp logo

Comments (6)

NickEntin avatar NickEntin commented on September 27, 2024

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.

efirestone avatar efirestone commented on September 27, 2024

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.

NickEntin avatar NickEntin commented on September 27, 2024

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.

efirestone avatar efirestone commented on September 27, 2024

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.

NickEntin avatar NickEntin commented on September 27, 2024

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.

NickEntin avatar NickEntin commented on September 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.