Skip to content

Commit 7bf1e4c

Browse files
authored
CMM-1037 Postlist empty view (#22407)
* Removed illustration from empty view, added subtitle * Added named arguments * Removed unused image resource * Wrap empty published message * Added button to trashed posts empty view, to match pages * Fixed missing space * Removed new line
1 parent 8100f0a commit 7bf1e4c

File tree

5 files changed

+24
-91
lines changed

5 files changed

+24
-91
lines changed

WordPress/src/main/java/org/wordpress/android/ui/posts/PostListFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class PostListFragment : ViewPagerFragment() {
215215
if (state.emptyViewVisible) {
216216
emptyView.visibility = View.VISIBLE
217217
uiHelpers.setTextOrHide(emptyView.title, state.title)
218-
uiHelpers.setImageOrHide(emptyView.image, state.imgResId)
218+
uiHelpers.setTextOrHide(emptyView.subtitle, state.subtitle)
219219
setupButtonOrHide(emptyView.button, state.buttonText, state.onButtonClick)
220220
} else {
221221
emptyView.visibility = View.GONE

WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListEmptyUiState.kt

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.wordpress.android.viewmodel.posts
22

3-
import androidx.annotation.DrawableRes
43
import org.wordpress.android.R
54
import org.wordpress.android.fluxc.store.ListStore.ListError
65
import org.wordpress.android.fluxc.store.ListStore.ListErrorType.PERMISSION_ERROR
@@ -15,19 +14,19 @@ import org.wordpress.android.ui.utils.UiString.UiStringRes
1514

1615
sealed class PostListEmptyUiState(
1716
val title: UiString? = null,
18-
@DrawableRes val imgResId: Int? = null,
17+
val subtitle: UiString? = null,
1918
val buttonText: UiString? = null,
2019
val onButtonClick: (() -> Unit)? = null,
2120
val emptyViewVisible: Boolean = true
2221
) {
2322
class EmptyList(
2423
title: UiString,
24+
subtitle: UiString? = null,
2525
buttonText: UiString? = null,
2626
onButtonClick: (() -> Unit)? = null,
27-
@DrawableRes imageResId: Int = R.drawable.img_illustration_posts_75dp
2827
) : PostListEmptyUiState(
2928
title = title,
30-
imgResId = imageResId,
29+
subtitle = subtitle,
3130
buttonText = buttonText,
3231
onButtonClick = onButtonClick
3332
)
@@ -36,7 +35,6 @@ sealed class PostListEmptyUiState(
3635

3736
object Loading : PostListEmptyUiState(
3837
title = UiStringRes(R.string.posts_fetching),
39-
imgResId = R.drawable.img_illustration_posts_75dp
4038
)
4139

4240
class RefreshError(
@@ -45,14 +43,12 @@ sealed class PostListEmptyUiState(
4543
onButtonClick: (() -> Unit)? = null
4644
) : PostListEmptyUiState(
4745
title = title,
48-
imgResId = R.drawable.img_illustration_empty_results_216dp,
4946
buttonText = buttonText,
5047
onButtonClick = onButtonClick
5148
)
5249

5350
object PermissionsError : PostListEmptyUiState(
5451
title = UiStringRes(R.string.error_refresh_unauthorized_posts),
55-
imgResId = R.drawable.img_illustration_posts_75dp
5652
)
5753
}
5854

@@ -121,19 +117,20 @@ private fun createEmptyListUiState(
121117
): PostListEmptyUiState.EmptyList {
122118
return when (postListType) {
123119
PUBLISHED -> PostListEmptyUiState.EmptyList(
124-
UiStringRes(R.string.posts_published_empty),
125-
UiStringRes(R.string.posts_empty_list_button),
126-
newPost
120+
title = UiStringRes(R.string.posts_published_empty),
121+
subtitle = UiStringRes(R.string.posts_published_empty_subtitle),
122+
buttonText = UiStringRes(R.string.posts_empty_list_button),
123+
onButtonClick = newPost
127124
)
128125
DRAFTS -> PostListEmptyUiState.EmptyList(
129-
UiStringRes(R.string.posts_draft_empty),
130-
UiStringRes(R.string.posts_empty_list_button),
131-
newPost
126+
title = UiStringRes(R.string.posts_draft_empty),
127+
buttonText = UiStringRes(R.string.posts_empty_list_button),
128+
onButtonClick = newPost
132129
)
133130
SCHEDULED -> PostListEmptyUiState.EmptyList(
134-
UiStringRes(R.string.posts_scheduled_empty),
135-
UiStringRes(R.string.posts_empty_list_button),
136-
newPost
131+
title = UiStringRes(R.string.posts_scheduled_empty),
132+
buttonText = UiStringRes(R.string.posts_empty_list_button),
133+
onButtonClick = newPost
137134
)
138135
SEARCH -> {
139136
val messageResId = if (isSearchPromptRequired) {
@@ -142,8 +139,14 @@ private fun createEmptyListUiState(
142139
R.string.post_list_search_nothing_found
143140
}
144141

145-
PostListEmptyUiState.EmptyList(title = UiStringRes(messageResId), imageResId = 0)
142+
PostListEmptyUiState.EmptyList(title = UiStringRes(messageResId))
143+
}
144+
TRASHED -> {
145+
PostListEmptyUiState.EmptyList(
146+
title = UiStringRes(R.string.posts_trashed_empty),
147+
buttonText = UiStringRes(R.string.posts_empty_list_button),
148+
onButtonClick = newPost
149+
)
146150
}
147-
TRASHED -> PostListEmptyUiState.EmptyList(UiStringRes(R.string.posts_trashed_empty))
148151
}
149152
}

WordPress/src/main/res/drawable/img_illustration_posts_75dp.xml

Lines changed: 0 additions & 70 deletions
This file was deleted.

WordPress/src/main/res/layout/post_list_fragment.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
android:layout_height="match_parent"
2929
android:visibility="gone"
3030
app:aevButton="@string/posts_empty_list_button"
31-
app:aevImage="@drawable/img_illustration_posts_75dp"
3231
app:aevTitle="@string/posts_empty_list"
3332
tools:visibility="visible" />
3433

WordPress/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@
288288
<string name="posts_empty_list">No posts yet. Why not create one?</string>
289289
<string name="posts_empty_list_button">Create a post</string>
290290
<string name="empty_list_default">This list is empty</string>
291-
<string name="posts_published_empty">You haven\'t published any posts yet</string>
291+
<string name="posts_published_empty">You haven\'t published any posts - yet!</string>
292+
<string name="posts_published_empty_subtitle">Why not create one?</string>
292293
<string name="posts_scheduled_empty">You don\'t have any scheduled posts</string>
293294
<string name="posts_draft_empty">You don\'t have any draft posts</string>
294295
<string name="posts_trashed_empty">You don\'t have any trashed posts</string>

0 commit comments

Comments
 (0)