Nat Strangerweather
04/04/2021, 9:39 AMNthily
04/04/2021, 12:32 PMMuhammad Zaryab Rafique
04/04/2021, 5:07 PMenighma
04/04/2021, 7:39 PMNavHost
I love the way I can setup navigation with it.
What I'm trying to understand is how I can get it to animate. I see that when I call navigate()
I have a lambda where I can provide options such as Anim.
I have something like this:
navController.navigate(Destination.newGame) {
anim { enter }
}
I'm guessing that I haven't defined the enter animation, since no animation is defined. Where do I define that? In the MaterialTheme somehow?Slackbot
04/04/2021, 9:16 PMzsperske
04/04/2021, 10:28 PMColton Idle
04/04/2021, 11:42 PMColton Idle
04/05/2021, 12:40 AMExposedDropdownMenu
from material android isn't available out of the box. Does anyone have a good gist to use as a replacement? I'm trying to create this from the docs.Ravi
04/05/2021, 2:38 AMIntrinsicSize.Min
its giving me Intrinsic measurements are not currently supported by SubcomposeLayout
. description text vary from 1-2 lines how to maintain common height for all the row elements
LazyRow(
state = listState,
modifier = modifier.height(IntrinsicSize.Min),
horizontalArrangement = Arrangement.spacedBy(8.dp),
)
Zhelyazko Atanasov
04/05/2021, 6:09 AMwidth
of a Column
to a percentage of the screen width. So I'm using Modifier.fillMaxWidth(0.8f)
but the Column
is still occupying the max screen width. Is this an expected behaviour and I haven't fully understood the fraction
argument or it's some kind of a bug? I'm using beta03
If that matters, the Column
is put inside a Surface
with fillMaxSize()
set.
Column(
modifier = Modifier
.fillMaxWidth(0.8f)
.fillMaxHeight()
.background(Color.Green)
) {
val (email, setEmail) = remember { mutableStateOf(TextFieldValue()) }
TextField(
value = email,
onValueChange = { setEmail(it) },
modifier = Modifier
.align(CenterHorizontally)
)
}
Marko Novakovic
04/05/2021, 6:57 AMvar state by remember { mutableStateOf(…) }
I get error saying there are no get
and set
methods BUT I have
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
and they are grey, not used. same get
and set
methods error when using import androidx.compose.runtime.*
Any fix?Marko Novakovic
04/05/2021, 7:20 AMremember {}
saves X for recomposition but when composable leaves the screen X is forgotten. if I want to save X even when composable leaves the screen I should use rememberSaveable {}
right? it seems weird because concept of rememberSaveable {}
is for surviving recreating
but composable leaving the screen is not recreation
. conceptually not the same. should I use rememberSaveable {}
or there is some other way to handle this use case?Utkarsh Tiwari
04/05/2021, 4:12 PMColton Idle
04/05/2021, 11:12 PMChris Fillmore
04/06/2021, 1:12 AM@Composable
method on an interface? something like:
interface ImageLoader {
@Composable
fun Image(url: String)
}
I have similar code implemented right now, which compiles but throws NoSuchMethodError at runtimeChris Fillmore
04/06/2021, 1:14 AMclass CustomImageLoader : ImageLoader {
@Composable
override fun Image(url: String) {
// Load and draw the image
}
}
Socheat KHAUV
04/06/2021, 2:51 AMCompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
AndroidView(
factory = { context ->
PreviewView(context).apply {
this.layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
preview.setSurfaceProvider(this.surfaceProvider)
}
},
modifier = Modifier.fillMaxSize()
)
}
I wrapped a camera preview within CompositionLocalProvider and gave an alpha value to medium, it does not work. anyone have some idea ?darkmoon_uk
04/06/2021, 4:20 AMAhmet Delibaş
04/06/2021, 7:09 AMMarko Novakovic
04/06/2021, 8:12 AMclass TestData(val test: String)
@Composable
fun StableTest() {
var state by remember { mutableStateOf(TestData("Marko")) }
SideEffect {
println(state.test)
}
Text(
modifier = Modifier
.clickable { state = TestData("Marko") }
.padding(32.dp),
text = state.test,
)
}
this triggers recomposition, TestData
is not stable, but data class TestData(val test: String)
doesn’t. Is there a reason to additionally mark data class
with @Stable
? or is @Stable
kind of forcing stability? but adding @Stable
to non data class
version still triggers recompositionJason Ankers
04/06/2021, 8:28 AMAnimatedVisibility
doesn’t have a callback when the animation finishes?Colton Idle
04/06/2021, 12:11 PMandroid:theme="@android:style/Theme.Material.Light.NoActionBar.TranslucentDecor"
but I was hoping to find something like Theme.Material.Light.NoActionBar.EdgeToEdge
.Nat Strangerweather
04/06/2021, 2:56 PMDaniel Candeias
04/06/2021, 3:57 PMZach Klippenstein (he/him) [MOD]
04/06/2021, 4:05 PMvar text by remember { mutableStateOf("") }
I made a little cheat sheet to help break it down, and hopefully serve as a quick reference if you forget.Yuri Drigin
04/06/2021, 4:57 PMGabriel Melo
04/06/2021, 8:24 PMShivam Sethi
04/07/2021, 12:24 AMString argument
having spaces or newline escape sequence from 1 destination
to another ? I am using navigation compose
currently it breaks if I try to do it according to documentation ? here the destination NEXT/${argument}
breaks if argument string has space in it ?Colton Idle
04/07/2021, 12:26 AMRender Problem
java.lang.IllegalStateException: No RollerToasterColorPalette provided at com.rollertoaster.app.theme.ThemeKt$AmbientRollerToasterColors$1.invok
Filip Wiesner
04/07/2021, 8:14 AMvar foo = remember { "hello" }
, when we mutate the variable ( foo = "world"
) it won't save it to next recomposition, right? We just mutate the variable in the current function scope.Filip Wiesner
04/07/2021, 8:14 AMvar foo = remember { "hello" }
, when we mutate the variable ( foo = "world"
) it won't save it to next recomposition, right? We just mutate the variable in the current function scope.wbertan
04/07/2021, 8:23 AMfoo.value = newValue
and to access the value with foo.value
.
To use the Delegate you have to use the `by`:
var foo by remember { mutableStateOf("hello") }
foo = "newValue"
Filip Wiesner
04/07/2021, 8:25 AMState
tho so there is no foo.value
and no delegate.julioromano
04/07/2021, 8:26 AMfoo
the way you mentioned, it will be difficult to ensure all composable functions that have foo
visible in their scope see the same mutated value of foo
.
If you need mutable state you should remember a mutableStateOf("hello")
.Filip Wiesner
04/07/2021, 8:31 AMremember
and State
separately because I don't want the reader to understand remember { mutableStateOf() }
as one thing. While explaining this I realized that I am not 100% sure that I know how it will behave so I just wanted to make sure 😄
it will be difficult to ensure all composable functions that haveSo if some inner composable function recomposes, will it get the new value ofvisible in their scopefoo
foo
variable?julioromano
04/07/2021, 8:40 AMSo if some inner composable function recomposes, will it get the new value ofvariable?foo
foo
has been mutated.Albert Chang
04/07/2021, 8:56 AMremember
always returns the same instance produced by executing the block in the first composition. foo
is just a pointer so changing the value foo
points to doesn't affect what remember
returns.
So if some inner composable function recomposes, will it get the new value ofThe inner function captures the pointer so I think the answer is yes.variable?foo
Filip Wiesner
04/07/2021, 8:59 AMjulioromano
04/07/2021, 9:20 AMAlbert Chang
04/07/2021, 9:22 AMjulioromano
04/07/2021, 9:32 AMvar foo = remember { "hello" }
foo = "newValue"
It means that any other code will see “newValue”, so in this case the remember
call is useless, it’s just polluting the composition by adding a “hello” string to it that will never be read.
I get that @Filip Wiesner is asking this for teaching purposes, I just wanted to be sure such a “pattern” would never be actually useful in real life.Filip Wiesner
04/07/2021, 9:35 AMin this case the(nitpicking a little bit) It will be read exactly once and assigned to the variable but other than that, that's exactly how I understand it.call is useless, it’s just polluting the composition by adding a “hello” string to it that will never be readremember
julioromano
04/07/2021, 9:39 AMfoo
briefly, just to be overwritten by “newValue” right after.Filip Wiesner
04/07/2021, 9:40 AMjulioromano
04/07/2021, 10:36 AMButton
) that recomposes on each click (recomposition is triggered thanks to someState
snapshot state object):
@Composable
private fun MyOuterComposable() {
Column {
var searchValue = remember { "" }
var someState by remember { mutableStateOf(".") }
OutlinedTextField(
value = searchValue,
onValueChange = { searchValue = it },
)
Button({ someState = someState.plus(".") }) {
Text("someState: $someState - searchValue: $searchValue")
}
}
}
The value of searchValue
that Button
displays depends on when Button
has been recomposed.
If it recomposes after searchValue
has been mutated then it will show the mutated value, otherwise not.
Since the order in which composables (i.e. Button
in this case) recompose may not always be reliably predicted, we can’t be sure which value of searchValue
will be read by Button
.
Disclaimer: this kind of code is just for learning purposes, it should never be used in production.Filip Wiesner
04/07/2021, 10:50 AMSean McQuillan [G]
04/07/2021, 4:33 PMReducer(...)
or Prev(...)
🙂julioromano
04/07/2021, 4:40 PMReducer(...)
or Prev(...)
?
Are they something in compose?
Or you mean Reducer as in Redux ?Sean McQuillan [G]
04/07/2021, 4:40 PM