mirror of
https://github.com/revanced/revanced-manager-compose-old.git
synced 2025-04-30 06:24:28 +02:00
feat: sorta reworked the dashboard screen
This commit is contained in:
parent
27f3d315cc
commit
4daacf0e91
@ -22,11 +22,12 @@ fun ApplicationItem(
|
|||||||
ExpandableCard(
|
ExpandableCard(
|
||||||
content = { arrowButton ->
|
content = { arrowButton ->
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
|
modifier = Modifier.height(68.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
) {
|
) {
|
||||||
|
@ -4,20 +4,21 @@ import androidx.compose.animation.animateContentSize
|
|||||||
import androidx.compose.animation.core.LinearOutSlowInEasing
|
import androidx.compose.animation.core.LinearOutSlowInEasing
|
||||||
import androidx.compose.animation.core.animateFloatAsState
|
import androidx.compose.animation.core.animateFloatAsState
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.ArrowDropDown
|
import androidx.compose.material.icons.filled.ArrowDropDown
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
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.RectangleShape
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import app.revanced.manager.R
|
import app.revanced.manager.R
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun ExpandableCard(
|
fun ExpandableCard(
|
||||||
content: @Composable (arrowButton: @Composable () -> Unit) -> Unit,
|
content: @Composable (arrowButton: @Composable () -> Unit) -> Unit,
|
||||||
@ -29,6 +30,7 @@ fun ExpandableCard(
|
|||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
.defaultMinSize(minHeight = 68.dp)
|
||||||
.animateContentSize(
|
.animateContentSize(
|
||||||
animationSpec = tween(
|
animationSpec = tween(
|
||||||
durationMillis = 300,
|
durationMillis = 300,
|
||||||
@ -56,9 +58,10 @@ fun ExpandableCard(
|
|||||||
contentDescription = stringResource(R.string.expand)
|
contentDescription = stringResource(R.string.expand)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
AssistChip(onClick = { /*TODO*/ }, label = {Text("Update")}, shape = CircleShape)
|
||||||
}
|
}
|
||||||
if (expandedState) {
|
if (expandedState) {
|
||||||
Box(modifier = Modifier.padding(bottom = 8.dp)) {
|
Box(modifier = Modifier.padding(bottom = 16.dp)) {
|
||||||
expandedContent()
|
expandedContent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,5 @@ enum class DashboardDestination(
|
|||||||
@StringRes val label: Int
|
@StringRes val label: Int
|
||||||
) : Destination {
|
) : Destination {
|
||||||
DASHBOARD(Icons.Default.Dashboard, R.string.dashboard),
|
DASHBOARD(Icons.Default.Dashboard, R.string.dashboard),
|
||||||
PATCHER(Icons.Default.Build, R.string.patcher),
|
PATCHER(Icons.Default.Build, R.string.patcher)
|
||||||
SETTINGS(Icons.Default.Settings, R.string.settings),
|
|
||||||
}
|
}
|
@ -8,10 +8,7 @@ import androidx.compose.foundation.verticalScroll
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Build
|
import androidx.compose.material.icons.filled.Build
|
||||||
import androidx.compose.material.icons.filled.Dashboard
|
import androidx.compose.material.icons.filled.Dashboard
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@ -26,6 +23,7 @@ import app.revanced.manager.ui.component.HeadlineWithCard
|
|||||||
import app.revanced.manager.ui.viewmodel.DashboardViewModel
|
import app.revanced.manager.ui.viewmodel.DashboardViewModel
|
||||||
import org.koin.androidx.compose.getViewModel
|
import org.koin.androidx.compose.getViewModel
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun DashboardScreen(viewModel: DashboardViewModel = getViewModel()) {
|
fun DashboardScreen(viewModel: DashboardViewModel = getViewModel()) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
@ -38,7 +36,7 @@ fun DashboardScreen(viewModel: DashboardViewModel = getViewModel()) {
|
|||||||
.padding(horizontal = 18.dp)
|
.padding(horizontal = 18.dp)
|
||||||
.verticalScroll(state = rememberScrollState()),
|
.verticalScroll(state = rememberScrollState()),
|
||||||
horizontalAlignment = Alignment.Start,
|
horizontalAlignment = Alignment.Start,
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
verticalArrangement = Arrangement.spacedBy(18.dp)
|
||||||
) {
|
) {
|
||||||
HeadlineWithCard(R.string.updates) {
|
HeadlineWithCard(R.string.updates) {
|
||||||
Row(
|
Row(
|
||||||
@ -65,51 +63,36 @@ fun DashboardScreen(viewModel: DashboardViewModel = getViewModel()) {
|
|||||||
Toast.makeText(context, "Already up-to-date!", Toast.LENGTH_SHORT)
|
Toast.makeText(context, "Already up-to-date!", Toast.LENGTH_SHORT)
|
||||||
.show()
|
.show()
|
||||||
},
|
},
|
||||||
) { Text(stringResource(R.string.update_manager)) }
|
) { Text(stringResource(R.string.update_patch_bundle)) }
|
||||||
Text(
|
|
||||||
text = "No updates available",
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
||||||
fontSize = 10.sp,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||||
|
|
||||||
HeadlineWithCard(R.string.patched_apps) {
|
|
||||||
Row(
|
Text(
|
||||||
modifier = Modifier
|
text = "Patched Applications",
|
||||||
.padding(horizontal = padHoriz, vertical = padVert)
|
style = MaterialTheme.typography.headlineSmall
|
||||||
.fillMaxWidth(),
|
)
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
FilterChip(selected = true, onClick = { /*TODO*/ }, label = {
|
||||||
) {
|
Text("Updates Available")
|
||||||
Column {
|
})
|
||||||
val amount = 2 // TODO
|
FilterChip(selected = false, onClick = { /*TODO*/ }, label = {
|
||||||
Text(
|
Text("Installed")
|
||||||
text = "${stringResource(R.string.updates_available)}: $amount",
|
})
|
||||||
style = MaterialTheme.typography.bodyLarge,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
fontSize = 18.sp
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Button(
|
|
||||||
enabled = true, // needs update
|
|
||||||
onClick = {
|
|
||||||
Toast.makeText(context, "Already up-to-date!", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
) { Text(stringResource(R.string.update_all)) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(horizontal = padHoriz)
|
|
||||||
.padding(bottom = padVert)
|
.padding(bottom = padVert)
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||||
) {
|
) {
|
||||||
ApplicationItem(
|
ApplicationItem(
|
||||||
name = "ReVanced",
|
name = "ReVanced",
|
||||||
released = "Released 2 days ago",
|
released = "com.google.android.youtube",
|
||||||
icon = { Icon(Icons.Default.Dashboard, "ReVanced") }
|
icon = { Icon(Icons.Default.Dashboard, "ReVanced") }
|
||||||
) {
|
) {
|
||||||
ChangelogText(
|
ChangelogText(
|
||||||
|
@ -31,7 +31,7 @@ fun MainRootScreen(navigator: BackstackNavigator<AppDestination>) {
|
|||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.nestedScroll(scrollBehavior.nestedScrollConnection),
|
.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||||
topBar = {
|
topBar = {
|
||||||
SmallTopAppBar(
|
LargeTopAppBar(
|
||||||
title = {
|
title = {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(mainRootNavigator.currentDestination.label),
|
text = stringResource(mainRootNavigator.currentDestination.label),
|
||||||
@ -64,11 +64,9 @@ fun MainRootScreen(navigator: BackstackNavigator<AppDestination>) {
|
|||||||
) { destination ->
|
) { destination ->
|
||||||
when (destination) {
|
when (destination) {
|
||||||
DashboardDestination.DASHBOARD -> DashboardScreen()
|
DashboardDestination.DASHBOARD -> DashboardScreen()
|
||||||
DashboardDestination.PATCHER -> DashboardScreen()
|
DashboardDestination.PATCHER -> PatcherScreen()
|
||||||
DashboardDestination.SETTINGS -> SettingsScreen()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,158 @@
|
|||||||
|
package app.revanced.manager.ui.screen
|
||||||
|
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Build
|
||||||
|
import androidx.compose.material.icons.filled.Dashboard
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import app.revanced.manager.R
|
||||||
|
import app.revanced.manager.ui.component.ApplicationItem
|
||||||
|
import app.revanced.manager.ui.component.HeadlineWithCard
|
||||||
|
import app.revanced.manager.ui.viewmodel.DashboardViewModel
|
||||||
|
import app.revanced.manager.ui.viewmodel.PatcherViewModel
|
||||||
|
import org.koin.androidx.compose.getViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun PatcherScreen(viewModel: DashboardViewModel = getViewModel()) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val padHoriz = 16.dp
|
||||||
|
val padVert = 10.dp
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(horizontal = 18.dp)
|
||||||
|
.verticalScroll(state = rememberScrollState()),
|
||||||
|
horizontalAlignment = Alignment.Start,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
|
) {
|
||||||
|
HeadlineWithCard(R.string.updates) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = padHoriz, vertical = padVert)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Column {
|
||||||
|
CommitDate(
|
||||||
|
label = R.string.patcher,
|
||||||
|
date = viewModel.patcherCommitDate
|
||||||
|
)
|
||||||
|
CommitDate(
|
||||||
|
label = R.string.manager,
|
||||||
|
date = viewModel.managerCommitDate
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
|
Button(
|
||||||
|
enabled = false, // needs update
|
||||||
|
onClick = {
|
||||||
|
Toast.makeText(context, "Already up-to-date!", Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
},
|
||||||
|
) { Text(stringResource(R.string.update_patch_bundle)) }
|
||||||
|
Text(
|
||||||
|
text = "No updates available",
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
fontSize = 10.sp,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HeadlineWithCard(R.string.patched_apps) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = padHoriz, vertical = padVert)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Column {
|
||||||
|
val amount = 2 // TODO
|
||||||
|
Text(
|
||||||
|
text = "${stringResource(R.string.updates_available)}: $amount",
|
||||||
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 18.sp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Button(
|
||||||
|
enabled = true, // needs update
|
||||||
|
onClick = {
|
||||||
|
Toast.makeText(context, "Already up-to-date!", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
) { Text(stringResource(R.string.update_all)) }
|
||||||
|
}
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = padHoriz)
|
||||||
|
.padding(bottom = padVert)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
|
) {
|
||||||
|
ApplicationItem(
|
||||||
|
name = "ReVanced",
|
||||||
|
released = "Released 2 days ago",
|
||||||
|
icon = { Icon(Icons.Default.Dashboard, "ReVanced") }
|
||||||
|
) {
|
||||||
|
ChangelogText(
|
||||||
|
"""
|
||||||
|
fix: aaaaaa
|
||||||
|
fix: aaaaaa
|
||||||
|
fix: aaaaaa
|
||||||
|
fix: aaaaaa
|
||||||
|
fix: aaaaaa
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
ApplicationItem(
|
||||||
|
name = "ReReddit",
|
||||||
|
released = "Released 1 month ago",
|
||||||
|
icon = { Icon(Icons.Default.Build, "ReReddit") }
|
||||||
|
) {
|
||||||
|
ChangelogText(
|
||||||
|
"""
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
fix: bbbbbb
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package app.revanced.manager.ui.viewmodel
|
||||||
|
|
||||||
|
import android.text.format.DateUtils
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import app.revanced.manager.repository.GitHubRepository
|
||||||
|
import app.revanced.manager.util.ghManager
|
||||||
|
import app.revanced.manager.util.ghPatcher
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class PatcherViewModel(private val repository: GitHubRepository) : ViewModel() {
|
||||||
|
var patcherCommitDate by mutableStateOf("")
|
||||||
|
private set
|
||||||
|
var managerCommitDate by mutableStateOf("")
|
||||||
|
private set
|
||||||
|
|
||||||
|
init {
|
||||||
|
runBlocking {
|
||||||
|
patcherCommitDate = commitDateOf(ghPatcher)
|
||||||
|
managerCommitDate = commitDateOf(ghManager)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun commitDateOf(repo: String, ref: String = "HEAD"): String {
|
||||||
|
val commit = repository.getLatestCommit(repo, ref).commit
|
||||||
|
return DateUtils.getRelativeTimeSpanString(
|
||||||
|
formatter.parse(commit.committer.date)!!.time,
|
||||||
|
Calendar.getInstance().timeInMillis,
|
||||||
|
DateUtils.MINUTE_IN_MILLIS
|
||||||
|
).toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault())
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
<string name="settings">Settings</string>
|
<string name="settings">Settings</string>
|
||||||
<string name="updates">Updates</string>
|
<string name="updates">Updates</string>
|
||||||
<string name="manager">Manager</string>
|
<string name="manager">Manager</string>
|
||||||
<string name="update_manager">Update Manager</string>
|
<string name="update_patch_bundle">Update Patches</string>
|
||||||
<string name="patched_apps">Installed</string>
|
<string name="patched_apps">Installed</string>
|
||||||
<string name="update_all">Update All</string>
|
<string name="update_all">Update All</string>
|
||||||
<string name="updates_available">Available updates</string>
|
<string name="updates_available">Available updates</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user