Condense main menu + add skill categories#373
Conversation
Stypox
left a comment
There was a problem hiding this comment.
Thanks for the nice change! I left some minor comments, but I'm very in favor of categorization.
Btw, I remember you posted some screenshots of this in Matrix; maybe also post them in the PR body next time, so visitors of the PR will see what it is up to at a glance :-).
| val collator = Collator.getInstance(locale) | ||
|
|
||
| // Group skills by category and sort | ||
| val categorizedSkills = skills |
There was a problem hiding this comment.
This calculation should go in the viewModel, otherwise it gets recomputed on every recomposition
| val enabledSkills by viewModel.enabledSkills.collectAsState() | ||
|
|
||
| // Get current locale for proper collation | ||
| val locale = context.resources.configuration.locales.get(0) ?: Locale.getDefault() |
There was a problem hiding this comment.
This is theoretically fine, but for the Locale I'd prefer if you used LocaleManager.locale.value in the viewModel
| * category. If not overridden, skills will be placed in the "Other" category. | ||
| * @return the string resource ID for the skill's category name (e.g. R.string.category_productivity) | ||
| */ | ||
| open val categoryNameRes: Int = 0 // Will default to R.string.category_other in app module |
There was a problem hiding this comment.
Instead of using a string resource, create an enum with all categories. The enum constructor then would take the string resource (and an icon?). This keeps the UI distinct from the fields of SkillInfo, and also makes it clear at a glance which categories exist.
Btw, generally, when you have Res ints, always add @StringRes.
| val collator = Collator.getInstance(locale) | ||
|
|
||
| // Group skills by category and sort | ||
| val categorizedSkills = skills |
There was a problem hiding this comment.
This code is duplicate with the above, it should be deduplicated somehow. And again it should not go in the UI, but here you can remember {} it since we don't have a view model.
| Text( | ||
| text = stringResource(R.string.here_is_what_i_can_do), | ||
| style = MaterialTheme.typography.bodyMedium, | ||
| color = MaterialTheme.colorScheme.onSecondaryContainer.copy(alpha = 0.7f), |
There was a problem hiding this comment.
I'd keep the color as-is, since here you are basically introducing a new color to the palette; are they not distinct enough without?
Made WhatICanDo.kt collapsible on main app screen.
Added categories for skills. These are used to categorize skills in the What I Can Do card and Skill Settings. Skill names are translatable via strings.xml and uses a collator to properly alphabetize categories based on the localized category names. Skills lacking a category are handled by dropping them into the Other category.
Categories are assigned in the SkillInfo.kt files. Example from current_time: