forked from upstream-mirrors/quik
Fix color for tabs and material swatch
This commit is contained in:
@@ -28,10 +28,12 @@ import android.widget.TextView
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import injection.appComponent
|
||||
import common.util.Colors
|
||||
import common.util.extensions.forEach
|
||||
import injection.appComponent
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.tab_view.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -39,6 +41,8 @@ class PagerTitleView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
|
||||
@Inject lateinit var colors: Colors
|
||||
|
||||
private val threadId: Subject<Long> = BehaviorSubject.create()
|
||||
|
||||
var pager: ViewPager? = null
|
||||
set(value) {
|
||||
if (field !== value) {
|
||||
@@ -51,6 +55,10 @@ class PagerTitleView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
if (!isInEditMode) appComponent.inject(this)
|
||||
}
|
||||
|
||||
fun setThreadId(id: Long) {
|
||||
threadId.onNext(id)
|
||||
}
|
||||
|
||||
private fun recreate() {
|
||||
removeAllViews()
|
||||
|
||||
@@ -78,8 +86,12 @@ class PagerTitleView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
intArrayOf(android.R.attr.state_selected),
|
||||
intArrayOf(-android.R.attr.state_selected))
|
||||
|
||||
val theme = threadId
|
||||
.distinctUntilChanged()
|
||||
.switchMap { threadId -> colors.themeForConversation(threadId) }
|
||||
|
||||
Observables
|
||||
.combineLatest(colors.theme, colors.textSecondary, { theme, textSecondary ->
|
||||
.combineLatest(theme, colors.textSecondary, { theme, textSecondary ->
|
||||
ColorStateList(states, intArrayOf(theme, textSecondary))
|
||||
})
|
||||
.autoDisposable(scope())
|
||||
|
||||
@@ -75,6 +75,8 @@ class ThemePickerActivity : QkThemedActivity<ThemePickerViewModel>(), ThemePicke
|
||||
}
|
||||
|
||||
override fun render(state: ThemePickerState) {
|
||||
tabs.setThreadId(state.threadId)
|
||||
|
||||
themeAdapter.threadId = state.threadId
|
||||
|
||||
applyGroup.setVisible(state.applyThemeVisible)
|
||||
@@ -84,5 +86,6 @@ class ThemePickerActivity : QkThemedActivity<ThemePickerViewModel>(), ThemePicke
|
||||
|
||||
override fun setCurrentTheme(color: Int) {
|
||||
picker.setColor(color)
|
||||
themeAdapter.selectedColor = color
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user