Skip to content

Instantly share code, notes, and snippets.

View MhmoudAlim's full-sized avatar

Mahmoud H. Alim MhmoudAlim

View GitHub Profile
/**
* Converts a [Flow] to a [StateFlow] that automatically starts and stops collection based on the number of collectors.
*
* This function is particularly useful for efficiently managing state in ViewModels, especially when dealing with
* data that needs to be retained across configuration changes but should not continuously consume resources when
* there are no active collectors.
*
*
* Usage considerations:
* - Prefer this over [stateIn] with [SharingStarted.Lazily] or [SharingStarted.Eagerly] in ViewModels to avoid
package com.mahmoudalim.onboarding_presentation.welcome.composables
import androidx.compose.runtime.Composable
import androidx.compose.animation.core.*
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size