https://kotlinlang.org logo
c

codeslubber

11/08/2019, 3:41 PM
The SwiftUI Tutorial has a section where they wrap their paging component and then use it from SwiftUI, each ‘view’ in the sequence is then declarative and the coordinator logic is bolted on. I want to do the equivalent in Compose. Is there a way to integrate Compose code with just standard View components? and/or an example of doing this? It would seem that the whole idea of a framework entitled Compose would be to demonstrate the creation of components that are made up of other components (like a ViewPager2).
l

Luca Nicoletti

11/08/2019, 3:42 PM
so, if you want to know how to use an
old view
in
compose
, have a look at how
webview
is done
If you want to do vice-versa, you need to wait for the
@GenerateView
annotation to be completed
c

codeslubber

11/08/2019, 3:43 PM
oh ok, I think that’s probably what I would need..
l

Luca Nicoletti

11/08/2019, 3:43 PM
Btw, I see no point in using
Compose
inside the old Android Framework
I’d rather wait and start with small screens entirely in
Compose
c

codeslubber

11/08/2019, 3:44 PM
well that’s not really what they are doing
l

Luca Nicoletti

11/08/2019, 3:44 PM
Well, they need a solid base before allowing you to use
components
inside old view system
c

codeslubber

11/08/2019, 3:44 PM
ok, and how would you tie them all together into a wizard? rewrite
ViewPager2
? [no snark there]
l

Luca Nicoletti

11/08/2019, 3:45 PM
There are already examples of
Tabs
in compose
c

codeslubber

11/08/2019, 3:45 PM
ok maybe that’s enough thanks I will look at that
l

Luca Nicoletti

11/08/2019, 3:46 PM
The idea would be to have 2 components, one for the
tabs
themselves and 1 for the
content
both built in
compose
, interacting with each other 🙂
c

codeslubber

11/08/2019, 3:46 PM
right
l

Luca Nicoletti

11/08/2019, 3:46 PM
nw 🙂
c

codeslubber

11/08/2019, 3:46 PM
sure
so you are basically saying you don’t really need
ViewPager
, just make the views in compose, and then treat them as tabs and bolt the nav logic on top
l

Luca Nicoletti

11/08/2019, 3:47 PM
Well, I’m saying you could do that
c

codeslubber

11/08/2019, 3:50 PM
yes
thanks it’s helpful I will look at the tab samples..
l

Luca Nicoletti

11/08/2019, 3:52 PM
And, for navigation (really basic) there are already examples already
There’s a drawer example and JetSample handles it 🙂
State was not handled properly in the example
c

codeslubber

11/08/2019, 4:12 PM
wow fantastic! thanks..
l

Leland Richardson [G]

11/08/2019, 4:22 PM
I have some code that integrates with RecyclerView and ViewPager. it’s a little bit hacky… but could put in a gist or something
👍 2
one thing to take into account is that while integration with android views is explicitly possible and was a primary design goal of compose, it is something where the IDE support for it right now is still really lacking
so we haven’t shown very many examples with it
because it feels wierd when the IDE complains about stuff or doesn’t work right and nothing is wrong
IDE support will happen, but at the moment we are putting more resources into getting the compose toolkit working smoothly
c

codeslubber

11/08/2019, 4:37 PM
thanks Leland! that makes a lot of sense.. have you guys done any brainstorming on what the DSL could unlock, in terms of those kinds of UI patterns? (wizards, onboarding, multi-panel config, etc.)?
l

Leland Richardson [G]

11/08/2019, 5:39 PM
i have a few things in mind for sure. there was a cool hackathon project this week that hooked up compose to RemoteViews for notifications. Was nice that you could use compose to create dynamic UI in the notifications pane where the code felt seamlessly integrated with the rest of your UI
😮 4
and could be done from background services etc too
pretty cool
not sure if that is going to go anywhere, but might give you an idea for what type of things you could do
c

codeslubber

11/08/2019, 5:39 PM
wow fantastic
l

Leland Richardson [G]

11/08/2019, 5:40 PM
there already exists some work in compose on a composer that builds of Vectors instead of ComponentNodes or Views. It could basically replace AnimatedVectorDrawable IMO
c

codeslubber

11/08/2019, 5:42 PM
have a piece I need to do that is going to involve getting a moderately complex
ViewModel
to drive a bunch of composable `View`s so I think this should be a great way to go..
5 Views