All caught up screen

This commit is contained in:
Benoit Marty 2019-05-29 15:29:02 +02:00
parent 241ee1cb9d
commit 9da727b623
5 changed files with 78 additions and 25 deletions

View File

@ -62,19 +62,19 @@ class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet?

private fun update(newState: State) {
when (newState) {
is StateView.State.Content -> {
is State.Content -> {
progressBar.visibility = View.INVISIBLE
errorView.visibility = View.INVISIBLE
emptyView.visibility = View.INVISIBLE
contentView?.visibility = View.VISIBLE
}
is StateView.State.Loading -> {
is State.Loading -> {
progressBar.visibility = View.VISIBLE
errorView.visibility = View.INVISIBLE
emptyView.visibility = View.INVISIBLE
contentView?.visibility = View.INVISIBLE
}
is StateView.State.Empty -> {
is State.Empty -> {
progressBar.visibility = View.INVISIBLE
errorView.visibility = View.INVISIBLE
emptyView.visibility = View.VISIBLE
@ -85,7 +85,7 @@ class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
contentView!!.visibility = View.INVISIBLE
}
}
is StateView.State.Error -> {
is State.Error -> {
progressBar.visibility = View.INVISIBLE
errorView.visibility = View.VISIBLE
emptyView.visibility = View.INVISIBLE

View File

@ -19,12 +19,14 @@ package im.vector.riotredesign.features.home.room.list
import android.os.Bundle
import android.os.Parcelable
import androidx.annotation.StringRes
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.airbnb.mvrx.*
import com.google.android.material.floatingactionbutton.FloatingActionButton
import im.vector.matrix.android.api.failure.Failure
import im.vector.matrix.android.api.session.room.model.Membership
import im.vector.matrix.android.api.session.room.model.RoomSummary
import im.vector.riotredesign.R
import im.vector.riotredesign.core.epoxy.LayoutManagerStateRestorer
@ -149,17 +151,38 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Callback {
}

private fun renderEmptyState(allRooms: List<RoomSummary>?) {
val hasNoRoom = allRooms.isNullOrEmpty()
val hasNoRoom = allRooms
?.filter {
it.membership == Membership.JOIN || it.membership == Membership.INVITE
}
.isNullOrEmpty()
val emptyState = when (roomListParams.displayMode) {
DisplayMode.HOME -> {
if (hasNoRoom) {
StateView.State.Empty(getString(R.string.room_list_catchup_welcome_title), null, getString(R.string.room_list_catchup_welcome_body))
StateView.State.Empty(
getString(R.string.room_list_catchup_welcome_title),
ContextCompat.getDrawable(requireContext(), R.drawable.ic_home_bottom_catchup),
getString(R.string.room_list_catchup_welcome_body)
)
} else {
StateView.State.Empty(getString(R.string.room_list_catchup_empty_title), null, getString(R.string.room_list_catchup_empty_body))
StateView.State.Empty(
getString(R.string.room_list_catchup_empty_title),
ContextCompat.getDrawable(requireContext(), R.drawable.ic_noun_party_popper),
getString(R.string.room_list_catchup_empty_body))
}
}
DisplayMode.PEOPLE -> StateView.State.Empty()
DisplayMode.ROOMS -> StateView.State.Empty()
DisplayMode.PEOPLE ->
StateView.State.Empty(
getString(R.string.room_list_people_empty_title),
ContextCompat.getDrawable(requireContext(), R.drawable.ic_home_bottom_chat),
getString(R.string.room_list_people_empty_body)
)
DisplayMode.ROOMS ->
StateView.State.Empty(
getString(R.string.room_list_rooms_empty_title),
ContextCompat.getDrawable(requireContext(), R.drawable.ic_home_bottom_group),
getString(R.string.room_list_rooms_empty_body)
)
}
stateView.state = emptyState
}

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportWidth="64"
android:viewportHeight="64">
<path
android:pathData="M62.382,26.685c-10.46,-2.55 -18.09,-0.21 -23,2.6 -0.82,-1 -1.68,-1.91 -2.58,-2.81 -0.9,-0.9 -1.79,-1.79 -2.74,-2.56a26.81,26.81 0,0 0,3.42 -20.23,2 2,0 1,0 -3.9,0.87 22.93,22.93 0,0 1,-2.67 16.93c-5.05,-3.46 -10.18,-5.07 -13.08,-2.64l-0.32,0.26a2,2 0,0 0,-0.22 0.27,5.05 5.05,0 0,0 -1.12,2.6l-16,38.57a2,2 0,0 0,1.74 2.81,1.89 1.89,0 0,0 0.77,-0.15l38.56,-16a5.06,5.06 0,0 0,2.6 -1.13,1.51 1.51,0 0,0 0.28,-0.22c0.1,-0.094 0.188,-0.202 0.26,-0.32 2.41,-2.88 0.85,-7.95 -2.56,-13 4.23,-2.28 10.73,-4.12 19.58,-2a2,2 0,0 0,0.98 -3.85zM22.682,50.585l-3.05,-18.38a42.26,42.26 0,0 0,5.18 6.26,37.92 37.92,0 0,0 9.7,7.22l-11.83,4.9zM12.312,54.875l-1.58,-9.52 5,-12.08 3.18,18.86 -6.6,2.74zM7.832,52.325l0.68,4.12 -2.89,1.24 2.21,-5.36zM41.482,42.745l-1.26,0.52c-2.31,-0.05 -7.31,-2.32 -12.58,-7.58 -5.27,-5.26 -7.58,-10.31 -7.64,-12.59l0.52,-1.26a2,2 0,0 1,0.8 -0.14c1.45,0 4.11,1 7.27,3.11a19.35,19.35 0,0 1,-2.2 2.33,2 2,0 0,0 2.59,3.05 24.05,24.05 0,0 0,2.77 -2.94c0.74,0.64 1.48,1.33 2.24,2.08 0.76,0.75 1.45,1.51 2.08,2.25a20.09,20.09 0,0 0,-3.32 3.24,2 2,0 0,0 0.38,2.8 2,2 0,0 0,2.78 -0.43,17.14 17.14,0 0,1 2.61,-2.5c2.64,3.89 3.48,7 2.96,8.06zM43.482,20.125l10.3,-10.34a2.001,2.001 0,0 1,2.83 2.83l-10.33,10.34a2,2 0,0 1,-1.42 0.58,2 2,0 0,1 -1.41,-0.58 2,2 0,0 1,0 -2.83h0.03zM42.322,2.215a2.01,2.01 0,1 1,4 -0.41l0.74,7.09a2,2 0,0 1,-1.78 2.2h-0.21a2,2 0,0 1,-2 -1.79l-0.75,-7.09z"
android:fillColor="#7E899C"
android:fillType="nonZero"/>
</vector>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -15,11 +16,11 @@

<LinearLayout
android:id="@+id/errorView"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp">
android:padding="@dimen/layout_horizontal_margin">

<TextView
android:id="@+id/errorMessageView"
@ -44,39 +45,54 @@
</LinearLayout>


<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/emptyView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp">
android:padding="@dimen/layout_horizontal_margin">

<TextView
android:id="@+id/emptyTitleView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="49dp"
android:gravity="center"
android:textColor="@android:color/black"
android:textSize="16sp" />
android:textColor="#2E2F32"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/emptyImageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="@string/room_list_catchup_empty_title" />

<ImageView
android:id="@+id/emptyImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp" />
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center_horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_noun_party_popper" />

<TextView
android:id="@+id/emptyMessageView"
android:layout_width="wrap_content"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="49dp"
android:gravity="center"
android:textColor="@android:color/black"
android:textSize="16sp" />
android:textColor="#7E899C"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/emptyImageView"
tools:text="@string/room_list_catchup_empty_body" />

</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

</merge>

View File

@ -11,6 +11,10 @@
<string name="room_list_catchup_empty_body">You have no more unread messages</string>
<string name="room_list_catchup_welcome_title">Welcome home!</string>
<string name="room_list_catchup_welcome_body">Catch up on unread messages here</string>
<string name="room_list_people_empty_title">Conversations</string>
<string name="room_list_people_empty_body">Your direct message conversation will be displayed here</string>
<string name="room_list_rooms_empty_title">Rooms</string>
<string name="room_list_rooms_empty_body">Your rooms will be displayed here</string>

<string name="title_activity_emoji_reaction_picker">Reactions</string>
<string name="reactions_agree">Agree</string>