Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.
This repository was archived by the owner on May 14, 2025. It is now read-only.

Add support for more than 2 arguments to minOf/maxOf (both for XInt/YInt, XAxisSolver/YAxisSolver variants) #116

@dimsuz

Description

@dimsuz

It is not the first time I have this usecase, where I want more than two arguments for minOf.

minOf currently supports XInt/YInt and XAxisSolver/YAxisSolver (but only 2 args for both kinds)...

I have just ran into another case with the latter. The layout is like this:

TITLE
PRIMARY_ACTION (optional, maybe GONE)
SECONDARY_ACTION (optional, maybe GONE)
---screen-bottom---

I want to do something like this:

titleView.layoutBy(
  x = matchParentX(),
  y = minOf(
     bottomTo { primaryAction.top() - 16.ydip },
     bottomTo { secondaryAction.top() - 16.ydip },
     bottomTo { parent.bottom() - 16.ydip },
  )
)

but minOf has only 2 args... Similar situation is for xint/yint, I often find myself wishing for more args.

Is this possible or maybe I also miss some easy workaround to achive what I want? I know I can put if (someView.isVisible) rule1 else rule2 in my lambdas, but that looks not very elegant and a bit messy...

P.S. Can't help but think that if we'd be in the functional programming land, XInt/Yint, and axis solvers could be an instance of Monoid + Ord and all the stdlib functions (including min) would just work on them. But oh well :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions