manager: Refactor AppItem layout and improve label display
This commit is contained in:
@@ -25,7 +25,6 @@ import androidx.compose.material3.pulltorefresh.PullToRefreshBox
|
|||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
|
||||||
import androidx.compose.ui.draw.scale
|
import androidx.compose.ui.draw.scale
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
@@ -57,6 +56,7 @@ import com.sukisu.ultra.ui.viewmodel.SuperUserViewModel
|
|||||||
import com.sukisu.ultra.ui.viewmodel.AppCategory
|
import com.sukisu.ultra.ui.viewmodel.AppCategory
|
||||||
import com.sukisu.ultra.ui.viewmodel.SortType
|
import com.sukisu.ultra.ui.viewmodel.SortType
|
||||||
import com.dergoogler.mmrl.ui.component.LabelItem
|
import com.dergoogler.mmrl.ui.component.LabelItem
|
||||||
|
import com.dergoogler.mmrl.ui.component.LabelItemDefaults
|
||||||
import kotlin.math.*
|
import kotlin.math.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -431,9 +431,7 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
|
|||||||
state = listState,
|
state = listState,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.nestedScroll(scrollBehavior.nestedScrollConnection),
|
.nestedScroll(scrollBehavior.nestedScrollConnection)
|
||||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
|
||||||
contentPadding = PaddingValues(vertical = 8.dp)
|
|
||||||
) {
|
) {
|
||||||
items(filteredAndSortedApps, key = { it.packageName + it.uid }) { app ->
|
items(filteredAndSortedApps, key = { it.packageName + it.uid }) { app ->
|
||||||
AppItem(
|
AppItem(
|
||||||
@@ -790,62 +788,46 @@ private fun AppItem(
|
|||||||
onLongClick: () -> Unit,
|
onLongClick: () -> Unit,
|
||||||
viewModel: SuperUserViewModel
|
viewModel: SuperUserViewModel
|
||||||
) {
|
) {
|
||||||
// 添加交互状态
|
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
|
||||||
val isPressed by interactionSource.collectIsPressedAsState()
|
|
||||||
|
|
||||||
// 优化的缩放动画
|
|
||||||
val scale by animateFloatAsState(
|
|
||||||
targetValue = if (isPressed) 0.98f else 1.0f,
|
|
||||||
animationSpec = spring(
|
|
||||||
dampingRatio = Spring.DampingRatioMediumBouncy,
|
|
||||||
stiffness = Spring.StiffnessHigh
|
|
||||||
),
|
|
||||||
label = "appItemScale"
|
|
||||||
)
|
|
||||||
|
|
||||||
ListItem(
|
ListItem(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
|
||||||
.scale(scale)
|
|
||||||
.pointerInput(Unit) {
|
.pointerInput(Unit) {
|
||||||
detectTapGestures(
|
detectTapGestures(
|
||||||
onLongPress = { onLongClick() },
|
onLongPress = { onLongClick() },
|
||||||
onTap = { onClick() }
|
onTap = { onClick() }
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
.padding(horizontal = 8.dp),
|
headlineContent = { Text(app.label) },
|
||||||
headlineContent = {
|
|
||||||
Text(
|
|
||||||
text = app.label,
|
|
||||||
style = MaterialTheme.typography.titleMedium,
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis
|
|
||||||
)
|
|
||||||
},
|
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
Column(
|
Column {
|
||||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
Text(app.packageName)
|
||||||
) {
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
Text(
|
|
||||||
text = app.packageName,
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis
|
|
||||||
)
|
|
||||||
|
|
||||||
FlowRow(
|
FlowRow(
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
verticalArrangement = Arrangement.spacedBy(2.dp)
|
|
||||||
) {
|
) {
|
||||||
if (app.allowSu) {
|
if (app.allowSu) {
|
||||||
LabelItem(text = stringResource(R.string.label_root))
|
LabelItem(
|
||||||
}
|
text = "ROOT",
|
||||||
if (Natives.uidShouldUmount(app.uid)) {
|
)
|
||||||
LabelItem(text = stringResource(R.string.label_unmount))
|
} else {
|
||||||
|
if (Natives.uidShouldUmount(app.uid)) {
|
||||||
|
LabelItem(
|
||||||
|
text = "UMOUNT",
|
||||||
|
style = LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (app.hasCustomProfile) {
|
if (app.hasCustomProfile) {
|
||||||
LabelItem(text = stringResource(R.string.label_custom))
|
LabelItem(
|
||||||
|
text = "CUSTOM",
|
||||||
|
style = LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.onTertiary,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onTertiaryContainer,
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -858,8 +840,9 @@ private fun AppItem(
|
|||||||
.build(),
|
.build(),
|
||||||
contentDescription = app.label,
|
contentDescription = app.label,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(48.dp)
|
.padding(4.dp)
|
||||||
.clip(MaterialTheme.shapes.small)
|
.width(48.dp)
|
||||||
|
.height(48.dp)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
@@ -889,10 +872,7 @@ private fun AppItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
colors = ListItemDefaults.colors(
|
|
||||||
containerColor = Color.Transparent
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -900,16 +880,15 @@ private fun AppItem(
|
|||||||
fun LabelText(label: String) {
|
fun LabelText(label: String) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(top = 2.dp, end = 2.dp)
|
.padding(top = 4.dp, end = 4.dp)
|
||||||
.background(
|
.background(
|
||||||
Color.Black,
|
Color.Black,
|
||||||
shape = RoundedCornerShape(4.dp)
|
shape = RoundedCornerShape(4.dp)
|
||||||
)
|
)
|
||||||
.clip(RoundedCornerShape(4.dp))
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = label,
|
text = label,
|
||||||
modifier = Modifier.padding(vertical = 2.dp, horizontal = 6.dp),
|
modifier = Modifier.padding(vertical = 2.dp, horizontal = 5.dp),
|
||||||
style = TextStyle(
|
style = TextStyle(
|
||||||
fontSize = 8.sp,
|
fontSize = 8.sp,
|
||||||
color = Color.White,
|
color = Color.White,
|
||||||
|
|||||||
Reference in New Issue
Block a user