Title changes on going back to all chats
This commit is contained in:
parent
a0baf77438
commit
947cd8fceb
@ -150,6 +150,15 @@ class HomeDetailFragment @Inject constructor(
|
||||
toggleModalVisibility()
|
||||
}
|
||||
|
||||
views.backButtonLayout.setOnClickListener {
|
||||
val currentSpace = sharedActionViewModel.space.value
|
||||
val directParent = currentSpace?.spaceParents?.firstOrNull()
|
||||
viewModel.handleSelectSpace(directParent?.roomSummary)
|
||||
sharedActionViewModel.space.value = directParent?.roomSummary
|
||||
sharedActionViewModel.post(HomeActivitySharedAction.OpenGroup(false))
|
||||
onSpaceChange(directParent?.roomSummary)
|
||||
}
|
||||
|
||||
views.dimView.setOnClickListener {
|
||||
toggleModalVisibility()
|
||||
}
|
||||
@ -205,25 +214,33 @@ class HomeDetailFragment @Inject constructor(
|
||||
|
||||
private fun observeSharedActions() = lifecycleScope.launch {
|
||||
sharedActionViewModel.stream().collect { action ->
|
||||
when(action) {
|
||||
is HomeActivitySharedAction.OpenGroup -> toggleModalVisibility()
|
||||
else -> Unit
|
||||
when (action) {
|
||||
is HomeActivitySharedAction.OpenGroup -> hideModal()
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleModalVisibility() {
|
||||
if (views.spaceModalFragment.isVisible) {
|
||||
views.spaceModalFragment.isVisible = false
|
||||
views.dimView.isVisible = false
|
||||
views.toolbarChevron.rotation = 0F
|
||||
hideModal()
|
||||
} else {
|
||||
views.spaceModalFragment.isVisible = true
|
||||
views.dimView.isVisible = true
|
||||
views.toolbarChevron.rotation = 90F
|
||||
showModal()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showModal() {
|
||||
views.spaceModalFragment.isVisible = true
|
||||
views.dimView.isVisible = true
|
||||
views.toolbarChevron.rotation = 90F
|
||||
}
|
||||
|
||||
private fun hideModal() {
|
||||
views.spaceModalFragment.isVisible = false
|
||||
views.dimView.isVisible = false
|
||||
views.toolbarChevron.rotation = 0F
|
||||
}
|
||||
|
||||
private fun handleCallStarted() {
|
||||
dismissLoadingDialog()
|
||||
val fragmentTag = HomeTab.DialPad.toFragmentTag()
|
||||
@ -312,8 +329,11 @@ class HomeDetailFragment @Inject constructor(
|
||||
}
|
||||
|
||||
private fun onGroupChange(groupSummary: GroupSummary?) {
|
||||
hideModal()
|
||||
if (groupSummary == null) {
|
||||
views.groupToolbarSpaceTitleView.isVisible = false
|
||||
views.groupToolbarSpaceTitleView.text = getString(R.string.all_chats)
|
||||
views.groupToolbarTitleView.text = getString(R.string.all_chats)
|
||||
} else {
|
||||
views.groupToolbarSpaceTitleView.isVisible = true
|
||||
views.groupToolbarSpaceTitleView.text = groupSummary.displayName
|
||||
@ -322,8 +342,11 @@ class HomeDetailFragment @Inject constructor(
|
||||
}
|
||||
|
||||
private fun onSpaceChange(spaceSummary: RoomSummary?) {
|
||||
hideModal()
|
||||
if (spaceSummary == null) {
|
||||
views.groupToolbarSpaceTitleView.isVisible = false
|
||||
views.groupToolbarSpaceTitleView.text = getString(R.string.all_chats)
|
||||
views.groupToolbarTitleView.text = getString(R.string.all_chats)
|
||||
} else {
|
||||
views.groupToolbarSpaceTitleView.isVisible = true
|
||||
views.groupToolbarSpaceTitleView.text = spaceSummary.displayName
|
||||
|
@ -29,6 +29,7 @@ import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.core.extensions.singletonEntryPoint
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.features.VectorOverrides
|
||||
import im.vector.app.features.analytics.plan.Interaction
|
||||
import im.vector.app.features.call.dialpad.DialPadLookup
|
||||
import im.vector.app.features.call.lookup.CallProtocolsChecker
|
||||
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
||||
@ -36,7 +37,10 @@ import im.vector.app.features.createdirect.DirectRoomHelper
|
||||
import im.vector.app.features.invite.AutoAcceptInvites
|
||||
import im.vector.app.features.invite.showInvites
|
||||
import im.vector.app.features.settings.VectorDataStore
|
||||
import im.vector.app.features.spaces.SpaceListAction
|
||||
import im.vector.app.features.spaces.SpaceListViewEvents
|
||||
import im.vector.app.features.ui.UiStateRepository
|
||||
import im.vector.app.space
|
||||
import im.vector.lib.core.utils.flow.throttleFirst
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
@ -52,6 +56,7 @@ import org.matrix.android.sdk.api.session.crypto.NewSessionListener
|
||||
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
|
||||
import org.matrix.android.sdk.api.session.room.RoomSortOrder
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
@ -215,6 +220,10 @@ class HomeDetailViewModel @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun handleSelectSpace(space: RoomSummary?) {
|
||||
appStateHandler.setCurrentSpace(space?.roomId)
|
||||
}
|
||||
|
||||
private fun observeRoomSummaries() {
|
||||
appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged().flatMapLatest {
|
||||
// we use it as a trigger to all changes in room, but do not really load
|
||||
|
@ -24,5 +24,5 @@ import javax.inject.Inject
|
||||
|
||||
class HomeSharedActionViewModel @Inject constructor(val session: Session) : VectorSharedActionViewModel<HomeActivitySharedAction>() {
|
||||
|
||||
val space = MutableLiveData<RoomSummary>()
|
||||
val space = MutableLiveData<RoomSummary?>()
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class SpaceListModalFragment : VectorBaseFragment<FragmentSpaceListModalBinding>
|
||||
}
|
||||
}
|
||||
|
||||
private fun observeSpaceChange() = sharedActionViewModel.space.observeNotNull(viewLifecycleOwner) {
|
||||
private fun observeSpaceChange() = sharedActionViewModel.space.observe(viewLifecycleOwner) {
|
||||
viewModel.setSpace(it)
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa
|
||||
}
|
||||
}
|
||||
|
||||
fun setSpace(space: RoomSummary) {
|
||||
fun setSpace(space: RoomSummary?) {
|
||||
this.currentSpace = space
|
||||
emitSpaceViewState()
|
||||
}
|
||||
|
@ -121,29 +121,38 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_button_chevron"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/ic_arrow_right"
|
||||
android:rotation="180"
|
||||
app:layout_constraintTop_toTopOf="@id/back_button_text"
|
||||
app:layout_constraintBottom_toBottomOf="@id/back_button_text"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:tint="@color/palette_element_green" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/back_button_text"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/back_button_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/chats"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textSize="17sp"
|
||||
android:textColor="@color/palette_element_green"
|
||||
app:layout_constraintStart_toEndOf="@id/back_button_chevron"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_button_chevron"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/ic_arrow_right"
|
||||
android:rotation="180"
|
||||
app:layout_constraintTop_toTopOf="@id/back_button_text"
|
||||
app:layout_constraintBottom_toBottomOf="@id/back_button_text"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:tint="@color/palette_element_green" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/back_button_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/chats"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textSize="17sp"
|
||||
android:textColor="@color/palette_element_green"
|
||||
app:layout_constraintStart_toEndOf="@id/back_button_chevron"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/all_chats_layout"
|
||||
@ -151,7 +160,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/back_button_chevron"
|
||||
app:layout_constraintTop_toBottomOf="@id/back_button_layout"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<TextView
|
||||
|
Loading…
Reference in New Issue
Block a user