8000 Add support for more than 2 arguments to minOf/maxOf (both for XInt/YInt, XAxisSolver/YAxisSolver variants) · Issue #116 · cashapp/contour · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
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

Open
dimsuz opened this issue Jan 11, 2021 · 1 comment

Comments

@dimsuz
Copy link
dimsuz commented Jan 11, 2021

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 r 93A7 an 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 :)

@dimsuz dimsuz changed the title Add support for more than 3 arguments to minOf/maxOf (both for XInt/YInt, XAxisSolver/YAxisSolver variants) Add support for more than 2 arguments to minOf/maxOf (both for XInt/YInt, XAxisSolver/YAxisSolver variants) Jan 11, 2021
@aerb
Copy link
Contributor
aerb commented Jan 20, 2021

This should be pretty doable.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0