forked from upstream-mirrors/quik
Remove all constants from Colors, only use observables
This commit is contained in:
@@ -25,6 +25,18 @@ class Colors @Inject constructor(context: Context, prefs: Preferences) {
|
||||
.map { dark -> if (dark) R.color.backgroundDark else R.color.backgroundLight }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
|
||||
val textPrimary: Observable<Int> = prefs.dark.asObservable()
|
||||
.map { dark -> if (dark) R.color.textPrimaryLight else R.color.textPrimary }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
|
||||
val textSecondary: Observable<Int> = prefs.dark.asObservable()
|
||||
.map { dark -> if (dark) R.color.textSecondaryLight else R.color.textSecondary }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
|
||||
val textTertiary: Observable<Int> = prefs.dark.asObservable()
|
||||
.map { dark -> if (dark) R.color.textTertiaryLight else R.color.textTertiary }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
|
||||
val bubble: Observable<Int> = prefs.dark.asObservable()
|
||||
.map { dark -> if (dark) R.color.bubbleDark else R.color.bubbleLight }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
@@ -45,8 +57,4 @@ class Colors @Inject constructor(context: Context, prefs: Preferences) {
|
||||
.map { dark -> if (dark) R.color.switch_track_disabled_dark else R.color.switch_track_disabled_light }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
|
||||
val textPrimary = 0xFF49555F.toInt()
|
||||
val textSecondary = 0xFF70808D.toInt()
|
||||
val textTertiary = 0xFFB7B9C0.toInt()
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import com.moez.QKSMS.data.model.Contact
|
||||
import com.moez.QKSMS.data.model.Message
|
||||
import com.moez.QKSMS.presentation.base.QkActivity
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
@@ -76,8 +77,10 @@ class ComposeActivity : QkActivity<ComposeViewModel>(), ComposeView {
|
||||
intArrayOf(android.R.attr.state_enabled),
|
||||
intArrayOf(-android.R.attr.state_enabled))
|
||||
|
||||
disposables += colors.theme
|
||||
.map { color -> ColorStateList(states, intArrayOf(color, colors.textTertiary)) }
|
||||
disposables += Observables
|
||||
.combineLatest(colors.theme, colors.textTertiary, { theme, textTertiary ->
|
||||
ColorStateList(states, intArrayOf(theme, textTertiary))
|
||||
})
|
||||
.subscribe { tintList -> send.imageTintList = tintList }
|
||||
|
||||
disposables += colors.background
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.moez.QKSMS.common.di.appComponent
|
||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||
import com.moez.QKSMS.presentation.Navigator
|
||||
import com.moez.QKSMS.presentation.base.QkActivity
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
@@ -85,7 +86,12 @@ class MainActivity : QkActivity<MainViewModel>(), MainView {
|
||||
|
||||
disposables += colors.theme
|
||||
.doOnNext { color -> compose.setBackgroundTint(color) }
|
||||
.map { color -> ColorStateList(states, intArrayOf(color, colors.textSecondary)) }
|
||||
.subscribe()
|
||||
|
||||
disposables += Observables
|
||||
.combineLatest(colors.theme, colors.textSecondary, { theme, textSecondary ->
|
||||
ColorStateList(states, intArrayOf(theme, textSecondary))
|
||||
})
|
||||
.doOnNext { tintList -> inboxIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> archivedIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> scheduledIcon.imageTintList = tintList }
|
||||
|
||||
Reference in New Issue
Block a user