Skip to content

Commit

Permalink
Show message when list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaturel committed Jan 4, 2023
1 parent e0b7793 commit bd9c53a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
3 changes: 2 additions & 1 deletion library/ui-strings/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -64,7 +67,7 @@ class RoomActivePollsFragment :
}

private fun cleanUpList() {
views.activePollsList.cleanup()
views.roomPollsList.cleanup()
roomActivePollsController.listener = null
}

Expand All @@ -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) {
Expand Down
23 changes: 22 additions & 1 deletion vector/src/main/res/layout/fragment_room_polls_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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>

0 comments on commit bd9c53a

Please sign in to comment.