galex
07/23/2020, 4:03 AMe: /Users/galex/projects/alexpizzapp/app/src/main/java/il/co/galex/alexpizzapp/common/navigation/Navigation.kt: (24, 16): @Composable invocations can only happen from the context of a @Composable function
I can reference Icons.Filled.AccountBox
but I can’t call to vectorResource
at the same level 😞Leland Richardson [G]
07/23/2020, 4:34 AMAccountBox
instead of the vector resource itself good enough?galex
07/23/2020, 6:16 AMLeland Richardson [G]
07/23/2020, 6:41 AMval foo = vectorResource(bar)
and using it inside a composable as
Image(foo)
Is it not easy enough to instead just do
val foo = bar
and then use it inside a composable as
Image(vectorResource(foo))
And if not, what is the use case that makes it not?galex
07/23/2020, 8:17 AMsealed class Screen(val id: ScreenName, @StringRes val label: Int, val icon: VectorAsset? = null, val iconResId: Int? = 0) {
object Home : Screen(
id = ScreenName.HOME,
label = R.string.title_home,
icon = Icons.Filled.Home,
)
object Calculator : Screen(
id = ScreenName.CALCULATOR,
label = R.string.title_calculator,
iconResId = R.drawable.ic_calculate_24dp
)
object Profile : Screen(
id = ScreenName.PROFILE,
label = R.string.title_profile,
icon = Icons.Filled.AccountBox
)
}
icon
as a vectorResource
because I couldn’t find the calculator icon in Icons.Filled.*
so I added it in my project old styleiconResId
property and condtionnaly load one or the other depending on icon
nullabilityBottomNavigation
, if I set the icon as Icons.Filled.Home
it is dark, and if I set it up as Icon(vectorResource(id = R.drawable.home)
it gets tinted to white! Should I open a bug?