Colton Idle
04/12/2021, 11:16 AMSrSouza
04/12/2021, 12:16 PMArsen
04/12/2021, 12:45 PMPiotr
04/12/2021, 12:54 PMAlex
04/12/2021, 1:38 PMUtkarsh Tiwari
04/12/2021, 1:42 PMOlivier Patry
04/12/2021, 2:44 PMpointerInput
Modifier
, I try to implement a custom drag behavior.
Based on a position on a Box
I compute a color.
If I use var color by remember { mutableStateOf(initialColor) }
inside my composable and update color value based on drag position it works.
If I extract a state (to allow parent composable to consume it), and hoist it, it doesn't work anymore.
My understanding is that the value captured by onDrag
is stale and still consider the initial value used and never update it. I don't understand the difference with state being hoisted or inline within Composable…
(code in thread)Rafal
04/12/2021, 4:02 PMjames
04/12/2021, 11:19 PMChris Fillmore
04/13/2021, 12:38 AMSurfaceView.lockHardwareCanvas()
. I didn’t see anything here about it:
https://developer.android.com/jetpack/compose/graphicsms
04/13/2021, 6:06 AMHorizontalPager
. When I run the app, I get
java.lang.NoSuchFieldError: No static field Companion of type Landroidx/compose/foundation/layout/BoxScope$Companion; in classLandroidx/compose/foundation/layout/BoxScope; or its superclasses (declaration of 'androidx.compose.foundation.layout.BoxScope' appears in /data/app/~~t1Ai-4vbEvAZ8lELuEQ7cA==/com.partnersincrime.focuslauncher-I6-eS_JANYdA0QptWYtpzA==/base.apk)
at com.google.accompanist.pager.Pager.Pager(Pager.kt:461)
at com.google.accompanist.pager.Pager.HorizontalPager(Pager.kt:147)
Noé Casas
04/13/2021, 8:08 AMGuilherme Delgado
04/13/2021, 8:24 AMSudhir Singh Khanger
04/13/2021, 9:31 AMCoilImage()
similar to <ImageView tools:src="@tools:sample/avatars" ... />
or possibly any alternatives to quickly viewing image composable while designing a screen?Colton Idle
04/13/2021, 10:32 AMAndrew Max
04/13/2021, 11:22 AMefemoney
04/13/2021, 12:02 PMLilly
04/13/2021, 1:19 PMcompose-router
to jetpacks navigation-compose
and I'm wondering how to handle constructs like those properly:
// (container) screen with a BottomNavigationBar
fun ScreenContainer(
...
childs: @Composable (PaddingValues, SomeState, SomeHighOrderFunction) -> Unit
)
ScreenContainer(
...
) { innerPadding, SomeState, onError -> // How to easily pass things like innerPading or highorder functions to child screens?
NestedRouter(startPoint = Screen.A) { backStack ->
when(backStack.last())
is ScreenA -> ScreenA()
is ScreenB -> ScreenB()
}
}
vs.
NavHost(navController = navController, startDestination = "container") {
composable("container") { ScreenContainer(
...
) // childs are now called via navController
composable("screena") { ScreenA(innerPadding = ?, state = ?, onError = ?) } // How to get these parameters?
composable("screenb") { ScreenB(innerPadding = ?, state = ?, onError = ?) }
}
Thanks in advance!Jan Skrasek
04/13/2021, 2:00 PMButtonPrimary(onClick = {}) { Text("Primary") }
ButtonSecondary(onClick = {}) { Text("Secondary") }
or having it configurable via a property and enum?
2️⃣
Button(Kind.Primary, onClick = {}) { Text("Primary") }
Button(Kind.Secondary, onClick = {}) { Text("Primary") }
My SwiftUI friend forces me to the enum way but I would prefer rather the first one (their syntax seems better here - they may use only the .Primary
token as the value.)Rodri Represa
04/13/2021, 3:20 PMescodro
04/13/2021, 5:03 PMYASAN
04/13/2021, 6:15 PMmzgreen
04/14/2021, 8:17 AMandroid:ellipsize="middle"
behavior with Text
composable? I know there is TextOverflow.Ellipsis
but how do I specify if it should be in the middle, end, etc?mzgreen
04/14/2021, 11:03 AM// first method - result on the left
Canvas(modifier = Modifier.size(50.dp)) {
drawCircle(Color.Blue)
drawCircle(Color.Green, style = Stroke(width = 2.dp.value))
}
/ second method - result on the right
Surface(
shape = CircleShape,
color = Color.Blue,
border = BorderStroke(2.dp, Color.Green),
modifier = Modifier.size(50.dp),
content = {}
)
YASAN
04/14/2021, 11:26 AMGeert
04/14/2021, 12:23 PMLilly
04/14/2021, 1:02 PMwhen
construct in a composable function:
when (val state = presenter.uiState) {
UiState.Success -> {
CallComponent() // composable code
}
is UiState.Failure -> {
CallAnotherComponent() // composable code
state = "setState" // non-composable code
}
}
presenter.uiState
is a mutableStateOf. Optimally this code should only be called when presenter.uiState has changed but instead it's called on every recompose. What's the right way to handle this?loloof64
04/14/2021, 1:32 PM@Composable
named NonInteractiveZone
which has some process running or not based on a Boolean
state (let's say shouldBeRunning
). I would like to let other @Composable
call some "methods/events" on it, let's say startProcess()
and endProcess()
. So that I could call myNonInteractiveZone.startProcess()
. Can I achieve something like that with a @Composable
? More in the thread.Nthily
04/14/2021, 4:11 PMval normalModifier = 0.dp
val expandModifier = 700.dp
val animatedHeight by animateDpAsState(
targetValue = (if(viewModel.textListSwitch) expandModifier else normalModifier),
animationSpec = tween(500)
)
I wrote a height animation of the expanded content, but I found that the Text control inside can be hidden in this way, while the Switch control is still displayedShakil Karim
04/14/2021, 7:08 PMShakil Karim
04/14/2021, 7:08 PMDominaezzz
04/14/2021, 7:09 PMShakil Karim
04/14/2021, 7:12 PMIan Lake
04/14/2021, 7:23 PM