Skip to content

Instantly share code, notes, and snippets.

View zurche's full-sized avatar
👋

Alejandro Zurcher zurche

👋
View GitHub Profile
@zurche
zurche / CryptoCard.kt
Created June 21, 2023 20:26
Animating enter animation
var visible by remember { mutableStateOf(false) }
LaunchedEffect(Unit) {
delay(300)
visible = true
}
AnimatedVisibility(
visible = visible,
enter = fadeIn() + slideInVertically { fullHeight -> fullHeight },
@zurche
zurche / CryptoCard.kt
Created June 22, 2023 13:00
State enum
private enum class CircleState {
MidSize,
FullSize
}
var circleState by remember { mutableStateOf(CircleState.MidSize) }
@zurche
zurche / CryptoCard.kt
Created June 22, 2023 13:03
Circle Transition
val transition = updateTransition(targetState = circleState, label = "")
val circleRadius by transition.animateFloat(label = "",
transitionSpec = {
if (targetState == CircleState.FullSize) {
spring(Spring.DampingRatioHighBouncy, Spring.StiffnessMedium)
} else {
spring(Spring.DampingRatioNoBouncy, Spring.StiffnessVeryLow)
}
}) { state ->
@zurche
zurche / CryptoCard.kt
Created June 22, 2023 13:06
Launched effect
LaunchedEffect(Unit) {
delay(500)
circleState = CircleState.FullSize
}
@zurche
zurche / CryptoCard.kt
Created June 22, 2023 13:09
Circle radius ready
Canvas(modifier = Modifier.size(cardSize), onDraw = {
drawRect(
color = backgroundColor,
topLeft = Offset(x = size.width - (cardSize.value / 2f) - 7.5f, y = 0f),
size = size / 5f
)
drawCircle(
color = bubbleColor,
@zurche
zurche / flow.xml
Created June 25, 2023 17:45
Flow usage
<android.support.constraint.helper.Flow
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="ac, plus_minus_switch, percentage, divide,
seven, eight, nine, multiply,
four, five, six, plus,
one, two, three, minus,
zero, comma"
app:flow_firstHorizontalStyle="spread"
app:flow_horizontalStyle="spread"
@zurche
zurche / NavGraphComposable.kt
Created July 10, 2023 09:57
Nav Graph Composable
composable(route = MOVIE_LIST) {
MoviesListScreen(
onMovieDetails = { navController.navigate("$MOVIE_DETAIL/$it") },
movies = movies
)
}
@zurche
zurche / MainActivity.kt
Last active July 10, 2023 12:54
Main Activity Navigation Graph
class MainActivity : ComponentActivity() {
private val viewModel: MoviesViewModel by viewModel()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MoviesListTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
@zurche
zurche / MovieListScreen.kt
Created July 10, 2023 09:58
Movie List Screen
@Composable
fun MoviesListScreen(
onMovieDetails: (Int) -> Unit = {},
movies: State<List<MovieUI>>
) {
MoviesListUI(movies.value, onMovieDetails)
}
val mockMovieList = listOf(MovieUI(1, "Batman", ""))