Overview
Content
The compose
module contains a CartesianChart
host, compatible scroll and zoom systems, a theming framework, and factory functions.
Factory functions
As previously discussed, core
uses android.graphics
APIs shared between Compose and views. In this context, dp dimensions are Float
s, colors are Int
s, and so on. The same applies to the view system, which uses android.graphics
APIs quite directly.
Jetpack Compose, on the other hand, introduces a larger abstraction layer over the underlying android.graphics
APIs, with classes such as Dp
and Color
. Under the hood, it ultimately converts instances of these to android.graphics
-compatible types, but this doesn’t concern the consumer.
Thus, to enable the natural use of Vico with Compose, the compose
module provides factory functions with parameters of Compose types. These wrap core
constructors and factory functions, handling the conversion to android.graphics
types internally, much like Compose itself does. Some of these factory functions also provide defaults based on the theming system.
You should therefore never find yourself using android.graphics
-like constructs—such as Float
s for dp dimensions or Int
s for colors—when working with Vico and Compose. Call the appropriate compose
factory functions instead. This isn’t to say that all core
APIs are off limits for Compose. Many core
constructors and factory functions have no parameters (1) of types for which Compose has abstractions or (2) that require defaults based on the theming system. These are perfectly appropriate to use in Compose—in fact, they have no compose
counterparts, as these would be identical.