Mitchell Syer
01/11/2022, 4:12 PMArun Joseph
01/11/2022, 4:30 PMVsevolod Kaganovych
01/11/2022, 4:39 PMTextFieldValue
in TextField
with AnnotatedString
?
Example: I have a ViewModel
from where I observe state. When text changes, I update my state and create a new AnnotatedString
like this
val nokString = getNokString(amount = state.nokAmount)
the getNokString()
looks like this
@Composable
private fun getNokString(amount: String): AnnotatedString {
return buildAnnotatedString {
withStyle(
style = SpanStyle(
fontFamily = MaterialTheme.typography.subtitle1.fontFamily,
fontSize = 40.sp
)
) {
append(amount.ifEmpty { "0" })
}
append(" ")
withStyle(
style = SpanStyle(
fontFamily = MaterialTheme.typography.subtitle1.fontFamily,
fontSize = 14.sp
)
) {
append("NOK")
}
}
}
But when I assign a new value to TextField
TextField(value = TextFieldValue(nokString),
onValueChange = {
actioner.invoke(SendAction.OnNokChanged(it.text))
})
The behaviour is unexpected: it appends the new result to the previous one. And I'm not sure how to handle this situation. Any ideas? Thanks in advance.alorma
01/11/2022, 4:47 PMColor
?Colton Idle
01/11/2022, 6:28 PMfun SomeContainer(
content: List<@Composable () -> Unit>)
Row(
Modifier.horizontalScroll(rememberScrollState()).height(IntrinsicSize.Min),
) {
content.forEach {
it(Modifier.fillMaxHeight()) <----- Anyway to get something like this
}
}
Wrapping it in a box for example doesn't help me, because although the box will get the modifier, the composable inside the box will not draw to fill max height.mattinger
01/11/2022, 7:03 PMAndy Himberger
01/12/2022, 3:28 AMDeepak Gahlot
01/12/2022, 6:46 AMyschimke
01/12/2022, 10:00 AMBox {
Content()
Overlay(modifier = Modifier.ignoreTouchEvents())
}
Marco Righini
01/12/2022, 11:31 AMJaime
01/12/2022, 3:18 PMMarcin Wisniowski
01/12/2022, 3:25 PMrequiredWidth()
but that centers it inside the parent (it overflows to both sides), where I want it left-aligned and clipped on the right.Stylianos Gakis
01/12/2022, 5:02 PMderivedStateOf
for when we want to calculate some result using composable’s parameters vs using local mutableState objects. More in thread 🧵myanmarking
01/12/2022, 5:46 PMfun someComposable(enabled: Boolean){
var valueField by remember{
mutableStateOf(..)
}
val errorInternal: Boolean = remember(enabled, valueField) {
derivedStateOf(valueField && enabled)
}
}
I need a state that depends on another state and a variable. derivedStateOf is for state only. This works but is this the correct approach?Colton Idle
01/12/2022, 7:17 PMuserScrollEnabled
was added to LazyColumn
, LazyRow
, and LazyVerticalGrid
in order to allow users to temporarily or permanently disable the user initiated scroll via touch gestures or accessibility actions. Scrolling programmatically via the methods on the state will still be allowed. (I7eae9, b/201150093)
• Added Wear OS device ids to Preview devices list (I93232)
• Fixes TextField
cursor handle not hiding when scrolled out of view. (I14552, b/208883748)
• ModalBottomSheetState
now has a isSkipHalfExpanded
flag. It can be either set through the constructor or updated later on by setting `ModalBottomSheetState`'s isSkipHalfExpanded
property to true
. Updating `isSkipHalfExpanded`'s value causes a recomposition of the sheet. (I18b86, b/186669820)
Edit: Can we get a slackbot that posts releases and release notes? lolBojie Jiang
01/12/2022, 8:01 PMbrabo-hi
01/12/2022, 8:05 PMoverride fun onNewIntent(intent: Intent?) {}
Colton Idle
01/12/2022, 8:43 PMSimon Stahl
01/13/2022, 12:29 AMFlow operator functions should not be invoked within composition
warning is
Say I have following method in my VM:
@Composable
fun getValue() =
flowOf(1, 2, 3)
.map { it.toString() } // warning here
.collectAsState(initial = "")
The naive solution is to just split the method up
fun getValueFlow() =
flowOf(1, 2, 3)
.map { it.toString() }
@Composable
fun getValue() =
getValueFlow()
.collectAsState(initial = "")
But that is not really a functional change and if there is an issue with flow operations, then we would still have it. What would be a real fix for this warning?Cristian Rosa
01/13/2022, 3:21 AMandroidx.compose.material3
v1.0.0-alpha02
and setting (according material 3 specification) right color on TextButton
TextButton(
onClick = onConfirm,
enabled = onConfirmEnable,
colors = ButtonDefaults.textButtonColors(
contentColor = MaterialTheme.colorScheme.primary,
disabledContentColor = Color.Red,
containerColor = Color.Transparent,
disabledContainerColor = Color.Transparent,
)
Doing by this che color always have primary color even when it’s disable…..I know those “transparent” look ugly, they were just for test it quicker! 😄FunkyMuse
01/13/2022, 8:35 AMafterTextChanged
for TextInputField in compose?Michael Bichlmeier
01/13/2022, 9:25 AMAnkit Shah
01/13/2022, 10:14 AMColumn(modifier = Modifier
.padding(it)
.fillMaxSize()
.verticalScroll(scrollState)
){
Box(){
Text("Sample Widget")
}
Box(){
LazyVerticalGrid(cells = GridCells.Fixed(3)) {
items(3) { index ->
val item = index
Text(text = "Item $item")
}
}
}
}
xxfast
01/13/2022, 11:00 AMandroidx.compose.material3:material3:1.0.0-alpha03
, and i’m running into this when building the app
e: java.lang.IllegalArgumentException: Failed requirement.
at androidx.compose.compiler.plugins.kotlin.lower.ComposableFunctionBodyTransformer.visitNormalComposableCall(ComposableFunctionBodyTransformer.kt:2660)
Full trace in the thread. I’m using kotlin-1.6.10elye
01/13/2022, 12:43 PM.value
)? More info on my question on https://stackoverflow.com/questions/70696585/can-we-still-use-the-variable-delegate-for-variable-pass-through-parameterAnkit Shah
01/13/2022, 1:04 PMste
01/13/2022, 1:30 PMClassCastException
with the following minimal snippet:
var something by rememberSaveable { mutableStateOf(0) }
val value by rememberSaveable(something) { mutableStateOf("Hello") }
val somethingElse by rememberSaveable { mutableStateOf(false) } // !!!
println("value: $value") // !!!
Box(
modifier = Modifier
.fillMaxSize()
.clickable { something += 1 }
)
However, after something
is changed, it throws java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
on configuration change. I know the example doesn't make sense, but is this a bug or whatsoever?K Merle
01/13/2022, 2:01 PMStylianos Gakis
01/13/2022, 3:07 PMefemoney
01/13/2022, 4:31 PMActionItem(...)
composables up until a maximum number (eg based on available space, only 3 ActionItem(...)
s allowed).
Is this enforceable at compile time? (eg something like coroutines’ @RestrictedSuspension
) 🤔 or can it only be implemented as a custom Layout
(that maybe checks, at runtime, for a particular parentData
type)?efemoney
01/13/2022, 4:31 PMActionItem(...)
composables up until a maximum number (eg based on available space, only 3 ActionItem(...)
s allowed).
Is this enforceable at compile time? (eg something like coroutines’ @RestrictedSuspension
) 🤔 or can it only be implemented as a custom Layout
(that maybe checks, at runtime, for a particular parentData
type)?Casey Brooks
01/13/2022, 5:34 PMColumn()
-> ColumnScope
, Box()
-> BoxScope
, etc)