Adds invites text to modal
This commit is contained in:
parent
89db0645a5
commit
a158d9866d
@ -28,10 +28,12 @@ import dagger.hilt.android.AndroidEntryPoint
|
|||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.platform.VectorBaseFragment
|
import im.vector.app.core.platform.VectorBaseFragment
|
||||||
import im.vector.app.databinding.FragmentSpaceListModalBinding
|
import im.vector.app.databinding.FragmentSpaceListModalBinding
|
||||||
|
import im.vector.app.features.home.room.list.UnreadCounterBadgeView
|
||||||
import im.vector.app.features.spaces.SpaceListAction
|
import im.vector.app.features.spaces.SpaceListAction
|
||||||
import im.vector.app.features.spaces.SpaceListViewModel
|
import im.vector.app.features.spaces.SpaceListViewModel
|
||||||
import im.vector.app.features.spaces.manage.ManageType
|
import im.vector.app.features.spaces.manage.ManageType
|
||||||
import im.vector.app.features.spaces.manage.SpaceManageActivity
|
import im.vector.app.features.spaces.manage.SpaceManageActivity
|
||||||
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@ -92,6 +94,9 @@ class SpaceListModalFragment : VectorBaseFragment<FragmentSpaceListModalBinding>
|
|||||||
(binding.roomList.adapter as SpaceListAdapter).replaceList(it)
|
(binding.roomList.adapter as SpaceListAdapter).replaceList(it)
|
||||||
binding.noSpacesYetGroup.isVisible = it.isEmpty()
|
binding.noSpacesYetGroup.isVisible = it.isEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.invitesGroup.isVisible = state.inviteCount > 0
|
||||||
|
binding.counterBadge.render(UnreadCounterBadgeView.State(state.inviteCount, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa
|
|||||||
)
|
)
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
homeAggregateCount = counts
|
homeAggregateCount = counts,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,19 +285,16 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa
|
|||||||
displayName = QueryStringValue.IsNotEmpty
|
displayName = QueryStringValue.IsNotEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
combine(
|
combine(session.flow().liveSpaceSummaries(params),
|
||||||
session.flow()
|
|
||||||
.liveSpaceSummaries(params),
|
|
||||||
session.accountDataService()
|
session.accountDataService()
|
||||||
.getLiveRoomAccountDataEvents(setOf(RoomAccountDataTypes.EVENT_TYPE_SPACE_ORDER))
|
.getLiveRoomAccountDataEvents(setOf(RoomAccountDataTypes.EVENT_TYPE_SPACE_ORDER))
|
||||||
.asFlow()
|
.asFlow()
|
||||||
) { spaces, _ ->
|
) { spaces, _ -> spaces }.execute { async ->
|
||||||
spaces
|
|
||||||
}.execute { async ->
|
|
||||||
asyncSpaceList = async
|
asyncSpaceList = async
|
||||||
val currentSpaceChildren = currentSpace?.let { space -> async.invoke()?.filter { it.flattenParentIds.contains(space.roomId) } }
|
val currentSpaceChildren = currentSpace?.let { space -> async.invoke()?.filter { it.flattenParentIds.contains(space.roomId) } }
|
||||||
val rootSpaces = async.invoke().orEmpty().filter { it.flattenParentIds.isEmpty() }
|
val rootSpaces = async.invoke().orEmpty().filter { it.flattenParentIds.isEmpty() }
|
||||||
val displaySpaces = currentSpaceChildren ?: rootSpaces
|
val displaySpaces = (currentSpaceChildren ?: rootSpaces).filter { it.inviterId == null }
|
||||||
|
val inviteSpaces = (currentSpaceChildren ?: rootSpaces).filter { it.inviterId != null }
|
||||||
val orders = displaySpaces.associate {
|
val orders = displaySpaces.associate {
|
||||||
it.roomId to session.getRoom(it.roomId)
|
it.roomId to session.getRoom(it.roomId)
|
||||||
?.roomAccountDataService()
|
?.roomAccountDataService()
|
||||||
@ -308,6 +305,8 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa
|
|||||||
copy(
|
copy(
|
||||||
asyncSpaces = async,
|
asyncSpaces = async,
|
||||||
rootSpacesOrdered = displaySpaces.sortedWith(TopLevelSpaceComparator(orders)),
|
rootSpacesOrdered = displaySpaces.sortedWith(TopLevelSpaceComparator(orders)),
|
||||||
|
inviteSpaces = inviteSpaces.sortedWith(TopLevelSpaceComparator(orders)),
|
||||||
|
inviteCount = inviteSpaces.size,
|
||||||
spaceOrderInfo = orders
|
spaceOrderInfo = orders
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -326,7 +325,8 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa
|
|||||||
private fun emitSpaceViewState() = asyncSpaceList?.let { async ->
|
private fun emitSpaceViewState() = asyncSpaceList?.let { async ->
|
||||||
val currentSpaceChildren = currentSpace?.let { space -> asyncSpaceList?.invoke()?.filter { it.flattenParentIds.contains(space.roomId) } }
|
val currentSpaceChildren = currentSpace?.let { space -> asyncSpaceList?.invoke()?.filter { it.flattenParentIds.contains(space.roomId) } }
|
||||||
val rootSpaces = asyncSpaceList?.invoke().orEmpty().filter { it.flattenParentIds.isEmpty() }
|
val rootSpaces = asyncSpaceList?.invoke().orEmpty().filter { it.flattenParentIds.isEmpty() }
|
||||||
val displaySpaces = currentSpaceChildren ?: rootSpaces
|
val displaySpaces = (currentSpaceChildren ?: rootSpaces).filter { it.inviterId == null }
|
||||||
|
val inviteSpaces = (currentSpaceChildren ?: rootSpaces).filter { it.inviterId != null }
|
||||||
val orders = displaySpaces.associate {
|
val orders = displaySpaces.associate {
|
||||||
it.roomId to session.getRoom(it.roomId)
|
it.roomId to session.getRoom(it.roomId)
|
||||||
?.roomAccountDataService()
|
?.roomAccountDataService()
|
||||||
@ -338,6 +338,8 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa
|
|||||||
copy(
|
copy(
|
||||||
asyncSpaces = async,
|
asyncSpaces = async,
|
||||||
rootSpacesOrdered = displaySpaces.sortedWith(TopLevelSpaceComparator(orders)),
|
rootSpacesOrdered = displaySpaces.sortedWith(TopLevelSpaceComparator(orders)),
|
||||||
|
inviteSpaces = inviteSpaces.sortedWith(TopLevelSpaceComparator(orders)),
|
||||||
|
inviteCount = inviteSpaces.size,
|
||||||
spaceOrderInfo = orders
|
spaceOrderInfo = orders
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,11 @@ data class SpaceListViewState(
|
|||||||
val asyncSpaces: Async<List<RoomSummary>> = Uninitialized,
|
val asyncSpaces: Async<List<RoomSummary>> = Uninitialized,
|
||||||
val selectedGroupingMethod: RoomGroupingMethod = RoomGroupingMethod.BySpace(null),
|
val selectedGroupingMethod: RoomGroupingMethod = RoomGroupingMethod.BySpace(null),
|
||||||
val rootSpacesOrdered: List<RoomSummary>? = null,
|
val rootSpacesOrdered: List<RoomSummary>? = null,
|
||||||
|
val inviteSpaces: List<RoomSummary>? = null,
|
||||||
val spaceOrderInfo: Map<String, String?>? = null,
|
val spaceOrderInfo: Map<String, String?>? = null,
|
||||||
val spaceOrderLocalEchos: Map<String, String?>? = null,
|
val spaceOrderLocalEchos: Map<String, String?>? = null,
|
||||||
val legacyGroups: List<GroupSummary>? = null,
|
val legacyGroups: List<GroupSummary>? = null,
|
||||||
val expandedStates: Map<String, Boolean> = emptyMap(),
|
val expandedStates: Map<String, Boolean> = emptyMap(),
|
||||||
|
val inviteCount: Int = 0,
|
||||||
val homeAggregateCount: RoomAggregateNotificationCount = RoomAggregateNotificationCount(0, 0)
|
val homeAggregateCount: RoomAggregateNotificationCount = RoomAggregateNotificationCount(0, 0)
|
||||||
) : MavericksState
|
) : MavericksState
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/bg_space_modal">
|
android:background="@drawable/bg_space_modal">
|
||||||
|
|
||||||
<FrameLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/header_text_layout"
|
android:id="@+id/header_text_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -28,7 +28,45 @@
|
|||||||
android:text="@string/choose_a_space"
|
android:text="@string/choose_a_space"
|
||||||
android:textAllCaps="true" />
|
android:textAllCaps="true" />
|
||||||
|
|
||||||
</FrameLayout>
|
<androidx.constraintlayout.widget.Group
|
||||||
|
android:id="@+id/invites_group"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:constraint_referenced_ids="invites_text, counter_badge"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/invites_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textSize="13sp"
|
||||||
|
android:textColor="?attr/vctr_content_tertiary"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:text="@string/invites"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/counter_badge" />
|
||||||
|
|
||||||
|
<im.vector.app.features.home.room.list.UnreadCounterBadgeView
|
||||||
|
android:id="@+id/counter_badge"
|
||||||
|
style="@style/Widget.Vector.TextView.Micro"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:minWidth="16dp"
|
||||||
|
android:minHeight="16dp"
|
||||||
|
android:paddingStart="4dp"
|
||||||
|
android:paddingEnd="4dp"
|
||||||
|
android:textColor="?colorOnError"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/invites_text"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/invites_text"
|
||||||
|
tools:background="@drawable/bg_unread_highlight"
|
||||||
|
tools:text="147" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/room_list"
|
android:id="@+id/room_list"
|
||||||
|
@ -3039,6 +3039,7 @@
|
|||||||
<string name="screen_sharing_notification_description">Screen sharing is in progress</string>
|
<string name="screen_sharing_notification_description">Screen sharing is in progress</string>
|
||||||
<string name="all_chats">All Chats</string>
|
<string name="all_chats">All Chats</string>
|
||||||
<string name="choose_a_space">Spaces</string>
|
<string name="choose_a_space">Spaces</string>
|
||||||
|
<string name="invites">Invites</string>
|
||||||
<string name="chats">Chats</string>
|
<string name="chats">Chats</string>
|
||||||
<string name="no_spaces_yet">No spaces yet</string>
|
<string name="no_spaces_yet">No spaces yet</string>
|
||||||
<string name="no_spaces_yet_message">Add spaces to group your chats</string>
|
<string name="no_spaces_yet_message">Add spaces to group your chats</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user