For #26587 - Replace the color in DefaultImagePlaceholder with FirefoxTheme layer2
This commit is contained in:
parent
45f998ee95
commit
a9b2f1c6a7
|
@ -17,6 +17,7 @@ import androidx.compose.ui.unit.dp
|
||||||
import mozilla.components.support.images.compose.loader.ImageLoader
|
import mozilla.components.support.images.compose.loader.ImageLoader
|
||||||
import mozilla.components.support.images.compose.loader.WithImage
|
import mozilla.components.support.images.compose.loader.WithImage
|
||||||
import org.mozilla.fenix.components.components
|
import org.mozilla.fenix.components.components
|
||||||
|
import org.mozilla.fenix.theme.FirefoxTheme
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A composable that lays out and draws the image from a given URL while showing a default placeholder
|
* A composable that lays out and draws the image from a given URL while showing a default placeholder
|
||||||
|
@ -75,8 +76,10 @@ fun Image(
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
||||||
private fun ImagePreview() {
|
private fun ImagePreview() {
|
||||||
Image(
|
FirefoxTheme {
|
||||||
"https://mozilla.com",
|
Image(
|
||||||
Modifier.height(100.dp).width(200.dp)
|
url = "https://mozilla.com",
|
||||||
)
|
modifier = Modifier.height(100.dp).width(200.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package org.mozilla.fenix.compose
|
package org.mozilla.fenix.compose
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
@ -17,7 +16,7 @@ import androidx.compose.ui.unit.dp
|
||||||
import mozilla.components.support.images.compose.loader.Fallback
|
import mozilla.components.support.images.compose.loader.Fallback
|
||||||
import mozilla.components.support.images.compose.loader.ImageLoaderScope
|
import mozilla.components.support.images.compose.loader.ImageLoaderScope
|
||||||
import mozilla.components.support.images.compose.loader.Placeholder
|
import mozilla.components.support.images.compose.loader.Placeholder
|
||||||
import mozilla.components.ui.colors.PhotonColors
|
import org.mozilla.fenix.theme.FirefoxTheme
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the app default image placeholder while the image is still getting loaded.
|
* Renders the app default image placeholder while the image is still getting loaded.
|
||||||
|
@ -68,20 +67,17 @@ internal fun DefaultImagePlaceholder(
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
contentDescription: String? = null
|
contentDescription: String? = null
|
||||||
) {
|
) {
|
||||||
val color = when (isSystemInDarkTheme()) {
|
Image(ColorPainter(FirefoxTheme.colors.layer2), contentDescription, modifier)
|
||||||
true -> PhotonColors.DarkGrey30
|
|
||||||
false -> PhotonColors.LightGrey30
|
|
||||||
}
|
|
||||||
|
|
||||||
Image(ColorPainter(color), contentDescription, modifier)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
||||||
private fun DefaultImagePlaceholderPreview() {
|
private fun DefaultImagePlaceholderPreview() {
|
||||||
DefaultImagePlaceholder(
|
FirefoxTheme {
|
||||||
Modifier
|
DefaultImagePlaceholder(
|
||||||
.size(200.dp, 100.dp)
|
Modifier
|
||||||
.clip(RoundedCornerShape(8.dp))
|
.size(200.dp, 100.dp)
|
||||||
)
|
.clip(RoundedCornerShape(8.dp))
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user