I just started reading and experimenting with Comp...
# compose
z
I just started reading and experimenting with Compose. So far it looks awesome - thanks to everyone involved in this enormous effort โค๏ธ As expected, I have a lot of questions ๐Ÿ˜„ After doing Android development for more than 10 years it's really hard to switch to Compose ๐Ÿ˜Š 1. I've been reading the examples and quite often they use a Composable called
Scaffold
but reading the docs doesn't really explain what it is. Judging by the samples, it looks to be something like a
CoordinatorLayout
, am I right? 2. All the samples I've been reading use hardcoded values for dimensions (using the extension function
Int.dp()
). Haven't read much about Theming yet, but is it possible to define something similar to custom attributes (
attrs.xml
) or dimensions and reference those instead of the hardcoded values? Same for Strings - is there an alternative to
strings.xml
/
plurals.xml
3. Are there any more complex examples of a complete application? I'm about to read and play with Chris Banes' Tivi, as I'd like to see some samples on how to handle large app with many different screens, what are the best practices to integrate Composables with ViewModel... 4. And last one for the time being - so far I haven't seen/read anything about handling configuration changes (the most common one being screen rotation). In Activity's world we have
onSaveInstanceState()
- is there an alternative in Compose (other than ViewModel's SaveState)?
a
1. yes, Scaffold is a more specific CoordinatorLayout for material design patterns. 2. yep, just use constants in your code declared at whatever scope makes sense for your use case. Strings still use strings.xml; there's a lot of tooling ecosystem around this today and we're not attempting to change that at the moment. 3. tivi is good, also try the jetnews sample 4. there's a savedInstanceState composable that has a shape like
remember {}
but that does the usual parcel saving.
๐Ÿ‘ 3
z
Thanks a lot for the quick reply! I'm reading the jetnews app right now and that's where some of the questions popped-up ๐Ÿ™‚ Will check the
savedInstanceState
composable and how to reference String resources.
๐Ÿ‘ 2
a
z
And for anyone interested, these are the functions to load resources - strings, fonts, colors, etc.
c
Just to follow up on Tivi, at the moment it's still very much 'some Compose' in an existing View-based app (everything is in fragments for example). As I migrate more screens over, it will be interesting to see what changes I need to make to remove those fragments.
๐Ÿ‘ 4