Skip to content

Commit

Permalink
[#551] Add typography tokens in search results
Browse files Browse the repository at this point in the history
  • Loading branch information
paulinea committed Jan 16, 2024
1 parent bcca94d commit 2548768
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion app/src/main/java/com/orange/ods/app/ui/search/SearchScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

package com.orange.ods.app.ui.search

import androidx.annotation.DrawableRes
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
Expand Down Expand Up @@ -45,6 +46,7 @@ import com.orange.ods.compose.component.listitem.OdsListItem
import com.orange.ods.compose.theme.OdsTheme
import com.orange.ods.extension.orElse
import com.orange.ods.theme.guideline.GuidelineColor
import com.orange.ods.theme.guideline.GuidelineTextStyle
import com.orange.ods.theme.guideline.toHexString

@Composable
Expand All @@ -57,6 +59,10 @@ fun SearchScreen(onResultItemClick: (String, Long?) -> Unit) {
.contains(searchedText.text.lowercase())
}.asSequence()

val filteredGuidelineTypography = LocalOdsGuideline.current.guidelineTypography.filter { typography ->
searchedText.text.isEmpty() || typography.name.lowercase().contains(searchedText.text.lowercase())
}

val filteredSpacings = Spacing.entries.filter { spacing ->
searchedText.text.isEmpty() || spacing.tokenName.lowercase()
.contains(searchedText.text.lowercase())
Expand All @@ -82,7 +88,7 @@ fun SearchScreen(onResultItemClick: (String, Long?) -> Unit) {
data class SearchResult(
val title: String,
val id: Long,
val image: Int?,
@DrawableRes val image: Int?,
val subtitle: String?,
val color: Color?,
val data: Any
Expand Down Expand Up @@ -128,6 +134,15 @@ fun SearchScreen(onResultItemClick: (String, Long?) -> Unit) {
subtitle = stringResource(id = R.string.guideline_spacing_dp, spacing.getDp().value.toInt()),
data = spacing
)
}).plus(filteredGuidelineTypography.map { guidelineTypography ->
SearchResult(
guidelineTypography.name,
0,
image = R.drawable.il_typography,
color = null,
subtitle = guidelineTypography.composeStyle,
data = guidelineTypography
)
}).sortedBy { it.title }.toList()

LazyColumn(
Expand Down Expand Up @@ -174,6 +189,7 @@ fun SearchScreen(onResultItemClick: (String, Long?) -> Unit) {
is Variant -> onResultItemClick(ComponentsNavigation.ComponentVariantDemoRoute, item.id)
is Spacing -> onResultItemClick(GuidelinesNavigation.GuidelineSpacing, null)
is GuidelineColor -> openDialog.value = true
is GuidelineTextStyle -> onResultItemClick(GuidelinesNavigation.GuidelineTypography, null)
}
}
if (openDialog.value && guidelineColor != null) {
Expand Down

0 comments on commit 2548768

Please sign in to comment.