You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, dealing with icons in Jetpack Compose can involve handling both ImageVector and DrawableRes icons separately. It would be convenient to have some extensions or utility functions that simplify working with icons, allowing users to seamlessly switch between ImageVector and DrawableRes icons without the need for explicit conversions.
Describe the solution
Add extensions or utility functions to the Icon class in the dev.teogor.ceres.ui.foundation.graphics package to provide easy access to icons using both ImageVector and DrawableRes.
Example Usage:
// Create an Icon using ImageVectorval imageVectorIcon =Icons.Filled.Wallpaper.asImageVectorIcon()
// Create an Icon using DrawableResval drawableResIcon =R.drawable.ic_wallpaper.asDrawableResourceIcon()
Additional context
No response
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
That seems like a more efficient approach for generating the Icon type class. We are planning to implement this enhancement in our next release.
// IconExtensions.ktpackagedev.teogor.ceres.ui.foundation.graphicsimportandroidx.annotation.DrawableResimportandroidx.compose.material.icons.Iconsimportandroidx.compose.material.icons.filled.Wallpaperimportandroidx.compose.ui.graphics.vector.ImageVector/** * Extension function to create an Icon using ImageVector. * @receiver The ImageVector you want to use as an Icon. * @return An ImageVectorIcon.*/fun ImageVector.asImageVectorIcon(): Icon.ImageVectorIcon {
returnIcon.ImageVectorIcon(this)
}
/** * Extension function to create an Icon using a DrawableRes. * @receiver The DrawableRes identifier you want to use as an Icon. * @return A DrawableResourceIcon.*/fun Int.asDrawableResourceIcon(): Icon.DrawableResourceIcon {
returnIcon.DrawableResourceIcon(this)
}
// Example usage:// val imageVectorIcon = Icons.Filled.Wallpaper.asImageVectorIcon()// val drawableResIcon = R.drawable.ic_wallpaper.asDrawableResourceIcon()
Is there an existing issue for this?
Describe the problem
Currently, dealing with icons in Jetpack Compose can involve handling both
ImageVector
andDrawableRes
icons separately. It would be convenient to have some extensions or utility functions that simplify working with icons, allowing users to seamlessly switch betweenImageVector
andDrawableRes
icons without the need for explicit conversions.Describe the solution
Add extensions or utility functions to the
Icon
class in thedev.teogor.ceres.ui.foundation.graphics
package to provide easy access to icons using bothImageVector
andDrawableRes
.Example Usage:
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: