mirror of
https://github.com/revanced/revanced-manager-compose-old.git
synced 2025-04-30 06:24:28 +02:00
feat: don't allow expanding without content
This commit is contained in:
parent
7e1f829e3c
commit
a161467457
@ -12,17 +12,22 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.compositeOver
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import app.revanced.manager.R
|
||||
import app.revanced.manager.ui.navigation.AppDestination
|
||||
import dev.olshevski.navigation.reimagined.navController
|
||||
import dev.olshevski.navigation.reimagined.navigate
|
||||
|
||||
@Composable
|
||||
fun ApplicationItem(
|
||||
appName: String,
|
||||
appIcon: @Composable () -> Unit,
|
||||
releaseAgo: String,
|
||||
expandedContent: @Composable () -> Unit,
|
||||
appVersion: String,
|
||||
onClick: () -> Unit,
|
||||
expandedContent: (@Composable () -> Unit)? = null,
|
||||
) {
|
||||
var expandedState by remember { mutableStateOf(false) }
|
||||
val rotateState by animateFloatAsState(targetValue = if (expandedState) 180f else 0f)
|
||||
@ -62,13 +67,14 @@ fun ApplicationItem(
|
||||
maxLines = 1
|
||||
)
|
||||
Text(
|
||||
text = releaseAgo,
|
||||
text = appVersion,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
Row {
|
||||
if (expandedContent != null) {
|
||||
IconButton(
|
||||
modifier = Modifier.rotate(rotateState),
|
||||
onClick = { expandedState = !expandedState },
|
||||
@ -78,11 +84,13 @@ fun ApplicationItem(
|
||||
contentDescription = stringResource(R.string.expand)
|
||||
)
|
||||
}
|
||||
OutlinedButton(onClick = {}) {
|
||||
Text(stringResource(R.string.update))
|
||||
}
|
||||
OutlinedButton(onClick = onClick) {
|
||||
Text(stringResource(R.string.info))
|
||||
}
|
||||
}
|
||||
}
|
||||
if (expandedContent != null) {
|
||||
AnimatedVisibility(
|
||||
visible = expandedState
|
||||
) {
|
||||
@ -97,24 +105,23 @@ fun ApplicationItem(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ApplicationItemDualTint(
|
||||
appName: String,
|
||||
appIcon: @Composable () -> Unit,
|
||||
releaseAgo: String,
|
||||
expandedContent: @Composable () -> Unit,
|
||||
appVersion: String,
|
||||
onClick: () -> Unit,
|
||||
expandedContent: (@Composable () -> Unit)? = null,
|
||||
) {
|
||||
var expandedState by remember { mutableStateOf(false) }
|
||||
val rotateState by animateFloatAsState(targetValue = if (expandedState) 180f else 0f)
|
||||
|
||||
Card(
|
||||
ElevatedCard(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.defaultMinSize(minHeight = 68.dp),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = Color(0xFF1E2630)
|
||||
)
|
||||
.defaultMinSize(minHeight = 68.dp)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@ -132,8 +139,7 @@ fun ApplicationItemDualTint(
|
||||
modifier = Modifier
|
||||
.height(68.dp)
|
||||
.weight(1f),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
appIcon()
|
||||
Column(modifier = Modifier.padding(start = 8.dp)) {
|
||||
@ -143,13 +149,14 @@ fun ApplicationItemDualTint(
|
||||
maxLines = 1
|
||||
)
|
||||
Text(
|
||||
text = releaseAgo,
|
||||
text = appVersion,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
if (expandedContent != null) {
|
||||
IconButton(
|
||||
modifier = Modifier.rotate(rotateState),
|
||||
onClick = { expandedState = !expandedState },
|
||||
@ -159,19 +166,23 @@ fun ApplicationItemDualTint(
|
||||
contentDescription = stringResource(R.string.expand)
|
||||
)
|
||||
}
|
||||
OutlinedButton(onClick = { /*TODO*/ }) {
|
||||
Text(stringResource(R.string.update))
|
||||
}
|
||||
Button(onClick = onClick) {
|
||||
Text(stringResource(R.string.info))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (expandedContent != null) {
|
||||
AnimatedVisibility(
|
||||
visible = expandedState
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(color = Color(0xFF11161C))
|
||||
.background(color = MaterialTheme.colorScheme.surface.copy(alpha = .4f).compositeOver(
|
||||
MaterialTheme.colorScheme.surfaceColorAtElevation(10.dp)
|
||||
))
|
||||
.padding(14.dp, 10.dp),
|
||||
) {
|
||||
expandedContent()
|
||||
@ -180,3 +191,4 @@ fun ApplicationItemDualTint(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package app.revanced.manager.ui.viewmodel
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Parcelable
|
||||
import android.text.format.DateUtils
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@ -15,6 +16,7 @@ import app.revanced.manager.util.ghManager
|
||||
import app.revanced.manager.util.ghPatcher
|
||||
import io.ktor.http.*
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
@ -67,10 +69,12 @@ class DashboardViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
class PatchedApp(
|
||||
data class PatchedApp(
|
||||
val appName: String,
|
||||
val pkgName: String,
|
||||
val version: String,
|
||||
val appliedPatches: List<String>
|
||||
)
|
||||
val appVersion: String,
|
||||
val appliedPatches: List<String>,
|
||||
val patchedDate: String
|
||||
) : Parcelable
|
||||
|
Loading…
x
Reference in New Issue
Block a user