voyager
ViewPropertyObjectAnimator
voyager | ViewPropertyObjectAnimator | |
---|---|---|
13 | 11 | |
2,327 | 339 | |
- | - | |
8.1 | 2.5 | |
7 days ago | 11 months ago | |
Kotlin | Java | |
MIT License | Apache License 2.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
voyager
-
Building a subscription tracker Desktop and iOS app with compose multiplatform
// composeApp/src/commonMain/kotlin/ui/screens/expenses/ExpensesScreenViewModel.kt package ui.screens.expenses import Expense import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.screenModelScope import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.delay import kotlinx.coroutines.launch private val logger = KotlinLogging.logger {} /** * Base state definition for our screen */ data class ExpensesScreenState( val data: List, ) { /** * Computed property to get the avg price of the expenses */ val avgExpenses: String get() = data.map { it.price }.average().toString() } /** * View model of our screen * More about ViewModels below */ class ExpensesScreenViewModel : StateScreenModel( ExpensesScreenState( data = listOf(), ), ) { init { /** * Simulating the "API request" by adding some latency * and fake data */ screenModelScope.launch { logger.info { "Fetching expenses" } delay(3000) mutableState.value = ExpensesScreenState( data = listOf( Expense( id = "1", name = "Rent", icon = "🏠", price = 102573, ), Expense( id = "2", name = "Apple one", icon = "🍎", price = 2595, ), Expense( id = "3", name = "Netflix", icon = "📺", price = 1299, ), ) ) } } } // composeApp/src/commonMain/kotlin/ui/screens/expenses/ExpensesScreen.kt package ui.screens.expenses import Expense import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import cafe.adriel.voyager.core.model.rememberScreenModel import cafe.adriel.voyager.core.screen.Screen import io.github.oshai.kotlinlogging.KotlinLogging import ui.theme.BorderRadius import ui.theme.IconSize import ui.theme.Spacing private val logger = KotlinLogging.logger {} /** * Voyager screen, since there are no params * we can define it as a plain `object` */ object ExpensesScreen : Screen { @Composable override fun Content() { /** * Instantiating our ViewModel * https://voyager.adriel.cafe/screenmodel */ val viewModel = rememberScreenModel { ExpensesScreenViewModel() } /** * More about this below, but for now, differently than JS * we handle values over time with Kotlin coroutine `Flow's` (in this case, `StateFlow`) * you can think of it as something similar to `Observables` in reactive programming */ val state by viewModel.state.collectAsState() val onExpenseClicked: (Expense) -> Unit = { logger.info { "Redirect to edit screen" } } Scaffold( topBar = { CenterAlignedTopAppBar( title = { Text("My subscriptions", style = MaterialTheme.typography.titleMedium) }, ) }, bottomBar = { BottomAppBar( contentPadding = PaddingValues(horizontal = Spacing.Large), ) { Row( modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween, ) { Column { Text( "Average expenses", style = MaterialTheme.typography.bodyLarge, ) Text( "Per month".uppercase(), style = MaterialTheme.typography.bodyMedium, ) } Text( state.avgExpenses, style = MaterialTheme.typography.labelLarge, ) } } }, ) { paddingValues -> Box(modifier = Modifier.padding(paddingValues)) { ExpenseList(state.data, onExpenseClicked) } } } } @Composable private fun ExpenseList( expenses: List, onClick: (expense: Expense) -> Unit, ) { LazyColumn( verticalArrangement = Arrangement.spacedBy(Spacing.Small_100), ) { items( items = expenses, key = { it.id }, ) { expense -> ExpenseListItem( expense = expense, onClick = { logger.info { "Clicked on ${expense.name}" } onClick(expense) }, ) } item { Spacer(Modifier.height(Spacing.Medium)) } } } @Composable private fun ExpenseListItem( expense: Expense, onClick: () -> Unit = {}, ) { Surface( modifier = Modifier .fillMaxWidth() .padding(horizontal = Spacing.Medium) .defaultMinSize(minHeight = 56.dp), onClick = onClick, shape = RoundedCornerShape(BorderRadius.small), color = MaterialTheme.colorScheme.surfaceVariant, ) { Row( modifier = Modifier .padding( horizontal = Spacing.Medium_100, vertical = Spacing.Small_100, ), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(Spacing.Large), ) { Text( text = expense.icon ?: "", fontSize = IconSize.Medium, modifier = Modifier.defaultMinSize(minWidth = 24.dp), ) Text( text = expense.name, style = MaterialTheme.typography.bodyLarge.copy(color = MaterialTheme.colorScheme.onSurfaceVariant), modifier = Modifier.weight(1f), ) Text( text = (expense.price).toString(), style = MaterialTheme.typography.bodyLarge.copy(color = MaterialTheme.colorScheme.onSurfaceVariant), ) } } }
-
Kotlin Routing - routing everything
KMP use cases increasing, developers migrating or creating your projects to KMP, no routing system or navigation available to KMP (Except Voyager), that was the opportunity to create one.
- Are Fragments in Android going to be deprecated in favor of Jetpack Compose?
-
Why compose multiplatform don't get more popular?
If I were to start a project right now, I'd use https://github.com/adrielcafe/voyager although, it doesn't support Web Canvas or iOS yet I don't think.
-
Which navigation library for compose do you suggest?
Voyager has some bugs (apparently SavedStateHandle doesn't work and the PR is open since Nov 24), Appyx is nice but I hear it's laggy (but honestly, everything in Compose is laggy all the time, so if you use Compose, that's pretty standard tbh), I don't know enough about Navigation-Reimagined to tell you, Compose-Destinations is a codegenerator over Navigation-Compose so you drag in Accompanist-Navigation to have basic screen transitions which is pre-alpha tech.
-
ViewModel: for UI business, not UI operations 😮
Voyager
-
voyager VS Appyx - a user suggested alternative
2 projects | 19 Sep 2022
-
What's the Current State of Android Development™?
https://github.com/adrielcafe/voyager/issues/42 open since January
-
The State of Navigation in Jetpack Compose
Yes, I've checked (it doesn't). I've also read AndroidScreenLifecycleOwner's source code, and I don't see a way for it to ever go to the ON_PAUSE state.
-
4 reasons Jetpack Compose is better than XML
Using any of the 5 prominent community alternatives is a better approach (even though most people hoping to use the docs as if it was like, written for stable code, will muck around with their apps crashing if the user inputs a & symbol). I have this thing but I'd consider taking a look at https://github.com/adrielcafe/voyager or maybe https://github.com/olshevski/compose-navigation-reimagined
ViewPropertyObjectAnimator
-
Am i safe by sticking with Java and XML for years ahead ?
I've been using https://github.com/blipinsk/ViewPropertyObjectAnimator and it's amazing
-
intuitive jetpack compose animations
you just use https://github.com/blipinsk/ViewPropertyObjectAnimator for everything, and if you need shared element transtiions you cry (then again, it's not like Compost can do that at all, so)
- Adding animation to recyclerView in an MVVM app requires a lot of boilerplate code
-
Why is Compose better than XML in your expirence? I'm preparing a post looking at TRUE benefits. Input appreciated.
Animations with views were much easier, you just had to use this lib https://github.com/blipinsk/ViewPropertyObjectAnimator and animator sets made it trivial. If you needed fancy crossfades then TransitionManager.beginDelayedTransition(container) and that's it.
-
What is actually the right way to make an android app?
Honestly, they're pretty even in that regard. Whether you use XML or Compose in "simple apps" is up to you. Some things are easier in Compose, and some things are just stupid tricky. Animations in Compose are the worst imo, with ViewPropertyObjectAnimator they used to be trivial for XML layouts.
-
4 reasons Jetpack Compose is better than XML
This is probably just my experience, but with Compose I have to muck around with LaunchedEffects and manual interpolation, while with XML views I could just use https://github.com/blipinsk/ViewPropertyObjectAnimator and AnimatorSet().playTogether().
-
Can someone review my coding assignment for a job? How valid is the feedback from the engineers who reviewed it?
That, and animations with https://github.com/blipinsk/ViewPropertyObjectAnimator were much easier than linear interpolating in a LaunchedEffect, and shadow support is basically non-existent (Modifier.shadow() doesn't work as you expect, even android:elevation was better).
-
Is it okay to set margin values to negative?
I like this library https://github.com/blipinsk/ViewPropertyObjectAnimator
-
What are the most underrated third party libraries for Native Android?
I don't know how to write animations without ViewPropertyObjectAnimator https://github.com/blipinsk/ViewPropertyObjectAnimator
-
Compose stable coming in July
Really? I just used https://github.com/blipinsk/ViewPropertyObjectAnimator + AnimatorSet for everything and it always just worked
What are some alternatives?
Decompose - Kotlin Multiplatform lifecycle-aware business logic components (aka BLoCs) with routing (navigation) and pluggable UI (Jetpack Compose, SwiftUI, JS React, etc.)
ArcAnimator - ArcAnimator helps to create arc transition animation: 2.3.+
compose-navigation-reimagined - 🌈 Type-safe navigation library for Jetpack Compose
AnimationEasingFunctions - Android Animation Easing Functions. Let's make animation more real!
compose-destinations - Annotation processing library for type-safe Jetpack Compose navigation with no boilerplate.
Lottie for Android, iOS, and React Native - Render After Effects animations natively on Android and iOS, Web, and React Native
PreCompose - Compose Multiplatform Navigation && State Management
UltimateAndroidReference - :rocket: Ultimate Android Reference - Your Road to Become a Better Android Developer
compose-shared-element - Experiment with SharedElement transition in Jetpack Compose, inspired by Flutter Hero widget.
CircleIndicator - A lightweight indicator like in nexus 5 launcher
navigation-compose-typed - Type-safe arguments for Jetpack Navigation Compose using Kotlinx.Serialization
AndroidViewAnimations - Cute view animation collection.