Skip to content

Commit

Permalink
Merge pull request #263 from yourssu/feature/rein/icon-contentDescrip…
Browse files Browse the repository at this point in the history
…tion

[YDS-#262] YDS Icon에 contentDescription 속성 추가
  • Loading branch information
kangyuri1114 committed Mar 20, 2024
2 parents 703db93 + 5854fd0 commit dac24b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.yourssu.design.system.compose.foundation.LocalYdsContentColor
Expand All @@ -29,48 +33,61 @@ sealed class IconSize(val value: Dp) {
fun Icon(
@DrawableRes id: Int,
modifier: Modifier = Modifier,
contentDescription: String? = null,
iconSize: IconSize = IconSize.Medium,
tint: Color = LocalYdsContentColor.current,
) {
Icon(
imageVector = ImageVector.vectorResource(id = id),
modifier = modifier,
contentDescription = contentDescription,
iconSize = iconSize,
tint = tint
tint = tint,
)
}

@Composable
fun Icon(
imageVector: ImageVector,
modifier: Modifier = Modifier,
contentDescription: String? = null,
iconSize: IconSize = IconSize.Medium,
tint: Color = LocalYdsContentColor.current,
) {
Icon(
painter = rememberVectorPainter(imageVector),
contentDescription = contentDescription,
modifier = modifier,
iconSize = iconSize,
tint = tint
tint = tint,
)
}

@Composable
fun Icon(
painter: Painter,
contentDescription: String?,
modifier: Modifier = Modifier,
iconSize: IconSize = IconSize.Medium,
tint: Color = LocalYdsContentColor.current,
) {
val colorFilter = ColorFilter.tint(tint)
val semantics = if (contentDescription != null) {
Modifier.semantics {
this.contentDescription = contentDescription
this.role = Role.Image
}
} else {
Modifier
}
Box(
modifier
.toolingGraphicsLayer()
.size(iconSize.value)
.paint(
painter = painter,
colorFilter = colorFilter,
contentScale = ContentScale.Fit
)
contentScale = ContentScale.Fit,
).then(semantics),
)
}
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
versionName=2.5.6
versionName=2.5.7
#자동 배포를 위해서 버전은 여기 한 군데에서 관리하면 된다

0 comments on commit dac24b8

Please sign in to comment.