Skip to content

Commit 070a166

Browse files
committed
feat: show highlight over filtered text in Details screens
except for listens for now #1472
1 parent 1785429 commit 070a166

File tree

29 files changed

+350
-173
lines changed

29 files changed

+350
-173
lines changed

shared/feature/collections/src/commonMain/kotlin/ly/david/musicsearch/shared/feature/collections/components/CollectionListItem.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import androidx.compose.material3.MaterialTheme
1111
import androidx.compose.material3.Text
1212
import androidx.compose.runtime.Composable
1313
import androidx.compose.ui.Modifier
14+
import androidx.compose.ui.text.SpanStyle
15+
import androidx.compose.ui.text.buildAnnotatedString
16+
import androidx.compose.ui.text.withStyle
1417
import androidx.compose.ui.unit.dp
1518
import ly.david.musicsearch.shared.domain.listitem.CollectionListItemModel
1619
import ly.david.musicsearch.ui.common.EntityIcon
@@ -50,9 +53,12 @@ internal fun CollectionListItem(
5053
ListItem(
5154
headlineContent = {
5255
HighlightableText(
53-
text = collection.name,
56+
text = buildAnnotatedString {
57+
withStyle(style = SpanStyle(fontWeight = collection.fontWeight)) {
58+
append(collection.name)
59+
}
60+
},
5461
highlightedText = query,
55-
fontWeight = collection.fontWeight,
5662
)
5763
},
5864
modifier = listItemModifier,

shared/feature/details/src/androidMain/kotlin/ly/david/musicsearch/shared/feature/details/alias/AliasListItem.android.kt

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,77 @@ package ly.david.musicsearch.shared.feature.details.alias
33
import androidx.compose.material3.Surface
44
import androidx.compose.runtime.Composable
55
import androidx.compose.ui.tooling.preview.PreviewLightDark
6-
import ly.david.musicsearch.shared.domain.alias.AliasType
7-
import ly.david.musicsearch.shared.domain.alias.BasicAlias
86
import ly.david.musicsearch.ui.common.preview.PreviewTheme
97

8+
private val primaryAlias = AliasListItemModel(
9+
name = "The Apothecary Diaries Season 2 Volume 2 (Original Anime Soundtrack)",
10+
locale = "en",
11+
language = "English",
12+
isPrimary = true,
13+
type = "Release group name",
14+
begin = "",
15+
end = "",
16+
ended = false,
17+
)
18+
1019
@PreviewLightDark
1120
@Composable
1221
internal fun PreviewAliasListItemPrimary() {
1322
PreviewTheme {
1423
Surface {
1524
AliasListItem(
16-
alias = BasicAlias(
17-
name = "The Apothecary Diaries Season 2 Volume 2 (Original Anime Soundtrack)",
18-
locale = "en",
19-
isPrimary = true,
20-
type = AliasType.RELEASE_GROUP_NAME,
21-
begin = "",
22-
end = "",
23-
ended = false,
24-
),
25+
alias = primaryAlias,
26+
filterText = "",
27+
)
28+
}
29+
}
30+
}
31+
32+
@PreviewLightDark
33+
@Composable
34+
internal fun PreviewAliasListItemPrimaryWithFilter() {
35+
PreviewTheme {
36+
Surface {
37+
AliasListItem(
38+
alias = primaryAlias,
39+
filterText = "i",
2540
)
2641
}
2742
}
2843
}
2944

45+
private val endedAlias = AliasListItemModel(
46+
name = "なみ",
47+
locale = "ja",
48+
language = "Japanese",
49+
isPrimary = false,
50+
type = "Artist name",
51+
begin = "2010",
52+
end = "2015-02",
53+
ended = true,
54+
)
55+
3056
@PreviewLightDark
3157
@Composable
3258
internal fun PreviewAliasListItemEnded() {
3359
PreviewTheme {
3460
Surface {
3561
AliasListItem(
36-
alias = BasicAlias(
37-
name = "なみ",
38-
locale = "ja",
39-
isPrimary = false,
40-
type = AliasType.ARTIST_NAME,
41-
begin = "2010",
42-
end = "2015-02",
43-
ended = true,
44-
),
62+
alias = endedAlias,
63+
filterText = "",
64+
)
65+
}
66+
}
67+
}
68+
69+
@PreviewLightDark
70+
@Composable
71+
internal fun PreviewAliasListItemEndedWithFilter() {
72+
PreviewTheme {
73+
Surface {
74+
AliasListItem(
75+
alias = endedAlias,
76+
filterText = "0",
4577
)
4678
}
4779
}

shared/feature/details/src/androidMain/kotlin/ly/david/musicsearch/shared/feature/details/alias/AliasesSection.android.kt

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,67 @@ import androidx.compose.material3.Surface
55
import androidx.compose.runtime.Composable
66
import androidx.compose.ui.tooling.preview.PreviewLightDark
77
import kotlinx.collections.immutable.persistentListOf
8-
import ly.david.musicsearch.shared.domain.alias.BasicAlias
98
import ly.david.musicsearch.ui.common.preview.PreviewTheme
109

10+
private val aliases = persistentListOf(
11+
AliasListItemModel(
12+
name = "Various Artists",
13+
type = null,
14+
locale = "en",
15+
language = "English",
16+
isPrimary = true,
17+
begin = "",
18+
end = "",
19+
ended = false,
20+
),
21+
AliasListItemModel(
22+
name = "ヴァリアス・アーティスト",
23+
type = null,
24+
locale = "ja",
25+
language = "Japanese",
26+
isPrimary = true,
27+
begin = "",
28+
end = "",
29+
ended = false,
30+
),
31+
AliasListItemModel(
32+
name = "群星",
33+
type = null,
34+
locale = "zh",
35+
language = "Chinese",
36+
isPrimary = true,
37+
begin = "",
38+
end = "",
39+
ended = false,
40+
),
41+
)
42+
1143
@PreviewLightDark
1244
@Composable
1345
internal fun PreviewAliasesSection() {
1446
PreviewTheme {
1547
Surface {
1648
LazyColumn {
1749
aliasesSection(
18-
filteredAliases = persistentListOf(
19-
BasicAlias(
20-
name = "Various Artists",
21-
locale = "en",
22-
isPrimary = true,
23-
),
24-
BasicAlias(
25-
name = "ヴァリアス・アーティスト",
26-
locale = "ja",
27-
isPrimary = true,
28-
),
29-
BasicAlias(
30-
name = "群星",
31-
locale = "zh",
32-
isPrimary = true,
33-
),
34-
),
35-
totalAliases = 50,
50+
aliases = aliases,
51+
primaryLabel = "Primary",
52+
filterText = "",
53+
)
54+
}
55+
}
56+
}
57+
}
58+
59+
@PreviewLightDark
60+
@Composable
61+
internal fun PreviewAliasesSectionWithFilter() {
62+
PreviewTheme {
63+
Surface {
64+
LazyColumn {
65+
aliasesSection(
66+
aliases = aliases,
67+
primaryLabel = "Primary",
68+
filterText = "en",
3669
)
3770
}
3871
}

shared/feature/details/src/androidMain/kotlin/ly/david/musicsearch/shared/feature/details/area/PreviewAreaUi.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,7 @@ private val detailsUiState = DetailsUiState(
520520
internal fun PreviewAreaDetails() {
521521
PreviewWithTransitionAndOverlays {
522522
AreaUi(
523-
state = detailsUiState.copy(
524-
detailsTabUiState = DetailsTabUiState(
525-
totalUrls = 2,
526-
totalAliases = 3,
527-
),
528-
),
523+
state = detailsUiState,
529524
)
530525
}
531526
}
@@ -538,8 +533,6 @@ internal fun PreviewAreaDetailsCollapsed() {
538533
state = detailsUiState.copy(
539534
detailsTabUiState = DetailsTabUiState(
540535
isExternalLinksCollapsed = true,
541-
totalUrls = 2,
542-
totalAliases = 3,
543536
),
544537
),
545538
)

shared/feature/details/src/androidMain/kotlin/ly/david/musicsearch/shared/feature/details/artist/ArtistUi.android.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ private val detailsUiState = DetailsUiState(
117117
detailsModel = detailsModel,
118118
detailsTabUiState = DetailsTabUiState(
119119
now = Instant.parse("2025-09-06T18:42:20Z"),
120-
totalUrls = 2,
121120
),
122121
)
123122

@@ -156,9 +155,7 @@ internal fun PreviewArtistDetailsUiWithFilter() {
156155
topAppBarFilterState.updateFilterText("https")
157156
ArtistUi(
158157
state = detailsUiState.copy(
159-
detailsTabUiState = detailsUiState.detailsTabUiState.copy(
160-
totalUrls = 3,
161-
),
158+
detailsTabUiState = detailsUiState.detailsTabUiState,
162159
topAppBarFilterState = topAppBarFilterState,
163160
),
164161
)
@@ -250,7 +247,6 @@ internal fun PreviewArtistDetailsUiWithWikipediaUrlButNoExtract() {
250247
),
251248
detailsTabUiState = DetailsTabUiState(
252249
now = Instant.parse("2025-06-05T19:42:20Z"),
253-
totalUrls = 1,
254250
),
255251
)
256252
}

shared/feature/details/src/androidMain/kotlin/ly/david/musicsearch/shared/feature/details/release/PreviewReleaseDetailsUi.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ internal fun PreviewReleaseDetailsUi() {
8585
detailsTabUiState = DetailsTabUiState(
8686
numberOfImages = 11,
8787
now = Instant.parse("2025-06-05T19:42:20Z"),
88-
totalUrls = 2,
8988
),
9089
)
9190
}
@@ -102,7 +101,6 @@ internal fun PreviewReleaseDetailsUiCollapsed() {
102101
isReleaseEventsCollapsed = true,
103102
isExternalLinksCollapsed = true,
104103
now = Instant.parse("2025-06-05T19:42:20Z"),
105-
totalUrls = 2,
106104
),
107105
)
108106
}
@@ -142,7 +140,6 @@ internal fun PreviewReleaseDetailsUiWithListens() {
142140
numberOfImages = 11,
143141
isReleaseEventsCollapsed = true,
144142
now = Instant.fromEpochMilliseconds(1757116212000),
145-
totalUrls = 2,
146143
),
147144
)
148145
}

shared/feature/details/src/androidMain/kotlin/ly/david/musicsearch/shared/feature/details/releasegroup/PreviewReleaseGroupDetailsUi.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package ly.david.musicsearch.shared.feature.details.releasegroup
33
import androidx.compose.runtime.Composable
44
import androidx.compose.ui.tooling.preview.PreviewLightDark
55
import kotlinx.collections.immutable.persistentListOf
6-
import kotlin.time.Instant
76
import ly.david.musicsearch.shared.domain.details.ReleaseGroupDetailsModel
87
import ly.david.musicsearch.shared.domain.listitem.RelationListItemModel
98
import ly.david.musicsearch.shared.domain.network.MusicBrainzEntityType
109
import ly.david.musicsearch.shared.domain.wikimedia.WikipediaExtract
1110
import ly.david.musicsearch.shared.feature.details.utils.DetailsTabUiState
1211
import ly.david.musicsearch.ui.common.preview.PreviewWithTransitionAndOverlays
12+
import kotlin.time.Instant
1313

1414
private val releaseGroup = ReleaseGroupDetailsModel(
1515
id = "bdaeec2d-94f1-46b5-91f3-340ec6939c66",
@@ -60,7 +60,6 @@ internal fun PreviewReleaseGroupDetailsUi() {
6060
detailsTabUiState = DetailsTabUiState(
6161
numberOfImages = 1,
6262
now = Instant.parse("2025-06-05T19:42:20Z"),
63-
totalUrls = 3,
6463
),
6564
)
6665
}
@@ -76,7 +75,6 @@ internal fun PreviewReleaseGroupDetailsUiCollapsed() {
7675
numberOfImages = 1,
7776
now = Instant.parse("2025-06-05T19:42:20Z"),
7877
isExternalLinksCollapsed = true,
79-
totalUrls = 3,
8078
),
8179
)
8280
}

shared/feature/details/src/androidMain/kotlin/ly/david/musicsearch/shared/feature/details/utils/UrlsSection.android.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal fun PreviewUrlsSection() {
1616
Surface {
1717
LazyColumn {
1818
urlsSection(
19-
filteredUrls = persistentListOf(
19+
urls = persistentListOf(
2020
RelationListItemModel(
2121
id = "1",
2222
linkedEntityId = "3",
@@ -39,7 +39,7 @@ internal fun PreviewUrlsSection() {
3939
name = "https://www.wikidata.org/wiki/Q719120",
4040
),
4141
),
42-
totalUrls = 3,
42+
filterText = "",
4343
)
4444
}
4545
}

shared/feature/details/src/androidMain/kotlin/ly/david/musicsearch/shared/feature/details/work/PreviewWorkDetailsUi.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ internal fun PreviewWorkDetailsUi() {
4848
work = work,
4949
detailsTabUiState = DetailsTabUiState(
5050
now = Instant.parse("2025-06-05T19:42:20Z"),
51-
totalUrls = 1,
5251
),
5352
)
5453
}
@@ -69,7 +68,6 @@ internal fun PreviewWorkDetailsUiWithListens() {
6968
),
7069
detailsTabUiState = DetailsTabUiState(
7170
now = Instant.parse("2025-06-05T19:42:20Z"),
72-
totalUrls = 1,
7371
),
7472
)
7573
}

shared/feature/details/src/androidUnitTest/kotlin/ly/david/musicsearch/shared/feature/details/alias/AliasListItemTest.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,24 @@ class AliasListItemTest : ScreenshotTest() {
1212
}
1313
}
1414

15+
@Test
16+
fun primaryWithFilter() {
17+
snapshot {
18+
PreviewAliasListItemPrimaryWithFilter()
19+
}
20+
}
21+
1522
@Test
1623
fun ended() {
1724
snapshot {
1825
PreviewAliasListItemEnded()
1926
}
2027
}
28+
29+
@Test
30+
fun endedWithFilter() {
31+
snapshot {
32+
PreviewAliasListItemEndedWithFilter()
33+
}
34+
}
2135
}

0 commit comments

Comments
 (0)