Skip to content

Commit

Permalink
Fix tall browse screenshot (#2272)
Browse files Browse the repository at this point in the history
* Fix tall browse screenshot

* 馃 reformat

* 馃 Updates screenshots

---------

Co-authored-by: yschimke <[email protected]>
  • Loading branch information
yschimke and yschimke committed Jun 14, 2024
1 parent e714ec3 commit 32a62bd
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,80 +54,100 @@ public fun PlaylistDownloadBrowseScreen(
BrowseScreen(
modifier = modifier,
) {
val downloadsSectionState = when (browseScreenState) {
BrowseScreenState.Loading -> Section.State.Loading
is BrowseScreenState.Loaded -> {
if (browseScreenState.downloadList.isEmpty()) {
Section.State.Empty
} else {
Section.State.Loaded(browseScreenState.downloadList)
}
}
PlaylistDownloadBrowseScreenContent(
browseScreenState,
onDownloadItemClick,
onDownloadItemInProgressClick,
onPlaylistsClick,
onSettingsClick,
downloadItemArtworkPlaceholder,
onDownloadItemInProgressClickActionLabel,
)
}
}

BrowseScreenState.Failed ->
// display empty state
internal fun BrowseScreenScope.PlaylistDownloadBrowseScreenContent(
browseScreenState: BrowseScreenState,
onDownloadItemClick: (PlaylistDownloadUiModel) -> Unit,
onDownloadItemInProgressClick: (PlaylistDownloadUiModel) -> Unit,
onPlaylistsClick: () -> Unit,
onSettingsClick: () -> Unit,
downloadItemArtworkPlaceholder: Painter? = null,
onDownloadItemInProgressClickActionLabel: String? = null,
) {
val downloadsSectionState = when (browseScreenState) {
BrowseScreenState.Loading -> Section.State.Loading
is BrowseScreenState.Loaded -> {
if (browseScreenState.downloadList.isEmpty()) {
Section.State.Empty
} else {
Section.State.Loaded(browseScreenState.downloadList)
}
}

downloadsSection(state = downloadsSectionState) {
loading {
PlaceholderChip(colors = ChipDefaults.secondaryChipColors())
}
BrowseScreenState.Failed ->
// display empty state
Section.State.Empty
}

loaded { download: PlaylistDownloadUiModel ->
when (download) {
is PlaylistDownloadUiModel.Completed -> {
Chip(
label = download.playlistUiModel.title,
onClick = { onDownloadItemClick(download) },
icon = CoilPaintable(
download.playlistUiModel.artworkUri,
downloadItemArtworkPlaceholder,
),
largeIcon = true,
colors = ChipDefaults.secondaryChipColors(),
)
}
downloadsSection(state = downloadsSectionState) {
loading {
PlaceholderChip(colors = ChipDefaults.secondaryChipColors())
}

is PlaylistDownloadUiModel.InProgress -> {
val customModifier = onDownloadItemInProgressClickActionLabel?.let {
Modifier.semantics {
onClick(
label = onDownloadItemInProgressClickActionLabel,
action = null,
)
}
} ?: Modifier
loaded { download: PlaylistDownloadUiModel ->
when (download) {
is PlaylistDownloadUiModel.Completed -> {
Chip(
label = download.playlistUiModel.title,
onClick = { onDownloadItemClick(download) },
icon = CoilPaintable(
download.playlistUiModel.artworkUri,
downloadItemArtworkPlaceholder,
),
largeIcon = true,
colors = ChipDefaults.secondaryChipColors(),
)
}

Chip(
label = download.playlistUiModel.title,
onClick = { onDownloadItemInProgressClick(download) },
modifier = customModifier,
secondaryLabel = stringResource(
id = R.string.horologist_browse_downloads_progress,
download.percentage,
),
icon = Icons.Default.Downloading.asPaintable(),
colors = ChipDefaults.secondaryChipColors(),
)
}
is PlaylistDownloadUiModel.InProgress -> {
val customModifier = onDownloadItemInProgressClickActionLabel?.let {
Modifier.semantics {
onClick(
label = onDownloadItemInProgressClickActionLabel,
action = null,
)
}
} ?: Modifier

Chip(
label = download.playlistUiModel.title,
onClick = { onDownloadItemInProgressClick(download) },
modifier = customModifier,
secondaryLabel = stringResource(
id = R.string.horologist_browse_downloads_progress,
download.percentage,
),
icon = Icons.Default.Downloading.asPaintable(),
colors = ChipDefaults.secondaryChipColors(),
)
}
}
}
}

playlistsSection(
buttons = listOf(
BrowseScreenPlaylistsSectionButton(
textId = R.string.horologist_browse_library_playlists_button,
icon = Icons.AutoMirrored.Default.PlaylistPlay,
onClick = onPlaylistsClick,
),
BrowseScreenPlaylistsSectionButton(
textId = R.string.horologist_browse_library_settings_button,
icon = Icons.Default.Settings,
onClick = onSettingsClick,
),
playlistsSection(
buttons = listOf(
BrowseScreenPlaylistsSectionButton(
textId = R.string.horologist_browse_library_playlists_button,
icon = Icons.AutoMirrored.Default.PlaylistPlay,
onClick = onPlaylistsClick,
),
)
}
BrowseScreenPlaylistsSectionButton(
textId = R.string.horologist_browse_library_settings_button,
icon = Icons.Default.Settings,
onClick = onSettingsClick,
),
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ package com.google.android.horologist.media.ui.screens.browse

import androidx.wear.compose.foundation.lazy.ScalingLazyColumnDefaults.scalingParams
import androidx.wear.compose.foundation.lazy.ScalingParams
import com.google.android.horologist.composables.SectionedList
import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults
import com.google.android.horologist.compose.layout.ScalingLazyColumnState
import com.google.android.horologist.compose.layout.rememberResponsiveColumnState
import com.google.android.horologist.media.ui.PlayerLibraryPreview
import com.google.android.horologist.compose.layout.ScreenScaffold
import com.google.android.horologist.compose.layout.rememberColumnState
import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest
import org.junit.Test
import org.robolectric.annotation.Config

@Config(
sdk = [33],
qualifiers = "w227dp-h400dp-small-notlong-notround-watch-xhdpi-keyshidden-nonav",
qualifiers = "w227dp-h330dp-small-notlong-notround-watch-xhdpi-keyshidden-nonav",
)
class PlaylistDownloadBrowseScreenA11yTallScreenshotTest : WearLegacyA11yTest() {

Expand All @@ -38,21 +40,28 @@ class PlaylistDownloadBrowseScreenA11yTallScreenshotTest : WearLegacyA11yTest()
val screenState = BrowseScreenState.Loaded(downloadList)

runScreenTest {
val columnState: ScalingLazyColumnState = rememberResponsiveColumnState().copy(
val columnState = rememberColumnState(
factory = ScalingLazyColumnDefaults.belowTimeText(),
).copy(
scalingParams = scalingParams(
edgeScale = 1f,
edgeAlpha = 1f,
),
)

PlayerLibraryPreview(columnState = columnState, round = false) {
PlaylistDownloadBrowseScreen(
browseScreenState = screenState,
onDownloadItemClick = { },
onDownloadItemInProgressClick = { },
onPlaylistsClick = { },
onSettingsClick = { },
onDownloadItemInProgressClickActionLabel = "cancel",
ScreenScaffold(scrollState = columnState) {
SectionedList(
columnState = columnState,
sections = BrowseScreenScope().apply {
PlaylistDownloadBrowseScreenContent(
browseScreenState = screenState,
onDownloadItemClick = { },
onDownloadItemInProgressClick = { },
onPlaylistsClick = { },
onSettingsClick = { },
onDownloadItemInProgressClickActionLabel = "cancel",
)
}.sections,
)
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 32a62bd

Please sign in to comment.