kopia lustrzana https://github.com/ryukoposting/Signal-Android
Track tab buttons' selected state in the ViewModel.
rodzic
80a6e0f781
commit
c6bfdeb4b0
|
@ -69,21 +69,19 @@ class ConversationListTabsFragment : Fragment(R.layout.conversation_list_tabs) {
|
|||
}
|
||||
|
||||
private fun update(state: ConversationListTabsState, immediate: Boolean) {
|
||||
val wasChatSelected = chatsIcon.isSelected
|
||||
|
||||
chatsIcon.isSelected = state.tab == ConversationListTab.CHATS
|
||||
chatsPill.isSelected = state.tab == ConversationListTab.CHATS
|
||||
|
||||
storiesIcon.isSelected = state.tab == ConversationListTab.STORIES
|
||||
storiesPill.isSelected = state.tab == ConversationListTab.STORIES
|
||||
|
||||
chatsPill.isSelected = chatsIcon.isSelected
|
||||
storiesPill.isSelected = storiesIcon.isSelected
|
||||
|
||||
val hasStateChange = chatsIcon.isSelected xor wasChatSelected
|
||||
val hasStateChange = state.tab != state.prevTab
|
||||
if (immediate) {
|
||||
chatsIcon.pauseAnimation()
|
||||
storiesIcon.pauseAnimation()
|
||||
|
||||
chatsIcon.progress = if (chatsIcon.isSelected) 1f else 0f
|
||||
storiesIcon.progress = if (storiesIcon.isSelected) 1f else 0f
|
||||
chatsIcon.progress = if (state.tab == ConversationListTab.CHATS) 1f else 0f
|
||||
storiesIcon.progress = if (state.tab == ConversationListTab.STORIES) 1f else 0f
|
||||
|
||||
runPillAnimation(0, chatsPill, storiesPill)
|
||||
} else if (hasStateChange) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.stories.tabs
|
|||
|
||||
data class ConversationListTabsState(
|
||||
val tab: ConversationListTab = ConversationListTab.CHATS,
|
||||
val prevTab: ConversationListTab = ConversationListTab.STORIES,
|
||||
val unreadChatsCount: Long = 0L,
|
||||
val unreadStoriesCount: Long = 0L,
|
||||
val visibilityState: VisibilityState = VisibilityState()
|
||||
|
|
|
@ -37,12 +37,12 @@ class ConversationListTabsViewModel(repository: ConversationListTabRepository) :
|
|||
|
||||
fun onChatsSelected() {
|
||||
internalTabClickEvents.onNext(ConversationListTab.CHATS)
|
||||
store.update { it.copy(tab = ConversationListTab.CHATS) }
|
||||
store.update { it.copy(tab = ConversationListTab.CHATS, prevTab = it.tab) }
|
||||
}
|
||||
|
||||
fun onStoriesSelected() {
|
||||
internalTabClickEvents.onNext(ConversationListTab.STORIES)
|
||||
store.update { it.copy(tab = ConversationListTab.STORIES) }
|
||||
store.update { it.copy(tab = ConversationListTab.STORIES, prevTab = it.tab) }
|
||||
}
|
||||
|
||||
fun onSearchOpened() {
|
||||
|
|
Ładowanie…
Reference in New Issue