Android
Going edge-to-edge with Compose without losing it
A practical guide to edge-to-edge layouts in Compose: handling Window Insets, transparent status/navigation bars, and icon tints — recreating YouTube's Ambient Mode effect.
Android
A practical guide to edge-to-edge layouts in Compose: handling Window Insets, transparent status/navigation bars, and icon tints — recreating YouTube's Ambient Mode effect.
Sometimes, I get the impression one needs 42 hours of research and a PhD dissertation to figure out how to send a one-time event from the ViewModel layer to the UI safely these days. Memes aside, it feels like there is no “true” consensus on how to do such
Compose is fun. I do get the feeling that there are quite a few “gotchas” when working with it, though. Here are a few questions that kept bugging me: * Are all functions equal in the eyes of the compiler? * Are suspend functions stable/immutable? * Do recomposition scopes even matter much?
Dagger-Hilt is fine and all. Unfortunately, it arrived a bit too late in the android dev lifecycle. If I had to guess, most projects out there are still stuck using plain Dagger2. The official google android docs use Hilt to showcase Jetpack Compose code. What if you are stuck
These are not the droids you are looking for
On a long enough timeline, every test is a flaky test
Wot I think
Start a work request (see how-to-hilt+workmanager in the previous episode) A method in a ViewModel will do: fun startTodoWork() { viewModelScope.launch { val oneTimeWorkRequest = OneTimeWorkRequestBuilder<MyWorker>() .addTag("myTag") .setConstraints( Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .build() ) .build() workManager.enqueueUniqueWork(
Add (more) dependencies dependencies { implementation("androidx.hilt:hilt-work:1.0.0") kapt("androidx.hilt:hilt-compiler:1.0.0") } Declare a dagger module Make it easy to inject the singleton WorkManager instance anywhere. Debug logging level is optional. @Module @InstallIn(SingletonComponent::class) object WorkModule { @Provides
Kotlin Coroutines 1.4 is here, as is another chance to stave off boredom.
🤖::execute order process death::🤖
This is part of a series head-scratching my way into coroutines. It can be read as a standalone although you might be missing out on some spicy memes here and here. Testing ViewModels without losing the will to live A ViewModel “sits” quite close to the activity/fragment. Something