perf: optimize state management and clean up styling in ReactionsSettingsScreen
- Change `items` state initialization to use `toList()` instead of `toMutableList()` to ensure a fresh immutable snapshot from the flow. - Reformat chained modifiers in `DraggableItem` for better readability.
This commit is contained in:
+3
-5
@@ -87,7 +87,7 @@ fun ReactionsSettingsScreen(
|
|||||||
@Composable
|
@Composable
|
||||||
fun ReactionsSettingsContent(accountViewModel: AccountViewModel) {
|
fun ReactionsSettingsContent(accountViewModel: AccountViewModel) {
|
||||||
val reactionRowItems by accountViewModel.reactionRowItemsFlow().collectAsStateWithLifecycle()
|
val reactionRowItems by accountViewModel.reactionRowItemsFlow().collectAsStateWithLifecycle()
|
||||||
var items by remember(reactionRowItems) { mutableStateOf(reactionRowItems.toMutableList()) }
|
var items by remember(reactionRowItems) { mutableStateOf(reactionRowItems.toList()) }
|
||||||
|
|
||||||
fun save(newItems: List<ReactionRowItem>) {
|
fun save(newItems: List<ReactionRowItem>) {
|
||||||
items = newItems.toMutableList()
|
items = newItems.toMutableList()
|
||||||
@@ -238,16 +238,14 @@ private fun ReactionRowItemCard(
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.onGloballyPositioned { coordinates ->
|
.onGloballyPositioned { coordinates ->
|
||||||
onMeasured(coordinates.size.height.toFloat())
|
onMeasured(coordinates.size.height.toFloat())
|
||||||
}
|
}.graphicsLayer {
|
||||||
.graphicsLayer {
|
|
||||||
translationY = dragOffsetY
|
translationY = dragOffsetY
|
||||||
shadowElevation = elevation
|
shadowElevation = elevation
|
||||||
if (isDragging) {
|
if (isDragging) {
|
||||||
scaleX = 1.02f
|
scaleX = 1.02f
|
||||||
scaleY = 1.02f
|
scaleY = 1.02f
|
||||||
}
|
}
|
||||||
}
|
}.padding(vertical = 8.dp),
|
||||||
.padding(vertical = 8.dp),
|
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
|||||||
Reference in New Issue
Block a user