Last active
May 24, 2021 12:05
-
-
Save marenovakovic/6971ed658ae0863f24f09c1ad652d663 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import androidx.compose.runtime.Composable | |
import androidx.compose.runtime.remember | |
import androidx.compose.ui.platform.LocalContext | |
import coil.request.ImageRequest | |
import coil.target.Target | |
object DefaultRequest { | |
operator fun invoke(context: Context, url: String, target: Target) = | |
ImageRequest.Builder(context) | |
.data(url) | |
.target(target) | |
.allowHardware(false) | |
.build() | |
} | |
@Composable | |
fun rememberDefaultImageRequest(url: String, target: Target): ImageRequest { | |
val context = LocalContext.current | |
return remember(url) { DefaultRequest(context, url, target) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment