Skip to content

Commit

Permalink
[#551] Review: Search in composeStyle for typography results
Browse files Browse the repository at this point in the history
  • Loading branch information
paulinea committed Jan 16, 2024
1 parent 1f76aa6 commit d0e5521
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions app/src/main/java/com/orange/ods/app/ui/search/SearchScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,34 @@ import com.orange.ods.theme.guideline.toHexString
@Composable
fun SearchScreen(onResultItemClick: (String, Long?) -> Unit) {
val context = LocalContext.current
val searchedText = LocalAppBarManager.current.searchedText
val searchedText = LocalAppBarManager.current.searchedText.text.lowercase()

val filteredComponents = components.filter { component ->
searchedText.text.isEmpty() || stringResource(id = component.titleRes).lowercase()
.contains(searchedText.text.lowercase())
searchedText.isEmpty() || stringResource(id = component.titleRes).lowercase()
.contains(searchedText)
}.asSequence()

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

val filteredSpacings = Spacing.entries.filter { spacing ->
searchedText.text.isEmpty() || spacing.tokenName.lowercase()
.contains(searchedText.text.lowercase())
searchedText.isEmpty() || spacing.tokenName.lowercase()
.contains(searchedText)
}

val filteredGuidelineColors = LocalOdsGuideline.current.guidelineColors.filter { guidelineColor ->
searchedText.text.isEmpty() || guidelineColor.getName().lowercase().contains(searchedText.text.lowercase()) ||
guidelineColor.lightThemeName.lowercase().contains(searchedText.text.lowercase()) ||
guidelineColor.darkThemeName.lowercase().contains(searchedText.text.lowercase())
searchedText.isEmpty() || guidelineColor.getName().lowercase().contains(searchedText) ||
guidelineColor.lightThemeName.lowercase().contains(searchedText) ||
guidelineColor.darkThemeName.lowercase().contains(searchedText)
}

val filteredVariants = components.filter { it.variants.isNotEmpty() }
.flatMap { component ->
val componentImageRes = component.smallImageRes.orElse { component.imageRes }
component.variants.filter { variant ->
searchedText.text.isEmpty() || context.getString(variant.titleRes).lowercase()
.contains(searchedText.text.lowercase())
searchedText.isEmpty() || context.getString(variant.titleRes).lowercase()
.contains(searchedText)
}.map { variant ->
componentImageRes to variant
}
Expand Down

0 comments on commit d0e5521

Please sign in to comment.