https://kotlinlang.org logo
#compose
Title
# compose
h

huannguyen

08/05/2020, 7:42 AM
I believe existing UI libraries (e.g., custom
RecyclerView
) would not work with a
Composable
function. Anyone knows if there is any guide at this stage to convert such libraries to
Compose
?
👀 1
I’m asking in the context of migrating an existing project to
Compose
. If the project used a lot of common in house UI libraries and there is no easy way of converting such libs to work with
Composable
functions I guess the only option would be rewriting those libs with
Compose
which probably is a huge task. So curious if there is a better way
j

James Smith

08/05/2020, 9:35 AM
You can use regular Views inside Compose, that's how WebView is going to work with Compose for example. It's probably not a good idea to use custom RecyclerView inside Compose, but for some things it's fine
h

huannguyen

08/05/2020, 10:02 AM
Thanks. I’ll have a look. I agree its not great mixing Compose with the old way of building UI. Mainly I’m trying to think of how the migration steps would look like for a big codebase. Likely such mixture of usage would be introduced in the early steps and slowly removed down the track .
a

alexsullivan114

08/05/2020, 11:57 AM
Are you actively trying to migrate a large production project to Compose? Feels ballsy.
h

huannguyen

08/05/2020, 3:20 PM
haha no, just thinking at this stage since Compose is still under development. Mainly I want to get a feel of how such migration would look like and what are the steps involved. I think for a typical big project migrating the entire code base to Compose would not make sense since that is a big risk. What normally would happen is only new Fragment/Activity would be using Compose. However since our codebase relies on a number of common UI libraries, those new Fragments/Activities may not be able to use those libs (and hence the question). If we end up having to rewrite the libs in
Compose
that’d be a big task and the question would then be - is it worth to migrate.
androidx.compose.ui.viewinterop.emitView
from the link above looks interesting tho.
z

Zach Klippenstein (he/him) [MOD]

08/05/2020, 4:10 PM
I don't know any reason why RecyclerView wouldn't work in Compose. Pretty sure WebView is much more complicated and it is the primary sample, if not intended use case, for such integrations. You can definitely just use Compose for its declarative API and not use any of the compose components, using emitView. Leland has said that was intentionally supported from the start. You could also try using Compose's layout system but using classic Android views for stuff like text and RecyclerViews, which are very incomplete in Compose so far.
👍 1
h

huannguyen

08/07/2020, 2:19 PM
Thanks @Zach Klippenstein (he/him) [MOD] I’ll look into it closely