11package org.wordpress.android.viewmodel.posts
22
3- import androidx.annotation.DrawableRes
43import org.wordpress.android.R
54import org.wordpress.android.fluxc.store.ListStore.ListError
65import org.wordpress.android.fluxc.store.ListStore.ListErrorType.PERMISSION_ERROR
@@ -15,19 +14,19 @@ import org.wordpress.android.ui.utils.UiString.UiStringRes
1514
1615sealed 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}
0 commit comments