Skip to content

Instantly share code, notes, and snippets.

@ifucolo
Created April 15, 2025 12:03
Show Gist options
  • Select an option

  • Save ifucolo/9b847161383762b615da5a8d294b992b to your computer and use it in GitHub Desktop.

Select an option

Save ifucolo/9b847161383762b615da5a8d294b992b to your computer and use it in GitHub Desktop.
@Composable
fun PrayersFilterComponent(
selectedFilters: Set<SelectableFilterType>,
onFilterSelected: (SelectableFilterType) -> Unit
) {
val context = LocalContext.current
val items = remember(selectedFilters) {
listOf(
SelectableItemData(
name = context.getString(R.string.prayer_tag),
isSelected = selectedFilters.any { it is SelectableFilterType.PrayerType },
selectedColor = ColorPrayer,
unselectedColor = White,
type = SelectableFilterType.PrayerType()
),
SelectableItemData(
name = context.getString(R.string.novena_tag),
isSelected = selectedFilters.any { it is SelectableFilterType.NovenaType },
selectedColor = ColorNovena,
unselectedColor = White,
type = SelectableFilterType.NovenaType()
),
SelectableItemData(
name = context.getString(R.string.terco_tag),
isSelected = selectedFilters.any { it is SelectableFilterType.ChapletType },
selectedColor = ColorTerco,
unselectedColor = White,
type = SelectableFilterType.ChapletType()
)
)
}
SelectableItemList(
selectedItems = items,
onItemSelected = { selectedItem ->
onFilterSelected(selectedItem.type as SelectableFilterType)
}
)
}
sealed class SelectableFilterType: SelectableType {
data class PrayerType(val prayerId: Int = 1) : SelectableFilterType()
data class NovenaType(val novenaId: Int = 2) : SelectableFilterType()
data class ChapletType(val chapletId: Int = 3) : SelectableFilterType()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment