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) {
|
private fun update(state: ConversationListTabsState, immediate: Boolean) {
|
||||||
val wasChatSelected = chatsIcon.isSelected
|
|
||||||
|
|
||||||
chatsIcon.isSelected = state.tab == ConversationListTab.CHATS
|
chatsIcon.isSelected = state.tab == ConversationListTab.CHATS
|
||||||
|
chatsPill.isSelected = state.tab == ConversationListTab.CHATS
|
||||||
|
|
||||||
storiesIcon.isSelected = state.tab == ConversationListTab.STORIES
|
storiesIcon.isSelected = state.tab == ConversationListTab.STORIES
|
||||||
|
storiesPill.isSelected = state.tab == ConversationListTab.STORIES
|
||||||
|
|
||||||
chatsPill.isSelected = chatsIcon.isSelected
|
val hasStateChange = state.tab != state.prevTab
|
||||||
storiesPill.isSelected = storiesIcon.isSelected
|
|
||||||
|
|
||||||
val hasStateChange = chatsIcon.isSelected xor wasChatSelected
|
|
||||||
if (immediate) {
|
if (immediate) {
|
||||||
chatsIcon.pauseAnimation()
|
chatsIcon.pauseAnimation()
|
||||||
storiesIcon.pauseAnimation()
|
storiesIcon.pauseAnimation()
|
||||||
|
|
||||||
chatsIcon.progress = if (chatsIcon.isSelected) 1f else 0f
|
chatsIcon.progress = if (state.tab == ConversationListTab.CHATS) 1f else 0f
|
||||||
storiesIcon.progress = if (storiesIcon.isSelected) 1f else 0f
|
storiesIcon.progress = if (state.tab == ConversationListTab.STORIES) 1f else 0f
|
||||||
|
|
||||||
runPillAnimation(0, chatsPill, storiesPill)
|
runPillAnimation(0, chatsPill, storiesPill)
|
||||||
} else if (hasStateChange) {
|
} else if (hasStateChange) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.stories.tabs
|
||||||
|
|
||||||
data class ConversationListTabsState(
|
data class ConversationListTabsState(
|
||||||
val tab: ConversationListTab = ConversationListTab.CHATS,
|
val tab: ConversationListTab = ConversationListTab.CHATS,
|
||||||
|
val prevTab: ConversationListTab = ConversationListTab.STORIES,
|
||||||
val unreadChatsCount: Long = 0L,
|
val unreadChatsCount: Long = 0L,
|
||||||
val unreadStoriesCount: Long = 0L,
|
val unreadStoriesCount: Long = 0L,
|
||||||
val visibilityState: VisibilityState = VisibilityState()
|
val visibilityState: VisibilityState = VisibilityState()
|
||||||
|
|
|
@ -37,12 +37,12 @@ class ConversationListTabsViewModel(repository: ConversationListTabRepository) :
|
||||||
|
|
||||||
fun onChatsSelected() {
|
fun onChatsSelected() {
|
||||||
internalTabClickEvents.onNext(ConversationListTab.CHATS)
|
internalTabClickEvents.onNext(ConversationListTab.CHATS)
|
||||||
store.update { it.copy(tab = ConversationListTab.CHATS) }
|
store.update { it.copy(tab = ConversationListTab.CHATS, prevTab = it.tab) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onStoriesSelected() {
|
fun onStoriesSelected() {
|
||||||
internalTabClickEvents.onNext(ConversationListTab.STORIES)
|
internalTabClickEvents.onNext(ConversationListTab.STORIES)
|
||||||
store.update { it.copy(tab = ConversationListTab.STORIES) }
|
store.update { it.copy(tab = ConversationListTab.STORIES, prevTab = it.tab) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onSearchOpened() {
|
fun onSearchOpened() {
|
||||||
|
|
Ładowanie…
Reference in New Issue