Brian G
05/24/2021, 2:10 PMval view = MyView(context)
view.measure(widthMeasureSpec, heightMeasureSpec)
return Pair(textView.measuredWidth, view.measuredHeight)
I guess I could use ComposeView
for this but I'm wondering if there is something more directly available in Compose API.Zhelyazko Atanasov
05/24/2021, 2:41 PMTextField
and a button. When the user clicks the button, if the value in the TextField
is not correct or empty, I'd like to move the TextField
to the left/right a few times to draw the user's attention. In a View
world I can do something like this:
ObjectAnimator
.ofFloat(myTextInput, "translationX", 0, 25, -25, 25, -25,15, -15, 6, -6, 0)
.setDuration(duration)
.start();
But with Compose I can't figure out a way to have the current and target value be the same.
The direction I went into is to use animateDpAsState
together with keyframes
animation spec to animate the offset
of my TextField
and it does the job. My issue is how to trigger the animation.Tin Tran
05/24/2021, 2:43 PMModalBottomSheetLayout
. Code in 🧵Archie
05/24/2021, 3:32 PMInteractive Mode
on 4.2 Beta? I can’t seem find out why its missing?Vitaliy Zarubin
05/24/2021, 3:42 PMiamthevoid
05/24/2021, 3:58 PMCiprian Grigor
05/24/2021, 4:50 PMZach Klippenstein (he/him) [MOD]
05/24/2021, 5:17 PMBenny Özcetin
05/24/2021, 6:38 PMnglauber
05/24/2021, 6:51 PMmatch_parent
in Compose? 🤔
https://stackoverflow.com/questions/67677125/fill-height-for-child-in-rowSpiral123
05/24/2021, 9:03 PMArkadii Ivanov
05/24/2021, 10:57 PMState
interface have out T
and not just T
? Like State<out T> { ... }
Clément Jean
05/25/2021, 2:06 AMui_components
(android library)
/**
* Display a vertical list of [OutlinedTextField]
*/
@Composable
fun Form(fields: List<FormField>) {
LazyColumn(content = {
items(fields) { item ->
OutlinedTextField(
value = item.mutableState.value,
onValueChange = { item.mutableState.value = it },
label = { Text(text = stringResource(id = item.label)) },
isError = item.isError(item.mutableState.value)
)
}
})
}
However, when I compile the logs show me the following error:
e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't inline method call 'items' into
local final fun androidx.compose.foundation.lazy.LazyListScope.<anonymous>(): kotlin.Unit defined in com.xxx.xxx.ui_components.Form
{
items(fields) { item ->
OutlinedTextField(
value = item.mutableState.value,
onValueChange = { item.mutableState.value = it },
label = { Text(text = stringResource(id = item.label)) },
isError = item.isError(item.mutableState.value)
)
}
}
Am I doing something wrong here? Because individually the module compile (so no dependency missing, I guess) and without the dependency to ui_components
the app compiles.
Would be great if you can explain me, thanks in advance! 🙏Ryan Simon
05/25/2021, 5:50 AMSingleLiveEvent
and observing changes in my Fragment
. Now that I’m in Compose world, it seems that using a SingleLiveEvent
isn’t something that’s supported.
What are your recommendations for handling one-off events coming from the ViewModel like showing a Snackbar, navigation, etc?
Sample code in the thread of what I’m doing now.Vitaliy Zarubin
05/25/2021, 6:07 AMnatario1
05/25/2021, 10:02 AMNavHost
here? As far as I understand it makes it ignore any graph update. https://github.com/androidx/androidx/blob/androidx-main/navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt#L98iamthevoid
05/25/2021, 12:07 PMTolriq
05/25/2021, 2:25 PMChris Grigg
05/25/2021, 2:38 PMflowWithLifecycle
, which looks like it was introduced in a newer version of lifecycle than I have installed. Is flowWithLifecycle
the best way or can/should one still use shareIn
or stateIn
with a hot flow to control the collection behavior in a lifecycle-aware way?julioromano
05/25/2021, 2:57 PMBilly Newman
05/25/2021, 4:11 PMText(text = "\u202")
Nthily
05/25/2021, 4:12 PMHilt
, but when I use navigation to jump to another page, the viewModel
I get from that page is not the same as the viewModel
I get hereDaniel
05/25/2021, 4:32 PMColor
to a native color int?chao
05/25/2021, 5:26 PM@Composable
function with return type? I am trying to evaluate the feasibility to write JVM unit tests for them:
@Composable
fun spanStyleRange(textAttribute: TextAttribute): AnnotatedString.Range<SpanStyle> {
val spanStyle: SpanStyle = when (textAttribute.type) {
TextAttributeType.HASHTAG ->
SpanStyle(color = MaterialTheme.colors.primary, fontWeight = FontWeight.Bold)
else -> SpanStyle()
}
return AnnotatedString.Range(
item = spanStyle,
start = textAttribute.start,
end = textAttribute.start + textAttribute.length
)
}
In thie example, spanStyleRange
need to be annotated with @Composable
because it is using MaterialTheme.colors
Daniel
05/25/2021, 5:40 PMMarko Novakovic
05/25/2021, 8:15 PMSaiedmomen
05/25/2021, 10:10 PMNoop
05/25/2021, 11:52 PMYASAN
05/26/2021, 2:07 AMJason Ankers
05/26/2021, 5:05 AMJason Ankers
05/26/2021, 5:05 AMIan Lake
06/03/2021, 1:25 PMJason Ankers
06/03/2021, 1:33 PMNabeel
06/03/2021, 3:10 PM