Vsevolod Ganin
12/23/2020, 10:06 PMImageVector
in runtime anywayMark Murphy
12/24/2020, 2:11 PMVsevolod Ganin
12/24/2020, 3:06 PMChris Sinco [G]
03/15/2022, 8:49 AMChris Sinco [G]
03/15/2022, 8:49 AMChris Sinco [G]
03/15/2022, 8:50 AMBradleycorn
03/15/2022, 1:03 PMImageVector
definition.
Our designers are not programmers and do not have the knowledge or skills to write ImageVector
Kotlin code directly. And our developers are not designers and do not have the knowledge or skills properly use paths, curves, lines, etc to build an ImageVector
from a design mockup. That leaves us with the need for a tool that can turn svg files into ImageVector
kotlin code.Chris Sinco [G]
03/15/2022, 10:09 PMChris Sinco [G]
03/15/2022, 10:10 PMThomas
03/15/2022, 11:34 PMBradleycorn
03/16/2022, 12:47 AM<http://Icons.Filled.xxx|Icons.Filled.xxx>
) which are `ImageVector`s. But we do have some of our own icons as well. Now consider something like a BottomNavBar. We have a NavItem
data class that represents an item in the Nav Bar. We’d like it to have a label and an icon. But when some icons are material icons (ImageVector
) and others are Xml drawables (referenced with an @DrawableRes Int
) it becomes cumbersome to define a simple NavItem
data class with a String label and an ImageVector icon.
4. We do have one interesting use case where we build an ImageVector on the fly at runtime. Our app is a horse racing app, and we have to show the saddle cloths of the horses in each race. There are 48 different saddle cloths, but they are all either a solid color or one of 3 patterns that use 2 colors. Two triangles, a set of vertical stripes, or a set of horizontal stripes. (See attached screen shot of a preview). These are basic enough that I was able to write 3 generic composables that take in 2 colors, and build an ImageVector for the appropriate pattern. It then gets used as the background on a Box to render the saddle cloth with the horse’s number. This use case doesn’t have any requirements for a converter like we’ve been discussing, but it is one of the ways in which we are using ImageVector’s in our app.