diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/common/ShimmerEffect.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/common/ShimmerEffect.kt index a26da7c00a..ba9257c79c 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/common/ShimmerEffect.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/common/ShimmerEffect.kt @@ -9,11 +9,15 @@ import androidx.compose.animation.core.tween import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.width import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Brush import androidx.compose.ui.res.colorResource +import androidx.compose.ui.unit.dp import com.anytypeio.anytype.core_ui.R @Composable @@ -27,11 +31,13 @@ fun ShimmerEffect( val colorStart = colorResource(id = R.color.background_secondary) val colorEnd = colorResource(id = R.color.shape_secondary) - val shimmerColors = listOf( - colorStart, - colorEnd, - colorStart - ) + // Compose-safe gradient color list + val shimmerColors = remember(colorStart, colorEnd) { + listOf(colorStart, colorEnd, colorStart) + } + + // Prevent crash: verify color list is valid before creating Brush + if (shimmerColors.size < 2) return val infiniteTransition = rememberInfiniteTransition(label = "") @@ -64,3 +70,13 @@ fun ShimmerEffect( ) } } + +@DefaultPreviews +@Composable +fun ShimmerEffectPreview() { + ShimmerEffect( + modifier = Modifier + .width(164.dp) + .height(18.dp) + ) +} diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/RelationValueListWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/RelationValueListWidget.kt index a493997295..ab8f649d22 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/RelationValueListWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/RelationValueListWidget.kt @@ -20,6 +20,7 @@ import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType import com.anytypeio.anytype.presentation.objects.ObjectIcon import com.anytypeio.anytype.presentation.relations.ObjectRelationView import com.anytypeio.anytype.presentation.sets.model.ObjectView +import timber.log.Timber class RelationValueListWidget @JvmOverloads constructor( context: Context, @@ -418,27 +419,35 @@ class RelationValueListWidget @JvmOverloads constructor( private fun setLinksRelation(relation: ObjectRelationView.Links) { when (relation) { is ObjectRelationView.Links.From -> { - val count = context.resources.getQuantityString( - R.plurals.links_from_count, - relation.count, - relation.count - ) - setupSingleTextItem( - name = count, - textColor = textColorPrimary - ) + try { + val count = context.resources.getQuantityString( + R.plurals.links_from_count, + relation.count, + relation.count + ) + setupSingleTextItem( + name = count, + textColor = textColorPrimary + ) + } catch (e: Exception) { + Timber.e(e, "Error while trying to show links in featured properties") + } } is ObjectRelationView.Links.Backlinks -> { - val count = context.resources.getQuantityString( - R.plurals.backlinks_count, - relation.count, - relation.count - ) - setupSingleTextItem( - name = count, - textColor = textColorPrimary - ) + try { + val count = context.resources.getQuantityString( + R.plurals.backlinks_count, + relation.count, + relation.count + ) + setupSingleTextItem( + name = count, + textColor = textColorPrimary + ) + } catch (e: Exception) { + Timber.e(e, "Error while trying to show backlinks in featured properties") + } } } } diff --git a/localization/src/main/res/values/strings.xml b/localization/src/main/res/values/strings.xml index 4d8ce350b5..e7b1c28bb8 100644 --- a/localization/src/main/res/values/strings.xml +++ b/localization/src/main/res/values/strings.xml @@ -1265,13 +1265,13 @@ - $d backlinks + %d backlinks %d backlink %d backlinks - $d links + %d links %d link %d links