1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.compose.animation.graphics.vector 18 19 import androidx.compose.runtime.Immutable 20 import androidx.compose.ui.graphics.vector.ImageVector 21 import androidx.compose.ui.util.fastMaxBy 22 23 /** 24 * Animated vector graphics object that is generated as a result of 25 * [androidx.compose.animation.graphics.res.loadAnimatedVectorResource]. It can be composed and 26 * rendered by `rememberAnimatedVectorPainter`. 27 * 28 * @param imageVector The [ImageVector] to be animated. This is represented with the 29 * `android:drawable` parameter of an `<animated-vector>` element. 30 */ 31 @Immutable 32 public class AnimatedImageVector 33 internal constructor( 34 public val imageVector: ImageVector, 35 // The list of [AnimatedVectorTarget]s that specify animations for each of the elements in the 36 // drawable. This is represented with `<target>` elements in `<animated-vector>`. This list is 37 // expected to be *immutable*. 38 internal val targets: List<AnimatedVectorTarget> 39 ) { 40 41 /** 42 * The total duration of all the animations in this image, including start delays and repeats. 43 */ 44 public val totalDuration: Int = <lambda>null45 targets.fastMaxBy { it.animator.totalDuration }?.animator?.totalDuration ?: 0 46 47 /** Provide an empty companion object to hang platform-specific companion extensions onto. */ 48 public companion object {} 49 } 50 51 /** Definition of animation to one of the elements in a [AnimatedImageVector]. */ 52 @Immutable internal class AnimatedVectorTarget(val name: String, val animator: Animator) 53