ribesg
02/25/2019, 10:33 AMpiotrek1543
02/25/2019, 10:34 AMribesg
02/25/2019, 10:35 AMpiotrek1543
02/25/2019, 10:35 AMlouiscad
02/25/2019, 11:05 AMribesg
02/25/2019, 11:08 AMribesg
02/25/2019, 11:53 AMlouiscad
02/25/2019, 11:54 AMribesg
02/25/2019, 11:55 AMribesg
02/25/2019, 12:40 PMlouiscad
02/25/2019, 12:45 PMlouiscad
02/25/2019, 12:46 PMribesg
02/25/2019, 12:48 PMcompileDebugKotlin
task multiple times and tried to close and reopen the file / the project / IDEA, but it doesn’t seem to workribesg
02/25/2019, 12:56 PMlouiscad
02/25/2019, 2:10 PMribesg
02/25/2019, 2:12 PMlouiscad
02/25/2019, 2:13 PMribesg
02/25/2019, 2:16 PMcompileDebugKotlin
and forced refreshed and there’s an error now: https://gist.github.com/Ribesg/f5d502d35110c4dbefc9e10f976a8f77ribesg
02/25/2019, 2:26 PMlouiscad
02/25/2019, 2:27 PMBenoît
02/26/2019, 10:15 AMlouiscad
02/26/2019, 10:17 AMBenoît
02/26/2019, 10:39 AMribesg
02/26/2019, 10:51 AMadd(
textView {
text = "Test"
},
lParams {
...
}
)
is less readable than this
textView {
text = "Test"
}.lparams {
...
}
but I think I also understand why @louiscad made that choice. I think the idea is to separate the view itself, which you define somewhere else (a local property, a local function, whatever) and the layout params of that view in it’s container.Benoît
02/26/2019, 10:55 AMribesg
02/26/2019, 10:58 AMlouiscad
02/26/2019, 10:59 AMView
and ViewGroup.LayoutParams
, which made the library more heavyweight and didn't scale well with custom Views (including from third parties or Material Components). Also, it would implictly add the view to the current ViewGroup
, which was often an error if you did not specify the layout params.
In your "more readable" example, the fact that the textView
is added is implicit, so of course, missing explictedness is quicker to read, but it can also be slower to understand at scale because you have to guess or remember.ribesg
02/26/2019, 11:04 AM.lparams
adds the view to the parent? It’s an obscure behavior, but not really more obscure than what Anko doesBenoît
02/26/2019, 11:07 AMviewgroups
is a terrible ideaBenoît
02/26/2019, 11:11 AMlouiscad
02/26/2019, 11:12 AMView
and ViewGroup.LayoutParams
. This is a mutliplication, and multipying the amount of code one needs to write doesn't scale well, and it bloats the final app. In other words, that would still have the major drawback of Anko's approach.louiscad
02/26/2019, 11:15 AMBenoît
02/26/2019, 11:17 AMinline fun <T : View> T.frameLayoutLP(
width: Int = matchParent,
height: Int = matchParent,
init: FrameLayout.LayoutParams.() -> Unit = {}
): T {
layoutParams = FrameLayout.LayoutParams(width, height).apply(init)
return this
}
ribesg
02/26/2019, 11:18 AMoverride val root = constraintLayout {
and then a lot of add
blocks under it, which is kinda hard to read, I just need to get used to the correct way of writing `Ui`s... but what is the correct way? @louiscad is there no problem having local properties keeping references to subviews in my Ui
?louiscad
02/26/2019, 11:18 AMlouiscad
02/26/2019, 11:22 AMUi
implementation, there's already a strong reference to it (root
). I also have a lot of add
calls referencing properties (of type View
) with lParams { ... }
in it.sngrekov
02/26/2019, 1:08 PMr4zzz4k
04/02/2019, 9:38 AMdealing mostly with interfaces and functions (implemented in Android's View or other platform native way of displaying UI controls)How do you envision this? I was thinking of having class hierarchy replicating Android View classes and also implementing needed interfaces, but you explicitly mention above that you don't consider this solution acceptable. As a side note, if you see at least some people using your library, it may be logical to create #splitties for it :)
louiscad
04/02/2019, 9:48 AMContext
to create any View
or access resources. On iOS, you don't, and any View
may have subViews, while on Android, it's only possible for ViewGroup
subclasses. So the solution is to move away from the widgets when defining the user interfaces, and using interface
for that. I already do this even though I'm not really multiplatform yet. Splitties in its current form helps me to implement those `interface`s I create for the Android platform. At some point, I'd like to define platform agnostic types for two values controls (implemented by Switches, CheckBoxes, toggles, etc), values selection with limited count controls (implemented by lists, dropdowns, etc), and other kinds of scenarios, where you'd care about input values, ouput values, and what implementation you pick, that'd be a one line change to swap it for another implementation.louiscad
04/02/2019, 9:50 AMr4zzz4k
04/02/2019, 10:31 AM