Skip to content

Native Android client for Spotify, built with Jetpack Compose

The Classic search field follows the dark theme (#157): it was painted white with black text; a browse page of podcasts keeps its shows and episodes (test)

kota-zoe0968c3cdb0a
diff --git a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/BrowseCategoryTest.kt b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/BrowseCategoryTest.kt
new file mode 100644
index 00000000..bb378bd3
--- /dev/null
+++ b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/BrowseCategoryTest.kt
@@ -0,0 +1,49 @@
+package app.myspoti.spotify
+
+import app.myspoti.api.MediaKind
+import app.myspoti.spotify.bridge.Bridge
+import app.myspoti.spotify.gql.Gql
+import kotlinx.coroutines.runBlocking
+import kotlinx.serialization.json.JsonElement
+import kotlinx.serialization.json.JsonObject
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Test
+
+/** A browseCategory page (`browsePage`, as the Podcasts and Documentaries categories open) keeps its shows and episodes. */
+class BrowseCategoryTest {
+ private class PageGql(val answer: JsonElement) : Gql {
+ override suspend fun query(name: String, variables: JsonObject): JsonElement = answer
+ }
+
+ // Sanitised shape: a podcast category holds show and episode cards only.
+ private val answer = Bridge.json.parseToJsonElement("""
+ {"data":{"browse":{"__typename":"BrowseSectionContainer","uri":"spotify:page:test",
+ "header":{"title":{"transformedLabel":"Podcasts"}},
+ "sections":{"items":[
+ {"__typename":"BrowseSection","uri":"spotify:section:shows",
+ "data":{"__typename":"BrowseGenericSectionData","title":{"transformedLabel":"Popular podcasts"}},
+ "sectionItems":{"totalCount":2,"items":[
+ {"content":{"__typename":"PodcastResponseWrapper","data":{"__typename":"Podcast",
+ "name":"Show A","uri":"spotify:show:AAAAAAAAAAAAAAAAAAAAAA","publisher":{"name":"Publisher A"}}}},
+ {"content":{"__typename":"PodcastResponseWrapper","data":{"__typename":"Podcast",
+ "name":"Show B","uri":"spotify:show:BBBBBBBBBBBBBBBBBBBBBB","publisher":{"name":"Publisher B"}}}}
+ ]}},
+ {"__typename":"BrowseSection","uri":"spotify:section:episodes",
+ "data":{"__typename":"BrowseGenericSectionData","title":{"transformedLabel":"Latest episodes"}},
+ "sectionItems":{"items":[
+ {"content":{"__typename":"EpisodeResponseWrapper","data":{"__typename":"Episode",
+ "name":"Episode 1","uri":"spotify:episode:EEEEEEEEEEEEEEEEEEEEEE",
+ "podcastV2":{"__typename":"PodcastResponseWrapper","data":{"__typename":"Podcast","name":"Show A"}}}}}
+ ]}}
+ ]}}}}
+ """.trimIndent())
+
+ @Test
+ fun `podcast category keeps its shows and episodes`() = runBlocking {
+ val page = SpotifyHome(PageGql(answer)).category("spotify:page:test")
+ val cards = page.shelves.flatMap { it.items }
+ assertEquals(listOf("Show A", "Show B", "Episode 1"), cards.map { it.title })
+ assertEquals(listOf(MediaKind.SHOW, MediaKind.SHOW, MediaKind.EPISODE), cards.map { it.kind })
+ assertEquals("Show A", cards[2].subtitle)
+ }
+}
diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/SearchScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/SearchScreen.kt
index 7006ae6b..e538eb64 100644
--- a/base/app/src/main/java/com/music/spotui/ui/screens/SearchScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/SearchScreen.kt
@@ -884,12 +884,12 @@ fun SearchStickyBar(
.weight(1f)
.clip(RoundedCornerShape(10.dp))
.height(55.dp)
- .background(Color.White)
+ .background(tone(0xFF2A2A2A))
.padding(10.dp, 0.dp)
){
Icon(
painterResource(id = R.drawable.ic_search_big),
- tint = Color.Black,
+ tint = AppText,
contentDescription = "")
TextField(
@@ -900,7 +900,7 @@ fun SearchStickyBar(
.focusRequester(fieldFocus)
.onFocusChanged { onFocusChange(it.isFocused) },
value = text,
- textStyle = TextStyle.Default.copy(fontSize = 16.sp, color = Color.Black, fontWeight = FontWeight(500)),
+ textStyle = TextStyle.Default.copy(fontSize = 16.sp, color = AppText, fontWeight = FontWeight(500)),
colors = TextFieldDefaults.colors(
unfocusedContainerColor = Color.Transparent,
disabledContainerColor = Color.Transparent,
@@ -908,7 +908,9 @@ fun SearchStickyBar(
disabledIndicatorColor = Color.Transparent,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
- cursorColor = Color.Black
+ focusedTextColor = AppText,
+ unfocusedTextColor = AppText,
+ cursorColor = AppPalette
),
singleLine = true,
@@ -922,7 +924,7 @@ fun SearchStickyBar(
)
},
trailingIcon = if (text.isEmpty()) null else {
- { SearchClearButton(fieldFocus, Color.Black) { onTextChange("") } }
+ { SearchClearButton(fieldFocus, AppText) { onTextChange("") } }
},
)
}