mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
Bug 1844750 - Improve fallback for homepage images thumbnails
Added fallback images for both Jump Back In thumbnail and recently saved thumbnails.
This commit is contained in:
parent
2853033b23
commit
e374f2a670
@ -5,7 +5,6 @@
|
||||
package org.mozilla.fenix.home.recentbookmarks.view
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
@ -42,10 +41,10 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import mozilla.components.browser.icons.compose.Loader
|
||||
import mozilla.components.browser.icons.compose.Placeholder
|
||||
import mozilla.components.browser.icons.compose.WithIcon
|
||||
import mozilla.components.ui.colors.PhotonColors
|
||||
import org.mozilla.fenix.components.components
|
||||
import org.mozilla.fenix.compose.ContextualMenu
|
||||
import org.mozilla.fenix.compose.Favicon
|
||||
import org.mozilla.fenix.compose.Image
|
||||
import org.mozilla.fenix.compose.MenuItem
|
||||
import org.mozilla.fenix.compose.annotation.LightDarkPreview
|
||||
@ -172,6 +171,11 @@ private fun RecentBookmarkImage(bookmark: RecentBookmark) {
|
||||
modifier = imageModifier,
|
||||
targetSize = imageWidth,
|
||||
contentScale = ContentScale.Crop,
|
||||
fallback = {
|
||||
if (!bookmark.url.isNullOrEmpty()) {
|
||||
FallbackBookmarkFaviconImage(url = bookmark.url)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
!bookmark.url.isNullOrEmpty() && !inComposePreview -> {
|
||||
@ -180,23 +184,7 @@ private fun RecentBookmarkImage(bookmark: RecentBookmark) {
|
||||
PlaceholderBookmarkImage()
|
||||
}
|
||||
|
||||
WithIcon { icon ->
|
||||
Box(
|
||||
modifier = imageModifier.background(
|
||||
color = FirefoxTheme.colors.layer2,
|
||||
),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Image(
|
||||
painter = icon.painter,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.size(36.dp)
|
||||
.clip(cardShape),
|
||||
contentScale = ContentScale.Crop,
|
||||
)
|
||||
}
|
||||
}
|
||||
FallbackBookmarkFaviconImage(bookmark.url)
|
||||
}
|
||||
}
|
||||
inComposePreview -> {
|
||||
@ -217,6 +205,20 @@ private fun PlaceholderBookmarkImage() {
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun FallbackBookmarkFaviconImage(
|
||||
url: String,
|
||||
) {
|
||||
Box(
|
||||
modifier = imageModifier.background(
|
||||
color = FirefoxTheme.colors.layer2,
|
||||
),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Favicon(url = url, size = 36.dp)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@LightDarkPreview
|
||||
private fun RecentBookmarksPreview() {
|
||||
|
@ -240,6 +240,15 @@ fun RecentTabImage(
|
||||
modifier = modifier,
|
||||
targetSize = THUMBNAIL_SIZE.dp,
|
||||
contentScale = ContentScale.Crop,
|
||||
fallback = {
|
||||
TabThumbnail(
|
||||
tab = tab.state,
|
||||
size = LocalDensity.current.run { THUMBNAIL_SIZE.dp.toPx().toInt() },
|
||||
storage = storage,
|
||||
modifier = modifier,
|
||||
contentScale = contentScale,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
else -> TabThumbnail(
|
||||
|
Loading…
Reference in New Issue
Block a user