Show message when list is empty

This commit is contained in:
Maxime NATUREL 2022-12-30 14:57:37 +01:00
parent e0b77936c1
commit bd9c53a96c
4 changed files with 31 additions and 5 deletions

View File

@ -3191,7 +3191,8 @@
<string name="open_poll_option_description">Voters see results as soon as they have voted</string>
<string name="closed_poll_option_title">Closed poll</string>
<string name="closed_poll_option_description">Results are only revealed when you end the poll</string>
<string name="active_polls">Active polls</string>
<string name="room_polls_active">Active polls</string>
<string name="room_polls_active_no_item">There are no active polls in this room</string>
<!-- Location -->
<string name="location_activity_title_static_sharing">Share location</string>

View File

@ -66,7 +66,7 @@ class RoomPollsFragment : VectorBaseFragment<FragmentRoomPollsBinding>() {
tabLayoutMediator = TabLayoutMediator(views.roomPollsTabs, views.roomPollsViewPager) { tab, position ->
when (position) {
0 -> tab.text = getString(R.string.active_polls)
0 -> tab.text = getString(R.string.room_polls_active)
}
}.also { it.attach() }
}

View File

@ -20,9 +20,11 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import com.airbnb.mvrx.parentFragmentViewModel
import com.airbnb.mvrx.withState
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.R
import im.vector.app.core.extensions.cleanup
import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.VectorBaseFragment
@ -55,7 +57,8 @@ class RoomActivePollsFragment :
private fun setupList() {
roomActivePollsController.listener = this
views.activePollsList.configureWith(roomActivePollsController)
views.roomPollsList.configureWith(roomActivePollsController)
views.roomPollsEmptyTitle.text = getString(R.string.room_polls_active_no_item)
}
override fun onDestroyView() {
@ -64,7 +67,7 @@ class RoomActivePollsFragment :
}
private fun cleanUpList() {
views.activePollsList.cleanup()
views.roomPollsList.cleanup()
roomActivePollsController.listener = null
}
@ -79,6 +82,7 @@ class RoomActivePollsFragment :
private fun renderList(polls: List<PollSummary.ActivePoll>) {
roomActivePollsController.setData(polls)
views.roomPollsEmptyTitle.isVisible = polls.isEmpty()
}
override fun onPollClicked(pollId: String) {

View File

@ -6,7 +6,7 @@
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/activePollsList"
android:id="@+id/roomPollsList"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginHorizontal="@dimen/layout_horizontal_margin"
@ -17,5 +17,26 @@
tools:itemCount="5"
tools:listitem="@layout/item_poll_active" />
<TextView
android:id="@+id/roomPollsEmptyTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/layout_horizontal_margin"
android:layout_marginBottom="@dimen/layout_vertical_margin"
android:gravity="center"
android:textAppearance="@style/TextAppearance.Vector.Body"
android:textColor="?vctr_content_secondary"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/roomPollsEmptyGuideline"
tools:text="@string/room_polls_active_no_item" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/roomPollsEmptyGuideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.33" />
</androidx.constraintlayout.widget.ConstraintLayout>