aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-04 16:08:03 -0700
committerAllan Wang <me@allanwang.ca>2017-07-04 16:08:03 -0700
commitcf2a7fcd0880a8d276970124cdb5d5845d5631fe (patch)
treecc38ead7853ddb85c9c988e94a4af605e1e676f8 /core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt
parentfe4632c34a1d671503e0242a269865b884545e13 (diff)
downloadkau-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.kt20
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