Questions tagged [compose-recomposition]

167 questions
4
votes
3 answers

Understanding Compose declarative logic

I'm new with Compose and declarative programming, and I'm trying to understand it. For learning, after reading tutorials and watching courses, now I'm creating my first app. I'm creating a compose desktop application with compose multiplatform which…
4
votes
1 answer

Unwanted recomposition when using Context/Toast in event - Jetpack Compose

In a Jetpack Compose application, I have two composables similar to here: @Composable fun Main() { println("Composed Main") val context = LocalContext.current var text by remember { mutableStateOf("") } fun update(num: Number) { …
4
votes
1 answer

Android collectAsStateWithLifecycle() not collecting inside composable

I am using compose LazyColumn with viewModel updating the list items by having inside my viewModel: data class ContactsListUiState( val contacts: MutableList ) @HiltViewModel class ContactsViewModel @Inject…
4
votes
3 answers

I cannot color single text from my list on click Jetpack Compose (single selection)

I have a string list of texts, when I click one of them I should color it in one color, currently my implementation colors all of the texts, what I'm doing wrong ? var isPressed by remember { mutableStateOf(false) } val buttonColor: Color by…
SNM
  • 5,625
  • 9
  • 28
  • 77
4
votes
2 answers

Compose AlertDialog not closing

I have a Dialog that I cant close when I press the button this is my code, I believe that is for the if cycle, but I need it to make it true under those circumstances, any idea that could help me here? @Composable fun PopupWindowDialog( …
4
votes
1 answer

State Hoisting in LazyColumn Single Selection. Jetpack Compose

I have a LazyColumn with expandable items. And when i click on the item he expands or collapses, but i need that when i click on closed element it opens and others in the list close.(the one that open). So first i moved state of item from remember…
4
votes
1 answer

Jetpack Compose Navigation endless loop

I am trying to show a walkthrough of my app on initial start up. I am trying to present 3 screens Welcome Screen1 Screen2 I have this navigation graph composable(Routes.Welcome.name) { WelcomeScreen( done = { …
4
votes
1 answer

Fetching photos from Firebase Cloud Storage causes flickering on Android Jetpack Compose

I'm developing an Android app using Kotlin. I need to display pictures from Cloud Storage on the screens. Now, pictures are displayed but they flickers. I can't find infomation written in Kotlin and I have no idea why this is happening. This is my…
4
votes
1 answer

ViewModel triggered navigation with JetpackCompose

In Android I often want to navigate is response to state change from a ViewModel. (for example, successful authentication triggers navigation to the user's home screen.) Is the best practice to trigger navigation from within the ViewModel? Is…
4
votes
1 answer

Mutable state of value from viewModel is not working

I have a mutablestate in my ViewModel that I'm trying to set and access in my composable. When I use delegated Property of remember it is working but after creating it in viewModel and accessing it in compose the state of the variable is empty how…
4
votes
2 answers

How to recompose a composable after an event occured in the main Activity?

I created an event listener to catch when a physical button is pressed, and it works well. But I would want to update a list used in a LazyColumn class MainActivity : ComponentActivity() { @OptIn(ExperimentalComposeUiApi::class) override fun…
4
votes
1 answer

Composable visibility not changing on State change

I have a isLoading state and I'm trying to show a CircularProgressIndicator when the value is true. @Composable fun ProductDetailScreen( viewModel: ProductDetailViewModel = hiltViewModel() ) { val productState = viewModel.productState.value …
Hamed
  • 459
  • 4
  • 20
4
votes
2 answers

jetpack compose removing elements from list of text fields

. I want my code to remove elements from list of text fields properly. Each element has an X button to remove it's text field. If I start removing elements from the bottom it works but it doesn't work for removing random elements I want to use…
4
votes
1 answer

Jetpack Compose Navigation loads screen infinitely

I am trying to implement Navigation using single activity and multiple Composable Screens. This is my NavHost: @Composable @ExperimentalFoundationApi fun MyNavHost( modifier: Modifier = Modifier, navController: NavHostController =…
4
votes
1 answer

Lazycolumn does not update when deleting an item

I am trying to delete an item from Lazycolumn. Here is my code : MyViewModel.kt : class MyViewModel:ViewModel() { val items = MutableLiveData>() fun removeItem(item: Items) { items.value = items.value?.filter { it !=…
1 2
3
11 12