Kulwinder Singh
01/24/2022, 8:51 AMDropdownMenu
using offset
property. I have tried to use
Modifier.onGloballyPositioned{}
but not getting expected results,
How i should position Popup menu at depending on other view ?myanmarking
01/24/2022, 10:45 AMjulioromano
01/24/2022, 3:01 PMderivedStateOf
track reads of State
objects at run time or compile time (or perhaps I should say dynamically or statically)?
🧵marios proto
01/24/2022, 3:32 PMRow {
Text()
Button()
}
and on using the largest font in the device I want to have them both visible, text and button, and if needed to break the content in two lines, is it even possible?
So far, I only managed to have them both visible with ellipse of their textmyanmarking
01/24/2022, 4:04 PMFilip Stanis
01/24/2022, 6:37 PM@Composable
fun MyButton(onClick: () -> Unit) {
Button(onClick = onClick) { ... }
}
// vs
@Composable
fun MyButton(onClick: () -> Unit) {
Button(onClick = { onClick() } { ... }
}
(this is probably a more general kotlin question, but I see both patterns in compose code and it's unclear if one is better / worse than the other)Billy Newman
01/24/2022, 6:44 PMmyanmarking
01/24/2022, 6:49 PMArun Joseph
01/24/2022, 7:39 PMif (enabled) {
Icon(
painter = painterResource(id = iconId),
contentDescription = null,
modifier = Modifier.size(32.dp),
tint = iconColor
)
} else {
Icon(
painter = painterResource(id = iconId),
contentDescription = null,
modifier = Modifier.size(32.dp),
)
}
I am trying something along these lines
Icon(
painter = painterResource(id = iconId),
contentDescription = null,
modifier = Modifier.size(32.dp),
tint = if (enabled) iconColor else ...
)
henrikhorbovyi
01/25/2022, 12:48 AMMyScreen:
Column():
Text("Nice Title")
LazyVerticalGrid:
items(n) { MyItem() }
iona bartishvili
01/25/2022, 7:35 AMMarcin Środa
01/25/2022, 9:00 AMMatthew Laser
01/25/2022, 3:22 PMJan
01/25/2022, 5:35 PMclass AbsenceViewModel : ViewModel() {
val absencesFlow = MutableStateFlow<List<DBItem>>(emptyList())
init {
viewModelScope.launch {
kotlin.runCatching {
AbsenceRepository.getAll()
}.onSuccess {
absencesFlow.value = it.toList()
}.onFailure {
absencesFlow.value = emptyList()
}
}
}
}
but whats when I modify the entries on the rest api? Or if I want to modify them locally?Filip Stanis
01/25/2022, 6:32 PMTextField
in a scrollable column and I realized that by default the column won't scroll to the bottom if it goes off screen. Attached gif of what I mean - the TextField
grows until it reached the height of the Column
, then it goes off-screen - but I can still scroll to it. Can I make the scroll position follow focus? I'd expected that to happen by default, maybe I'm doing something wrong?
val scrollState by remember { mutableStateOf(ScrollState(0)) }
var value by remember { mutableStateOf("") }
Column(
Modifier
.padding(8.dp)
.height(60.dp)
.verticalScroll(scrollState)
) {
BasicTextField(
modifier = Modifier
.fillMaxWidth()
.background(Color.White)
.padding(8.dp),
value = value,
onValueChange = { value = it }
)
}
Lucien Guimaraes
01/25/2022, 7:34 PMscrimColor
parameter to Color.Unspecified
, to make sheets looks like standard sheets, we don't have control over the peekHeight.vgonda
01/25/2022, 8:29 PMAndroidComposeTestRule
for end-to-end tests that work through multiple activities?myanmarking
01/25/2022, 8:58 PMLazyColumn{
item(item, {item.key}){
MyItem()
}
}
LazyColumn{
item(item){
key(item.key){
MyItem()
}
}
}
Marko Novakovic
01/25/2022, 9:49 PMAnimatedNavHost
from Accompanist
composable(...) {...}
is recomposed multiple times due to animation. so every value inside the composable
lambda should be `remember`ed right? for extracting arguments it doesn't really matter because they are static but with remember
we avoid constant extraction of arguments?
what about hiltViewModel
inside composable
lambda?
is it ok to do something like this:
composable(
route = Screen.Checkout.route,
arguments = ...,
enterTransition = { forwardTransitionSharedAxisXIn() },
exitTransition = { backwardsTransitionSharedAxisXOut() },
) { backStackEntry ->
val someArg = remember { backStackEntry.arguments!!.getFloat("arg") }
val viewModel = hiltViewModel<CheckoutViewModel>(backStackEntry)
CheckoutScreen(
...
navigateUp = navController::popBackStack,
)
}
?Aditya Murthy
01/25/2022, 11:22 PMmarios proto
01/26/2022, 12:02 AMLazycolumn
inside an AbstractComposeView
, contained in a ScrollView(in an xml layout)? it seems there is no way around the exception of
Nesting scrollable in the same direction layouts like LazyColumn and Column(Modifier.verticalScroll()) is not allowed.
jannis
01/26/2022, 9:56 AMTextField
?Jan Skrasek
01/26/2022, 10:31 AMPainter
- seems to have mutability issues and I didn't found any copy/clone method.
• @Composable () -> Unit
- for custom rendering icon is too benevolent for me
• @Composable () -> Painter
- is what I'm ended up. Is it the correct solution?Ashu
01/26/2022, 2:13 PMTeck Wei Chan
01/26/2022, 2:25 PMvar show by rememberSaveable { mutableStateOf(false) }
causes ClassCastException: Boolean can't be cast to String
on configuration change. remember { ... }
works fine, of course.
afaik, rememberSaveable
uses bundle to save values so it should be fine, no?Guilherme Delgado
01/26/2022, 3:01 PManimateItemPlacement
implementation (or alternative) for LazyGridScope
? 🤔Colton Idle
01/26/2022, 4:18 PMremember*State
calls to my VM?
Example:
val bottomSheetScaffoldState = rememberBottomSheetScaffoldState(bottomSheetState = BottomSheetState(BottomSheetValue.Collapsed))
myanmarking
01/26/2022, 7:28 PMSimon Stahl
01/26/2022, 7:48 PMFilip Wiesner
01/26/2022, 7:50 PMFilip Wiesner
01/26/2022, 7:50 PMval writeObserver: (Any) -> Unit = { writtenState ->
val s = writtenState as MutableState<String>
println("State was changed to ${s.value}")
}
var state by mutableStateOf("")
val snap = Snapshot.takeMutableSnapshot(writeObserver = writeObserver)
snap.enter {
state = "A"
Snapshot.withMutableSnapshot {
state = "B"
state = "C"
}
}
snap.apply()
snap.dispose()
//The Result is:
// State was changed to A
// State was changed to B
// State was changed to C
takeNestedMutableSnapshot
which is called by takeMutableSnapshot
) clearly states that this shouldn't be the case:
Take a mutable snapshot of the state values in this snapshot. Entering this snapshot by calling enter allows state objects to be modified that are not visible to the this, the parent snapshot, until the apply is called.What am I missing?
val snap = Snapshot.takeMutableSnapshot()
snap.enter {
Snapshot.observe(writeObserver = writeObserver) {
state = "A"
val nestedSnap = snap.takeNestedMutableSnapshot()
nestedSnap.enter {
state = "B"
state = "C"
}
nestedSnap.apply()
nestedSnap.dispose()
}
}
snap.apply()
snap.dispose()
//The Result is:
// State was changed to A
But frankly I have no idea why. And it also doesn't work like I thought it will. It observes only the "A" change but not the "C" change which kinda makes sense.currentSnapshot()
function returns the global snapshot and not the snap
like I thought it will. So when I create snapshot inside another, they are both in GlobalSnapshot. But even then it doesn't make sense to me 😞Adam Powell
02/02/2022, 4:49 PMChuck Jazdzewski [G]
02/02/2022, 5:11 PMGlobalSnapshotManager
does, so it can schedule some action. It is not intended to be used as apply observer which will only send a notification at most once for each change.objects to be modified that are not visible to the this, the parent snapshot, until the apply is called.This is referring to the values of the objects not the notification sent to the read and write observers. Changing the value of
state
in nestedSnap
is not visible in snap
until nestedSnap
is applied.