Fudge
11/15/2020, 3:42 PMcompose-navigation
, it seems like the api is quite akward to use. It requires predefining routes with Strings, and then specifying those Strings again when you want to navigate to those routes. And then passing parameters into the routes is a whole world of complication. What will you do when you need to pass real objects? Serialization?
Why not a solution that looks like this, in the way Flutter did it?
onClick = { navigate { TheOtherComposable(obj1, obj2) } }
zoha131
11/15/2020, 6:15 PMmanueldidonna
11/15/2020, 6:17 PMvar result by remember { mutableStateOf(emptyList<String>()) }
val (query, changeQuery) = remember { mutableStateOf("") }
LaunchedEffect(subject = query) {
delay(300L)
stations = getResultFromWebServer(query)
}
BasicTextField(value = query, onValueChange = changeQuery)
Is this the correct way to do it?Hitanshu Dhawan
11/15/2020, 9:32 PMMaterialTheme.colors.background
inside my transitionDefinition
but I as this function is not marked with @Composable
I am getting this error
@Composable invocations can only happen from the context of a @Composable function
Is the transitionDefinition
function made non-composable on purpose? How can I make access these values inside transitionDefinition
?
My use case is to have different values for light and dark theme.
Something like this…
private val SomeTransitionDefinition = transitionDefinition<SomeState> {
state(SomeState.State1) {
this[backgroundColor] = if (MaterialTheme.colors.isLight) MaterialTheme.colors.primary else MaterialTheme.colors.secondary
}
}
Vincent tiensi
11/15/2020, 10:24 PMfun <T> VerticalListingComponent(
itemList: List<T>,
loading: Boolean,
loadNextPage: () -> Unit
)
and am calling it through this
VerticalListingComponent(
itemList = itemListingState.listings,
loading = itemListingState.loading,
{}
)
When I update the itemListingState the VerticalListingComponent seems to be consuming and displaying the new itemList properly, but it seems to be ignoring the loading boolean that I’m passing (I have a loading indicator that shows when loading = true). Does anyone know what I’m doing wrong?len
11/16/2020, 9:40 AMJrichards1408
11/16/2020, 9:56 AMRafs
11/16/2020, 10:30 AMYahor
11/16/2020, 11:27 AMJrichards1408
11/16/2020, 3:06 PMmanueldidonna
11/16/2020, 3:22 PMSearchRequest
to pass to the second screen that uses it to fetch the items from a web server.
data class SearchRequest(
val departFrom: String,
val arriveAt: String,
val departureTime: Time, // data class with day, month and year
val departureDate: Date // data class with minute and hour
)
What's the best way to translate this object to a route without parcelizing it?Vince Rickey
11/16/2020, 3:50 PMAndroidView(viewBlock = { webView })
. This will load most webpages, but it fails to load resource intensive iFrames such as an interactive elections map graphic.
I added the hardware acceleration tag to the app's Manifest, but still no luck. A log shows that the Fragment's rootview is hardware accelerated, but the Composable's AndroidView is not. The docs state that hardware acceleration is only possible through the Manifest's application or activity tags, or programmatically through the Window. I'm wondering if AndroidView doesn't support this yet if it isn't attached to the Activity or Window under the hood.
Has anyone else encountered difficulty with hardware acceleration with AndroidView interop? Code snippet in the thread.David Attias
11/16/2020, 5:40 PMRafs
11/16/2020, 6:33 PMFill
and Stroke
but i need something like StrokeAndFill
Yahor
11/16/2020, 7:28 PMe: androidx.compose.compiler.plugins.kotlin.IncompatibleComposeRuntimeVersionException: You are using an outdated version of Compose Runtime that is not compatible with the version of the Compose Compiler plugin you have installed. The compose compiler plugin you are using (version 1.0.0-alpha07) expects a minimum runtime version of 1.0.0-alpha07.
Sergey B
11/16/2020, 7:38 PMKirill Grouchnikov
11/16/2020, 9:59 PMImageBitmap
)? In general, there doesn't seem to be a way, maybe by design, to get access to the underlying pixel information for direct manipulation. AndroidImageAsset
and DesktopImageAsset
go through a somewhat of a contortion to expose the underlying pixel information to the ImageBitmap
, but I don't see any way to get those pixels afterwards.Denis Sakhapov
11/17/2020, 2:57 AMJetchat
app, if you click on any of the chat messages prior to engaging message input, and then try to type a message, the input field won't trigger the keyboard to show up. Is this a known issue and are there any workarounds for it? I experience pretty much the same behavior in my project when I first click outside an input field and then on it, it seems to obtain the focus but the soft keyboard doesn't appear.allan.conda
11/17/2020, 4:46 AMremember
a state on each item of a hoisted list.
The idea is that an item’s state is remembered even if the list has been updated.
Is it possible right now?
@Composable
fun Component(list: List<T>) {
list.forEach { item ->
// something like this but this won't work
// this should stay as false if (someCondition) for the unchanged iteems even if the list is updated
val rememberedFlag = remember(item) { mutableStateOf(true) }
if (someCondition) rememberedFlag.value = false
}
}
Edit: ^Actually works apparentlyKirill Grouchnikov
11/17/2020, 5:27 AMImageAsset
as AndroidImageAsset
and how it's painted in AndroidCanvas.drawImage
- where it is explicitly checked to be an AndroidImageAsset
. So even though Canvas.drawImage
accepts ImageAsset
, it's going to accept a very specific implementation of that interface - one on Android and one on desktop. Is there a way to create an ImageAsset
at runtime dynamically? Not from a resource, not from a file, but by populating each pixel individually as an int array, and then "wrapping" that array as an implementation of ImageAsset
that is platform agnostic?Kirill Grouchnikov
11/17/2020, 5:37 AMImageAsset
and drawing on it - such as ImageAssetSample
, but it's a chicken-and-egg problem. In order to be able to draw a dynamic "bitmap" onto it, such a bitmap would first need to already exist.Mehdi Haghgoo
11/17/2020, 5:47 AMval size1 = animate(300.dp)
val size2 = animate(100.dp)
var aSize by mutableStateOf(size1)
Image(vectorResource(id = R.drawable.video), modifier = Modifier.size(aSize).clickable(onClick = { aSize = size2 }).background(Color.Red))
allan.conda
11/17/2020, 6:43 AMMehdi Haghgoo
11/17/2020, 11:27 AMA MutableState only lasts in a single composition and it is lost in the next composition unless we remember it with.remember
nonameden
11/17/2020, 11:28 AMmanueldidonna
11/17/2020, 11:50 AMsavedInstanceState
doesn't work in a NavHost. This sample will always print '1'. Am I doing something wrong?
NavHost(navController, startDestination = "search") {
composable("search") {
var counter by savedInstanceState { 0 }
counter += 1
Log.d("counter", counter.toString())
}
}
ciscorucinski
11/17/2020, 12:39 PMOutlinedButton
we can no longer set backgroundColor
or contentColor
and I am no sure of how to do this.
I also noticed that verticalGravity
is gone, but it has been replaced with verticalAlignment
. While that was slightly obvious using auto-completion, I can't find the color properties. Or how I might navigate how to find these changed properties in the future. It seems colors
is something I have to look at, but I am not sure how to execute this in code yetChethan
11/17/2020, 12:58 PMOmar Miatello
11/17/2020, 3:13 PMbuildscript {
configurations.all {
resolutionStrategy { force 'com.android.tools.build:gradle:4.2.0-alpha16' }
}
}
but didn’t work 😞
Do you know a solution to enable Compose on a single module?Tony Mykhaylovsky
11/17/2020, 4:27 PMTony Mykhaylovsky
11/17/2020, 4:27 PMSe7eN
11/17/2020, 4:31 PM@Composable
fun Parent() {
var state by remember { mutableStateof(false) }
Child(onSomeEvent = { state = true })
}
@Composable
fun Child(onSomeEvent: () -> Unit) {
Button(onClick = onSomeEvent)
}
Tony Mykhaylovsky
11/17/2020, 4:32 PMZach Klippenstein (he/him) [MOD]
11/17/2020, 4:33 PMJavier
11/17/2020, 4:33 PMppvi
11/17/2020, 4:33 PMZach Klippenstein (he/him) [MOD]
11/17/2020, 4:34 PMMutableState
down to your child and have the child mutate the state itself, but that increases coupling and is considered more of a bad practice.Adam Powell
11/17/2020, 4:35 PMMutableState<MyData>
around is kind of like passing around Pair<Foo, Bar>
instead of defining a data class for the abstraction you're trying to represent with itppvi
11/17/2020, 4:36 PMAdam Powell
11/17/2020, 4:36 PMTony Mykhaylovsky
11/17/2020, 4:41 PMJoost Klitsie
11/17/2020, 4:44 PMppvi
11/17/2020, 4:44 PMactions
Tony Mykhaylovsky
11/17/2020, 4:44 PMJoost Klitsie
11/17/2020, 4:45 PM@Composable
fun parent() {
childContainer(...paremeters) {
SomeOtherComposable()
}
}
@Composable
fun childContainer(...paremeters, children: @Composable () -> Unit) {
SpecialStuff()
children()
}
Tony Mykhaylovsky
11/17/2020, 4:46 PMJoost Klitsie
11/17/2020, 4:46 PMhttps://www.youtube.com/watch?v=SMOhl9RK0BA▾
Zach Klippenstein (he/him) [MOD]
11/17/2020, 4:48 PMclass YourComplicatedState {
private val _foo: MutableState<Foo> = mutableStateOf(…)
private val _bar: MutableState<Bar> = mutableStateOf(…)
val foo: State<Foo> = _foo
val bar: State<Bar> = _bar
fun doSomeAction() {
_foo.value = …
_bar.value = …
}
}
@Composable
fun Parent() {
var state by remember { YourComplicatedState() }
Child(state)
}
@Composable
fun Child(state: YourComplicatedState) {
Button(onClick = { state.doSomeAction() })
}
Tony Mykhaylovsky
11/17/2020, 4:48 PM