mikepenz / Android-Iconics

Android-Iconics - Use any icon font, or vector (.svg) as drawable in your application.
https://mikepenz.dev
Apache License 2.0
5.16k stars 619 forks source link

Compose Image is ignoring `size` modifier #638

Open Nek-12 opened 9 months ago

Nek-12 commented 9 months ago

About this issue

For the following composable

RIcon ```kotlin @Composable fun RIcon( icon: IIcon, modifier: Modifier = Modifier, size: Dp = Size.icon, color: Color = Color.Unspecified, respectFontBounds: Boolean = false, // needed to align some icons correctly ) { Image( asset = icon, modifier = modifier.requiredSizeIn(maxWidth = size, maxHeight = size), alignment = Alignment.Center, contentScale = ContentScale.Fit, iconicsConfig = IconicsConfig( respectFontBounds = respectFontBounds, iconBrush = SolidColor(color.takeOrElse { LocalContentColor.current }), paddingDp = 1, ), ) } ```

When using sizeIn(maxWidth, maxHeight), the modifier is ignored and icons spill outside of the composable bounds.requiredSizeIn fixes the issue but breaks animations & other Material widgets that want to resize the icon composable.
We need a proper solution for sizing icons without using requiredSize.

Why is this and how can this be fixed? Using respectFontBounds = true is not possible because that breaks alignment of icons in the container.

Details

Checklist

mikepenz commented 8 months ago

Thank you very much for the report Unfortunately, I currently don't have the capacity to look into this, I'd be more than happy to review a PR for it though