Google

License Profile

Material Motion system animations for Jetpack Compose

Who’s using Compose Metaphor?

? Check out who’s using Compose Metaphor

Include in your project

Maven Central

Gradle

Add the dependency below to your module‘s build.gradle file:

dependencies {
    implementation("io.github.androidpoet:composemetaphor:1.0.0")
}

@OptIn(ExperimentalAnimationApi::class)
@Composable
fun AnimateVisibility() {
  var visible by remember {
    mutableStateOf(true)
  }
  Column(
    modifier = Modifier.fillMaxSize(),
    verticalArrangement = Arrangement.Center,
    horizontalAlignment = Alignment.CenterHorizontally
  ) {
    Metaphor(
      visible = visible,
      enter = MetaphorEnterAnimation.SlideInHorizontally,
      exit = MetaphorExitAnimation.FadeOut,
      easing = MetaphorEasing.FastOutLinearInEasing,
      enterDuration = 500,
      exitDuration = 100,
      delay = 0,
      content = {

        FloatingActionButton(
          modifier = Modifier.padding(24.dp),
          onClick = {
          }
        ) {
          Icon(imageVector = Icons.Default.Add, "")
        }
      }
    )
  }

  
}

Enter Animations

 MetaphorEnterAnimation.FadeIn
 MetaphorEnterAnimation.SharedAxisXForward
 MetaphorEnterAnimation.SharedAxisYForward
 MetaphorEnterAnimation.SharedAxisZForward
 MetaphorEnterAnimation.ElevationScale
 MetaphorEnterAnimation.SlideIn
 MetaphorEnterAnimation.SlideInHorizontally
 MetaphorEnterAnimation.SlideInVertically
 MetaphorEnterAnimation.ScaleIn
 MetaphorEnterAnimation.ExpandIn
 MetaphorEnterAnimation.ExpandHorizontally
 MetaphorEnterAnimation.ExpandVertically

Exit Animations

 MetaphorEnterAnimation.FadeOut
 MetaphorEnterAnimation.SharedAxisXBackward
 MetaphorEnterAnimation.SharedAxisYBackward
 MetaphorEnterAnimation.SharedAxisZBackward
 MetaphorEnterAnimation.ElevationScale
 MetaphorEnterAnimation.SlideOut
 MetaphorEnterAnimation.SlideOutHorizontally
 MetaphorEnterAnimation.SlideOutVertically
 MetaphorEnterAnimation.ScaleOut
 MetaphorEnterAnimation.ShrinkOut
 MetaphorEnterAnimation.ShrinkHorizontally
 MetaphorEnterAnimation.ShrinkVertically

Icon used:3d modeling icons created by Good Ware – Flaticon

Find this library useful? ❤️

Support it by joining stargazers for this repository. ⭐

License

Copyright 2022 AndroidPoet (Ranbir Singh)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

GitHub

View Github