Skip to content

Commit

Permalink
💫 Added animation for MenuCartButton
Browse files Browse the repository at this point in the history
  • Loading branch information
hitanshu-dhawan committed Nov 29, 2020
1 parent 50a18f7 commit 53f0518
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.hitanshudhawan.mccompose.ui.menu

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumnFor
Expand All @@ -22,6 +26,7 @@ import androidx.ui.tooling.preview.Preview
import com.hitanshudhawan.mccompose.model.Menu
import com.hitanshudhawan.mccompose.ui.theme.McComposeTheme

@ExperimentalAnimationApi
@Composable
fun MenuScreen(
onBackClick: () -> Unit
Expand Down Expand Up @@ -56,21 +61,30 @@ fun MenuScreen(
Divider()
}

if (data.menuItems.any { it.quantity != 0 }) {
AnimatedVisibility(
visible = data.menuItems.any { it.quantity != 0 },
enter = slideInVertically(
initialOffsetY = { it * 2 }
),
exit = slideOutVertically(
targetOffsetY = { it * 2 }
),
modifier = Modifier
.padding(16.dp)
.align(Alignment.BottomCenter)
) {
MenuCartButton(
quantity = data.menuItems.sumOf { it.quantity },
price = data.menuItems.sumOf { it.price },
onClick = {},
modifier = Modifier
.padding(16.dp)
.align(Alignment.BottomCenter)
onClick = {}
)
}

}
}
}

@ExperimentalAnimationApi
@Preview("MenuScreen")
@Composable
private fun MenuScreenPreview() {
Expand All @@ -81,6 +95,7 @@ private fun MenuScreenPreview() {
}
}

@ExperimentalAnimationApi
@Preview("MenuScreen • Dark")
@Composable
private fun MenuScreenDarkPreview() {
Expand Down

0 comments on commit 53f0518

Please sign in to comment.