Created
April 15, 2025 12:03
-
-
Save ifucolo/9b847161383762b615da5a8d294b992b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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