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.Modifier
|
||||||
import androidx.compose.ui.draw.rotate
|
import androidx.compose.ui.draw.rotate
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.compositeOver
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import app.revanced.manager.R
|
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
|
@Composable
|
||||||
fun ApplicationItem(
|
fun ApplicationItem(
|
||||||
appName: String,
|
appName: String,
|
||||||
appIcon: @Composable () -> Unit,
|
appIcon: @Composable () -> Unit,
|
||||||
releaseAgo: String,
|
appVersion: String,
|
||||||
expandedContent: @Composable () -> Unit,
|
onClick: () -> Unit,
|
||||||
|
expandedContent: (@Composable () -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
var expandedState by remember { mutableStateOf(false) }
|
var expandedState by remember { mutableStateOf(false) }
|
||||||
val rotateState by animateFloatAsState(targetValue = if (expandedState) 180f else 0f)
|
val rotateState by animateFloatAsState(targetValue = if (expandedState) 180f else 0f)
|
||||||
@ -62,36 +67,40 @@ fun ApplicationItem(
|
|||||||
maxLines = 1
|
maxLines = 1
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = releaseAgo,
|
text = appVersion,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row {
|
Row {
|
||||||
IconButton(
|
if (expandedContent != null) {
|
||||||
modifier = Modifier.rotate(rotateState),
|
IconButton(
|
||||||
onClick = { expandedState = !expandedState },
|
modifier = Modifier.rotate(rotateState),
|
||||||
) {
|
onClick = { expandedState = !expandedState },
|
||||||
Icon(
|
) {
|
||||||
imageVector = Icons.Default.ExpandMore,
|
Icon(
|
||||||
contentDescription = stringResource(R.string.expand)
|
imageVector = Icons.Default.ExpandMore,
|
||||||
)
|
contentDescription = stringResource(R.string.expand)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
OutlinedButton(onClick = {}) {
|
OutlinedButton(onClick = onClick) {
|
||||||
Text(stringResource(R.string.update))
|
Text(stringResource(R.string.info))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AnimatedVisibility(
|
if (expandedContent != null) {
|
||||||
visible = expandedState
|
AnimatedVisibility(
|
||||||
) {
|
visible = expandedState
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(bottom = 10.dp)
|
|
||||||
.fillMaxSize(),
|
|
||||||
) {
|
) {
|
||||||
expandedContent()
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(bottom = 10.dp)
|
||||||
|
.fillMaxSize(),
|
||||||
|
) {
|
||||||
|
expandedContent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,19 +111,17 @@ fun ApplicationItem(
|
|||||||
fun ApplicationItemDualTint(
|
fun ApplicationItemDualTint(
|
||||||
appName: String,
|
appName: String,
|
||||||
appIcon: @Composable () -> Unit,
|
appIcon: @Composable () -> Unit,
|
||||||
releaseAgo: String,
|
appVersion: String,
|
||||||
expandedContent: @Composable () -> Unit,
|
onClick: () -> Unit,
|
||||||
|
expandedContent: (@Composable () -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
var expandedState by remember { mutableStateOf(false) }
|
var expandedState by remember { mutableStateOf(false) }
|
||||||
val rotateState by animateFloatAsState(targetValue = if (expandedState) 180f else 0f)
|
val rotateState by animateFloatAsState(targetValue = if (expandedState) 180f else 0f)
|
||||||
|
|
||||||
Card(
|
ElevatedCard(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.defaultMinSize(minHeight = 68.dp),
|
.defaultMinSize(minHeight = 68.dp)
|
||||||
colors = CardDefaults.cardColors(
|
|
||||||
containerColor = Color(0xFF1E2630)
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -132,8 +139,7 @@ fun ApplicationItemDualTint(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.height(68.dp)
|
.height(68.dp)
|
||||||
.weight(1f),
|
.weight(1f),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
|
||||||
) {
|
) {
|
||||||
appIcon()
|
appIcon()
|
||||||
Column(modifier = Modifier.padding(start = 8.dp)) {
|
Column(modifier = Modifier.padding(start = 8.dp)) {
|
||||||
@ -143,38 +149,44 @@ fun ApplicationItemDualTint(
|
|||||||
maxLines = 1
|
maxLines = 1
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = releaseAgo,
|
text = appVersion,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
IconButton(
|
if (expandedContent != null) {
|
||||||
modifier = Modifier.rotate(rotateState),
|
IconButton(
|
||||||
onClick = { expandedState = !expandedState },
|
modifier = Modifier.rotate(rotateState),
|
||||||
) {
|
onClick = { expandedState = !expandedState },
|
||||||
Icon(
|
) {
|
||||||
imageVector = Icons.Default.ExpandMore,
|
Icon(
|
||||||
contentDescription = stringResource(R.string.expand)
|
imageVector = Icons.Default.ExpandMore,
|
||||||
)
|
contentDescription = stringResource(R.string.expand)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
OutlinedButton(onClick = { /*TODO*/ }) {
|
Button(onClick = onClick) {
|
||||||
Text(stringResource(R.string.update))
|
Text(stringResource(R.string.info))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AnimatedVisibility(
|
if (expandedContent != null) {
|
||||||
visible = expandedState
|
AnimatedVisibility(
|
||||||
) {
|
visible = expandedState
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.background(color = Color(0xFF11161C))
|
|
||||||
.padding(14.dp, 10.dp),
|
|
||||||
) {
|
) {
|
||||||
expandedContent()
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(color = MaterialTheme.colorScheme.surface.copy(alpha = .4f).compositeOver(
|
||||||
|
MaterialTheme.colorScheme.surfaceColorAtElevation(10.dp)
|
||||||
|
))
|
||||||
|
.padding(14.dp, 10.dp),
|
||||||
|
) {
|
||||||
|
expandedContent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package app.revanced.manager.ui.viewmodel
|
package app.revanced.manager.ui.viewmodel
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.os.Parcelable
|
||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@ -15,6 +16,7 @@ import app.revanced.manager.util.ghManager
|
|||||||
import app.revanced.manager.util.ghPatcher
|
import app.revanced.manager.util.ghPatcher
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -67,10 +69,12 @@ class DashboardViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
@Serializable
|
@Serializable
|
||||||
class PatchedApp(
|
data class PatchedApp(
|
||||||
val appName: String,
|
val appName: String,
|
||||||
val pkgName: String,
|
val pkgName: String,
|
||||||
val version: String,
|
val appVersion: String,
|
||||||
val appliedPatches: List<String>
|
val appliedPatches: List<String>,
|
||||||
)
|
val patchedDate: String
|
||||||
|
) : Parcelable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user