Skip to content

Commit

Permalink
Fixed the collapsing list
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai-Cristian Condrea committed Jun 23, 2024
1 parent b9f1743 commit 368bb04
Showing 1 changed file with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
package com.d4rk.cleaner.ui.memory

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.expandVertically
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowRight
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.material.icons.automirrored.filled.ArrowLeft
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.outlined.Android
import androidx.compose.material.icons.outlined.Apps
import androidx.compose.material.icons.outlined.ArrowDropDown
import androidx.compose.material.icons.outlined.Download
import androidx.compose.material.icons.outlined.FolderOpen
import androidx.compose.material.icons.outlined.Image
Expand Down Expand Up @@ -75,28 +71,27 @@ fun MemoryManagerComposable() {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp) ,
.padding(horizontal = 16.dp)
) {
AnimatedVisibility(
visible = listExpanded ,
enter = fadeIn() + expandVertically() ,
exit = fadeOut() + shrinkVertically()
) {
LazyColumn(
modifier = Modifier.padding(end = 8.dp)
) {
items(storageInfo.storageBreakdown.entries.toList()) { entry ->
StorageBreakdownItem(icon = entry.key , size = entry.value)
Box(modifier = Modifier.weight(1f)) {
Column(modifier = Modifier.animateContentSize()) {
if (listExpanded) {
LazyColumn {
items(storageInfo.storageBreakdown.entries.toList()) { entry ->
StorageBreakdownItem(icon = entry.key , size = entry.value)
}
}
}
}
}

}
IconButton(onClick = { listExpanded = ! listExpanded }) {
Icon(
imageVector = if (listExpanded) Icons.Default.ArrowDropDown else Icons.AutoMirrored.Filled.ArrowRight ,
contentDescription = if (listExpanded) "Collapse" else "Expand"
)
Spacer(modifier = Modifier.width(8.dp))
IconButton(onClick = { listExpanded = ! listExpanded }) {
Icon(
imageVector = if (listExpanded) Icons.Outlined.ArrowDropDown else Icons.AutoMirrored.Filled.ArrowLeft ,
contentDescription = if (listExpanded) "Collapse" else "Expand"
)
}
}
}
}
Expand Down

0 comments on commit 368bb04

Please sign in to comment.