Afzal Najam
11/24/2022, 10:48 PMmutableStateOf
make it stable as long as it’s only unwrapped at the end? If not, why does Compose Metrics say that State<Something>
is stable?
Does using referentialEqualityPolicy
make a difference in this case.K Merle
11/25/2022, 7:08 AMonNodeWithText
, but I'm not sure what's causing 2 nodes to be found. 🧵KotlinLeaner
11/25/2022, 11:54 AMColumn/Row
through lamda function in jetpack compose. I tried something but it giving me error.
PairContent
@Composable
fun PairContent(
bluetoothEnable: (ColumnScope) -> Unit,
) {
AnimatedVisibility(visible = true) {
Scaffold {
Column { columnScope ->
bluetoothEnable(columnScope)
}
}
}
}
ste
11/25/2022, 1:56 PMModifier.clipScrollableContainer
to LazyList
, there is? ._.PHondogo
11/25/2022, 6:34 PMDaniele Segato
11/25/2022, 6:50 PMLayout
with custom measurement and placement. I want to animate elements inside it, specifically when a parameter change I want one item to move and scale.
I first approached this like this:
val dynamicSize = animateFloatAsState(
targetValue = if (condition) .3f else 1f
)
Layout(
content = {
Box(
modifier = Modifier
.fillMaxSize(dynamicSize.value)
)
// ...
and than I kept the size to full inside my measurement... But now I actually need to decide the scaling in my layout measure logic.
Should I remove the fillMaxSize()
, have an animateFloatAsState()
outside the Layout
and use the 0f
--> 1f
inside the measure block to control the size with the constraints?
Is this an efficient way of handling animations with Layout
? I'm worried that i can become very complex in this layout to work with all the possibles options for animations.
I'm open to suggestions / code examples / anything that can show me how people handle this kind of things. Thanks.zsperske
11/25/2022, 7:16 PMAbstractComposeView
that wraps our Button component, to allow our legacy XML pages to make use of the component. In our existing UI tests we have espresso calls like onView(withId(id)).perform(click())
. When using this method on the Compose view, no click event is triggered. Has anyone else run into this/know of a fix?PHondogo
11/26/2022, 12:44 PMrobercoding
11/26/2022, 1:28 PMclickable
or any other Modifier extension that implements composed
under the hood, so I dived a bit into composed
extension.
From my own investigation, it seems that the root cause is that is creating a new ComposedModifier
each time the parent scope gets invalidated, so that would mean that any Composable (i.e Text) that is implementing something like Modifier.clickable { }
won't be skipped if the parent scope gets invalidated
But then it seems that there's an open issue tracker about this: https://issuetracker.google.com/issues/241154852
In the issue tracker it states that: Returning values from Composable functions are the cause of recomposition
Sadly I couldn't reproduce it by making an extension that returns value (Int, string) or even a Modifier. 🤔
The only way I was able reproduce the issue is by having a custom class that inherits from Modifier.Element
and this is creating a instance each time. (If it's an object
type it doesn't recompose)
So now I'm a bit bugged, I'd like to know what's exactly causing the Composable that implements composed
to be recomposed when the parent scope gets invalidated?Vikas Singh
11/26/2022, 4:40 PMmiqbaldc
11/28/2022, 2:13 AMMethod boolean androidx.compose.runtime.snapshots.SnapshotStateList.conditionalUpdate(kotlin.jvm.functions.Function1) failed lock verification and will run slower.
Common causes for lock verification issues are non-optimized dex code
and incorrect proguard optimizations.
Abdul Hafeez Sajid
11/28/2022, 7:54 AMAbdulaziz Mohammed
11/28/2022, 9:48 AMMichal Guspiel
11/28/2022, 11:34 AMMichael Job
11/28/2022, 12:38 PModay
11/28/2022, 2:38 PMonly
if its the first time that this composable is being shown
if I set isFirstTime
as a Boolean, and I then change the label (which is remembered) then recomposition happens and isFirstTime is initialized again as false and then it repeats and i fall into the isFirstTime == false
condition again
if I set isFirstTime
to remember, then changing it to true
after the first time has happened, this will also trigger recomposition and then it automatically falls into the isFirstTime
is true in the same recomposition that just happenedVille Orkas
11/28/2022, 3:40 PMdephinera
11/28/2022, 8:15 PMJasmin Fajkic
11/28/2022, 9:05 PMCorey
11/28/2022, 9:06 PMAbstractComposeView
into an existing Fragment to continuously integrate compose into an existing codebase, I have a memory leak 💥. Tho I use setCompositionStrategy
for this View the issue remains. Does anyone knows if this is an existing issue in Compose UI or am I missing something?Zoltan Demant
11/29/2022, 10:38 AMColton Idle
11/29/2022, 4:01 PMLisandro Di Meo
11/29/2022, 7:30 PMviewModel(
viewModelStoreOwner = viewModelStoreOwner, ...
)
correctly fetches the viewmodel, but the changes made on A now are lost. Am I missing something doing this?Android75
11/29/2022, 7:32 PM@Composable
fun DashBoardScreen(viewModel: DashBoardViewModel) {
var dashBoardState = viewModel.uiState.collectAsState().value
Text(text = "Title ${dashBoardState.title}" )
viewModel.loadData()
// ViewModel
val uiState = MutableStateFlow(DashboardState(false))
private fun loadData() {
uiState.value = uiState.value.copy(
title = "Text Changed" )
}
i don’t know why Text doesn’t change string…ursus
11/29/2022, 8:58 PManimateItemPlacement
insert the item immediately and then pushes the list down?
Is it possible to get what recycler view did? i.e. push the list down, then fade in the new itemAndrew Clunis
11/29/2022, 9:18 PMLuis Daivid
11/30/2022, 1:41 AMAmrJyniat
11/30/2022, 9:10 AMkeyboardType
as Number in the TextField?Tolriq
11/30/2022, 9:50 AMAndroid75
11/30/2022, 10:37 AMAndroid75
11/30/2022, 10:37 AMChris Fillmore
11/30/2022, 2:29 PMAndroid75
11/30/2022, 4:26 PM@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val navController = rememberNavController()
MyAppTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
NavigationComponent(navController)
}
}
}
}
}
@Composable
fun NavigationComponent(navController: NavHostController) {
NavHost(
navController = navController,
startDestination = Destination.Dashboard.path
) {
composable(Destination.Dashboard.path) {
val viewModel: DashBoardViewModel = hiltViewModel()
DashBoardScreen(viewModel)
}
}
}
@Composable
fun DashBoardScreen(viewModel: DashBoardViewModel) {
val dashBoardState by viewModel.uiState.collectAsState()
Column(modifier = Modifier.fillMaxSize().background(Color.White)) {
Text(
text = "${dashBoardState.title}",
fontSize = 20.sp,
color = Color.Black,
textAlign = TextAlign.Center,
modifier = Modifier.padding(16.dp)
)
Button(onClick = {viewModel.changeTitle()}) {
Text(
text = "CHANGE")
}
}
}
@HiltViewModel
class DashBoardViewModel @Inject constructor(
) : ViewModel() {
val uiState = MutableStateFlow(DashboardState(false))
fun changeTitle() {
viewModelScope.launch {
uiState.emit(uiState.value.copy(
title = "Ciao"
))
}
}
}
data class DashboardState(
var isLoading: Boolean = false,
var title: String = "start"
)
Ömer Faruk Delibaş
11/30/2022, 5:33 PMtext = "${dashBoardState.title}"
this to text = dashBoardState.title
. Because it’s already string. And maybe some little improvements for SOLID but apart from that your code is working.Android75
12/01/2022, 7:04 AM"androidx.compose.ui:ui:1.3.1" si mandatory to use compile and target 33