diff options
author | Allan Wang <me@allanwang.ca> | 2020-02-23 16:06:45 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2020-02-23 16:06:45 -0800 |
commit | c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc (patch) | |
tree | 0841d112c8c00504ce10ca72ef39e403b69c595c /app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt | |
parent | 4d5aaf541dbfa7d521ebbc5f011a642c83c4b9c5 (diff) | |
download | frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.tar.gz frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.tar.bz2 frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.zip |
Move prefs to service locator
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt index 097aea32..bc5c6bcc 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt @@ -30,6 +30,8 @@ import ca.allanwang.kau.utils.withAlpha import com.mikepenz.iconics.typeface.IIcon import com.pitchedapps.frost.databinding.ViewBadgedIconBinding import com.pitchedapps.frost.utils.Prefs +import org.koin.core.KoinComponent +import org.koin.core.inject /** * Created by Allan Wang on 2017-06-19. @@ -38,8 +40,10 @@ class BadgedIcon @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr) { +) : ConstraintLayout(context, attrs, defStyleAttr), KoinComponent { + + private val prefs: Prefs by inject() private val binding: ViewBadgedIconBinding = ViewBadgedIconBinding.inflate(LayoutInflater.from(context), this, true) @@ -49,7 +53,7 @@ class BadgedIcon @JvmOverloads constructor( fun ViewBadgedIconBinding.init() { val badgeColor = - Prefs.mainActivityLayout.backgroundColor().withAlpha(255).colorToForeground(0.2f) + prefs.mainActivityLayout.backgroundColor(prefs).withAlpha(255).colorToForeground(0.2f) val badgeBackground = GradientDrawable( GradientDrawable.Orientation.BOTTOM_TOP, @@ -57,7 +61,7 @@ class BadgedIcon @JvmOverloads constructor( ) badgeBackground.cornerRadius = 13.dpToPx.toFloat() badgeText.background = badgeBackground - badgeText.setTextColor(Prefs.mainActivityLayout.iconColor()) + badgeText.setTextColor(prefs.mainActivityLayout.iconColor(prefs)) } var iicon: IIcon? = null @@ -67,13 +71,13 @@ class BadgedIcon @JvmOverloads constructor( value?.toDrawable( context, sizeDp = 20, - color = Prefs.mainActivityLayout.iconColor() + color = prefs.mainActivityLayout.iconColor(prefs) ) ) } fun setAllAlpha(alpha: Float) { - // badgeTextView.setTextColor(Prefs.textColor.withAlpha(alpha.toInt())) + // badgeTextView.setTextColor(prefs.textColor.withAlpha(alpha.toInt())) binding.badgeImage.drawable.alpha = alpha.toInt() } |