Skip to content

Commit c920e87

Browse files
authored
Make lottieComposition public (#2660)
1 parent 5af8c29 commit c920e87

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

lottie-compose/api/lottie-compose.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ public final class com/airbnb/lottie/compose/LottieRetrySignalKt {
265265
}
266266

267267
public final class com/airbnb/lottie/compose/RememberLottieCompositionKt {
268+
public static final fun lottieComposition (Landroid/content/Context;Lcom/airbnb/lottie/compose/LottieCompositionSpec;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
269+
public static synthetic fun lottieComposition$default (Landroid/content/Context;Lcom/airbnb/lottie/compose/LottieCompositionSpec;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
268270
public static final fun rememberLottieComposition (Lcom/airbnb/lottie/compose/LottieCompositionSpec;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)Lcom/airbnb/lottie/compose/LottieCompositionResult;
269271
}
270272

lottie-compose/src/main/java/com/airbnb/lottie/compose/rememberLottieComposition.kt

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,35 @@ fun rememberLottieComposition(
113113
return result
114114
}
115115

116-
private suspend fun lottieComposition(
116+
/**
117+
* Takes a [LottieCompositionSpec], attempts to load and parse the animation once, and returns a [LottieCompositionResult].
118+
119+
* The loaded composition will automatically load and set images that are embedded in the json as a base64 string
120+
* or will load them from assets if an imageAssetsFolder is supplied.
121+
*
122+
* @param spec The [LottieCompositionSpec] that defines which LottieComposition should be loaded.
123+
* @param imageAssetsFolder A subfolder in `src/main/assets` that contains the exported images
124+
* that this composition uses. DO NOT rename any images from your design tool. The
125+
* filenames must match the values that are in your json file.
126+
* @param fontAssetsFolder The default folder Lottie will look in to find font files. Fonts will be matched
127+
* based on the family name specified in the Lottie json file.
128+
* Defaults to "fonts/" so if "Helvetica" was in the Json file, Lottie will auto-match
129+
* fonts located at "src/main/assets/fonts/Helvetica.ttf". Missing fonts will be skipped
130+
* and should be set via fontRemapping or via dynamic properties.
131+
* @param fontFileExtension The default file extension for font files specified in the fontAssetsFolder or fontRemapping.
132+
* Defaults to ttf.
133+
* @param cacheKey Set a cache key for this composition. When set, subsequent calls to fetch this composition will
134+
* return directly from the cache instead of having to reload and parse the animation. Set this to
135+
* null to skip the cache. By default, this will automatically generate a cache key derived
136+
* from your [LottieCompositionSpec].
137+
*/
138+
suspend fun lottieComposition(
117139
context: Context,
118140
spec: LottieCompositionSpec,
119-
imageAssetsFolder: String?,
120-
fontAssetsFolder: String?,
121-
fontFileExtension: String,
122-
cacheKey: String?,
141+
imageAssetsFolder: String? = null,
142+
fontAssetsFolder: String? = "fonts/",
143+
fontFileExtension: String = ".ttf",
144+
cacheKey: String? = DefaultCacheKey,
123145
): LottieComposition {
124146
val task = requireNotNull(lottieTask(context, spec, cacheKey, isWarmingCache = false)) {
125147
"Unable to create parsing task for $spec."

0 commit comments

Comments
 (0)