|
|
@ -49,7 +49,6 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
|
|
|
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
|
|
|
|
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
|
|
|
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|
|
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|
|
|
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaLoadingWheel
|
|
|
|
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaLoadingWheel
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews
|
|
|
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.TrackScrollJank
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.TrackScrollJank
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.newsFeed
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.newsFeed
|
|
|
@ -119,25 +118,24 @@ fun BookmarksScreen(
|
|
|
|
** The [Column] is handling the Empty state when the feed is empty.
|
|
|
|
** The [Column] is handling the Empty state when the feed is empty.
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
if (feedState is NewsFeedUiState.Success && feedState.feed.isEmpty()) {
|
|
|
|
if (feedState is NewsFeedUiState.Success && feedState.feed.isEmpty()) {
|
|
|
|
OnEmptyStateView()
|
|
|
|
EmptyState()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
private fun OnEmptyStateView() {
|
|
|
|
private fun EmptyState() {
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.padding(start = 16.dp, end = 16.dp)
|
|
|
|
.padding(16.dp)
|
|
|
|
.fillMaxSize()
|
|
|
|
.fillMaxSize()
|
|
|
|
.testTag("bookmarks:empty"),
|
|
|
|
.testTag("bookmarks:empty"),
|
|
|
|
verticalArrangement = Arrangement.Center,
|
|
|
|
verticalArrangement = Arrangement.Center,
|
|
|
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
|
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
Image(
|
|
|
|
Image(
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
|
.fillMaxWidth(),
|
|
|
|
painter = painterResource(id = R.drawable.img_empty_bookmarks),
|
|
|
|
painter = painterResource(id = R.drawable.img_no_bookmarks_error),
|
|
|
|
contentDescription = null
|
|
|
|
contentDescription = stringResource(id = R.string.bookmarks_empty_description),
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
Spacer(modifier = Modifier.height(16.dp))
|
|
|
|
Spacer(modifier = Modifier.height(16.dp))
|
|
|
@ -145,8 +143,7 @@ private fun OnEmptyStateView() {
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
|
text = stringResource(id = R.string.bookmarks_empty_error),
|
|
|
|
text = stringResource(id = R.string.bookmarks_empty_error),
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
|
.fillMaxWidth(),
|
|
|
|
|
|
|
|
style = MaterialTheme.typography.titleMedium,
|
|
|
|
style = MaterialTheme.typography.titleMedium,
|
|
|
|
fontWeight = FontWeight.Bold
|
|
|
|
fontWeight = FontWeight.Bold
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -156,19 +153,8 @@ private fun OnEmptyStateView() {
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
|
text = stringResource(id = R.string.bookmarks_empty_description),
|
|
|
|
text = stringResource(id = R.string.bookmarks_empty_description),
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
|
.fillMaxWidth(),
|
|
|
|
|
|
|
|
style = MaterialTheme.typography.bodyMedium
|
|
|
|
style = MaterialTheme.typography.bodyMedium
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@DevicePreviews
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
|
|
|
fun ShowErrorPreview() {
|
|
|
|
|
|
|
|
BookmarksScreen(
|
|
|
|
|
|
|
|
feedState = NewsFeedUiState.Success(emptyList()),
|
|
|
|
|
|
|
|
removeFromBookmarks = {},
|
|
|
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|