diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-04 16:08:03 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-07-04 16:08:03 -0700 |
commit | cf2a7fcd0880a8d276970124cdb5d5845d5631fe (patch) | |
tree | cc38ead7853ddb85c9c988e94a4af605e1e676f8 /core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt | |
parent | fe4632c34a1d671503e0242a269865b884545e13 (diff) | |
download | kau-cf2a7fcd0880a8d276970124cdb5d5845d5631fe.tar.gz kau-cf2a7fcd0880a8d276970124cdb5d5845d5631fe.tar.bz2 kau-cf2a7fcd0880a8d276970124cdb5d5845d5631fe.zip |
Separate core components in its own module
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt')
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt new file mode 100644 index 0000000..03a1605 --- /dev/null +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt @@ -0,0 +1,20 @@ +package ca.allanwang.kau.utils + +import android.content.Context +import android.content.res.ColorStateList +import android.graphics.Color +import android.graphics.drawable.Drawable +import android.support.annotation.ColorInt +import com.mikepenz.iconics.IconicsDrawable +import com.mikepenz.iconics.typeface.IIcon + +/** + * Created by Allan Wang on 2017-05-29. + */ +@KauUtils fun IIcon.toDrawable(c: Context, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE, builder: IconicsDrawable.() -> Unit = {}): Drawable { + val state = ColorStateList.valueOf(color) + val icon = IconicsDrawable(c).icon(this).sizeDp(sizeDp) + icon.setTintList(state) + icon.builder() + return icon +}
\ No newline at end of file |