Carl Benson
01/17/2022, 1:53 PMMargarita Volodina
01/17/2022, 3:22 PM// there is any nullable computed condition possible
val test: Boolean? = null
test?.let {
println("succeed")
} ?: run {
println("error")
}
test?.let {
Greeting("Android")
} ?: run {
Greeting("ios")
}
For kotlinVersion=1.5.31, composeVersion=1.0.5 works as expected (println("error")
, Greeting("ios")
are called).
For kotlinVersion=1.6.0 (and higher), composeVersion=1.1.0-rc01 composable function after ?:
is never called, even though println("error")
is called.
This behaviour could be easily reproduced for a new project from Android Studio wizard with default compose activity template.
Does anyone have the same problem? Any ideas how to fix this for newer kotlin versions without rewriting code for using if-statements?Brian G
01/17/2022, 5:26 PMHardeep Singh
01/17/2022, 5:28 PMLibor Bicanovsky
01/17/2022, 5:59 PMAnthony
01/17/2022, 6:00 PMRow(horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier.fillMaxWidth()) {
Text(currentTimeStamp ?: "--")
Text(artist ?: "")
Text(endTimeStamp ?: "--")
}
brabo-hi
01/17/2022, 9:15 PMnavController.currentBackStackEntry?.savedStateHandle?.set("person", person)
and
navController.currentBackStackEntry?.arguments?.putParcelable("person", person)
brabo-hi
01/17/2022, 10:51 PMdata class Person(val name: String)
class PersonViewModel: ViewModel() {
private val _itemsFlow: MutableStateFlow<List<Person>> = MutableStateFlow(emptyList())
val itemsFlow: StateFlow<List<Person>> = _itemsFlow
private val _itemsState: MutableState<List<Person>> = mutableStateOf(emptyList())
val itemsState: State<List<Person>> = _itemsState
}
@Composable
fun PersonScreen(viewmodel: PersonViewModel = viewModel()) {
val itemsFromState: List<Person> by viewmodel.itemsState
val itemsFromFlow: List<Person> by viewmodel.itemsFlow.collectAsState()
}
they are all returning List<Person>
and recomposed whenever data changesAfzal Najam
01/17/2022, 11:38 PMonStop
, I close the database. When they return, I use the Navigation component to direct them to the Password Screen.
The screen with the list of data uses a ViewModel
that exposes Flow from a Room DAO. The problem I’m having is that observing this from my ItemList
Composable apparently leaks the DAO (and hence the Database instance) when the user leaves, and when the user unlocks the app again, the ItemList
is still collection this Flow, which makes the app crash.
Using asLiveData
on the Flow
fixes the issue. Am I doing something wrong by observing the Room Flow
from a Composable
like this or is this some weird bug?Feri Nagy
01/18/2022, 8:30 AMPainter
to a Drawable
? I know that for the other way there is painterResource()
and rememberDrawablePainter()
in Accompanist, but I have not found anything about the inverse way.Ali Albaali
01/18/2022, 9:05 AMRak
01/18/2022, 11:45 AMColton Idle
01/18/2022, 12:17 PMclass LoginUiState(
var screenTitle by mutableStateOf("")
)
mikehearn
01/18/2022, 12:18 PM(params)
with { ... properties ... }
Orhan Tozan
01/18/2022, 12:30 PMSlackbot
01/18/2022, 3:42 PMJoseph Hawkes-Cates
01/18/2022, 6:57 PMmyanmarking
01/18/2022, 7:59 PMLachlan McKee
01/18/2022, 11:36 PMSimon Stahl
01/19/2022, 1:16 AMIllegalStateException: LayoutNode should be attached to an owner
(see comments for more info)clark
01/19/2022, 1:24 AMaccompanist-insets
to adjust my view size according to the height of the keyboard but when the insets finish animating, they reset to 0. Anyone seen this behavior? Any ideas on how I could fix it?
I added a green box that displays the value of LocalWindowInsets.current.ime.bottom
to show it is going back to 0 at the end of each animation.FunkyMuse
01/19/2022, 9:07 AMPeter Mandeljc
01/19/2022, 10:27 AMval btn = Button(context)
AndroidView(factory = { btn } )
theapache64
01/19/2022, 10:57 AMComposable
in the viewport, I am using a custom modifier with onGloballyPositioned
method. Inside the lambda, am comparing the x and y
cords of the Composable
and compare it with window height/width. It works, but am wondering if there’s any better method/approach? 🙂Csaba Szugyiczki
01/19/2022, 12:27 PMonCheckedChange
callback is called. We launch a request to our server and if it is successful only then we change the actual value that is backing the Switch’s checked state.
If this happens in around 100ms the switch can stuck in an endless loop.
Did anyone have a similar problem? It would be nice if we did not have to touch anything below VM layer to prevent this.myanmarking
01/19/2022, 12:44 PMTolriq
01/19/2022, 1:01 PMColton Idle
01/19/2022, 1:39 PM@Composable
fun FakeInputFieldButton(modifier: Modifier, onClick: () -> Unit, valueText: String) {
val someFunc = {}
OutlinedTextField("text", {}, modifier.clickable { someFunc() })
}
Stephen Prochnow
01/19/2022, 3:26 PMColton Idle
01/19/2022, 3:32 PMbottomSheet(route = Screen.NumberPickerBottomSheet.route) {
NumberPickerBottomSheet()
}
In the bottom sheet when the "Save" button is hit, I want to update the number value to the screen/VM that started the bottomSheet. Since it was a navigation event that started the bottom sheet, I can't pass a lambda of like onNumUpdateEvent
. What's the best way to go about this? The only other thing that comes to mind is for the screen/VM to implement some interface or something? Or maybe I just save the state in some Activity level VM? Edit: Or another option is to use the navController in the bottomsheet and use that to get the previous entry and get the VM/cast to the VM and update it that way?Colton Idle
01/19/2022, 3:32 PMbottomSheet(route = Screen.NumberPickerBottomSheet.route) {
NumberPickerBottomSheet()
}
In the bottom sheet when the "Save" button is hit, I want to update the number value to the screen/VM that started the bottomSheet. Since it was a navigation event that started the bottom sheet, I can't pass a lambda of like onNumUpdateEvent
. What's the best way to go about this? The only other thing that comes to mind is for the screen/VM to implement some interface or something? Or maybe I just save the state in some Activity level VM? Edit: Or another option is to use the navController in the bottomsheet and use that to get the previous entry and get the VM/cast to the VM and update it that way?Desmond Teo
01/19/2022, 3:58 PMNumberPickerBottomSheet(
onPickNumber = { value ->
navController.previousBackStackEntry?.savedStateHandle?.set(key, value)
}
)
navBackStackEntry.savedStateHandle
using the same key the picker usedColton Idle
01/19/2022, 4:51 PMArjun Achatz
01/19/2022, 7:13 PMnavController.previousBackStackEntry
seems a lot like starting an activity/fragment for result, which I've never been a fan of from a state mgmt prospectiveColton Idle
01/19/2022, 8:48 PMDesmond Teo
01/20/2022, 2:31 AMOh hm. Interesting. Do those values only get "transfered" once the bottom sheet collapses/goes away though? example: In the activity/fragment world with extras you only got the "extra" once the activity/fragment was closed.You can see the values immediately, because the previous destination is still active.
Colton Idle
01/20/2022, 3:49 AMMichal Klimczak
01/21/2022, 1:34 PM