feat(PatchingScreen): cleanup layout
This commit is contained in:
parent
9dc08bd1d0
commit
baad8d4a94
6 changed files with 91 additions and 56 deletions
|
|
@ -27,7 +27,6 @@ class CopyDependenciesStep : Step(), KoinComponent {
|
|||
override suspend fun execute(container: StepRunner) {
|
||||
val dir = paths.patchingWorkingDir()
|
||||
|
||||
// TODO: move this to a prepare step
|
||||
if (!dir.deleteRecursively())
|
||||
throw Error("Failed to clear existing patched dir")
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ package com.aliucord.manager.ui.screens.patching
|
|||
import android.os.Parcelable
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
|
|
@ -21,7 +20,6 @@ import androidx.compose.ui.platform.LocalContext
|
|||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import cafe.adriel.voyager.core.screen.Screen
|
||||
|
|
@ -47,7 +45,7 @@ import kotlinx.parcelize.IgnoredOnParcel
|
|||
import kotlinx.parcelize.Parcelize
|
||||
import org.koin.core.parameter.parametersOf
|
||||
|
||||
private val VERTICAL_PADDING: Dp = 18.dp
|
||||
val VERTICAL_PADDING: Dp = 18.dp
|
||||
|
||||
@Parcelize
|
||||
class PatchingScreen(private val data: PatchOptions) : Screen, Parcelable {
|
||||
|
|
@ -64,15 +62,6 @@ class PatchingScreen(private val data: PatchOptions) : Screen, Parcelable {
|
|||
val listState = rememberLazyListState()
|
||||
val showMinimizationWarning = remember { !context.isIgnoringBatteryOptimizations() }
|
||||
|
||||
// Go home directly if screen model mandates so (usually caused by cancelled PackageInstaller dialog)
|
||||
LaunchedEffect(state) {
|
||||
if (state is PatchingScreenState.CloseScreen)
|
||||
navigator.popUntilRoot()
|
||||
}
|
||||
|
||||
// Prevent screen from turning off while working
|
||||
Wakelock(active = state is PatchingScreenState.Working)
|
||||
|
||||
// Exit warning dialog (dismiss itself if install process state changes, esp. for Success)
|
||||
var showAbortWarning by remember(model.state.collectAsState()) { mutableStateOf(false) }
|
||||
|
||||
|
|
@ -97,10 +86,21 @@ class PatchingScreen(private val data: PatchOptions) : Screen, Parcelable {
|
|||
}
|
||||
}
|
||||
|
||||
// Close all groups when successfully finished everything
|
||||
// Prevent screen from turning off while working
|
||||
Wakelock(active = state is PatchingScreenState.Working)
|
||||
|
||||
LaunchedEffect(state) {
|
||||
if (state == PatchingScreenState.Success)
|
||||
expandedGroup = null
|
||||
when (state) {
|
||||
// Go home directly if screen model mandates so (usually caused by cancelled PackageInstaller dialog)
|
||||
PatchingScreenState.CloseScreen -> navigator.popUntilRoot()
|
||||
|
||||
// Close all groups when successfully finished everything
|
||||
PatchingScreenState.Success -> {
|
||||
expandedGroup = null
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
|
||||
listState.animateScrollToItem(0)
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ class PatchingScreen(private val data: PatchOptions) : Screen, Parcelable {
|
|||
modifier = Modifier
|
||||
.padding(bottom = VERTICAL_PADDING)
|
||||
.fillMaxWidth()
|
||||
.thenIf(state is PatchingScreenState.Success) { alpha(.6f) }
|
||||
.thenIf(state is PatchingScreenState.Success) { alpha(.5f) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -251,47 +251,33 @@ class PatchingScreen(private val data: PatchOptions) : Screen, Parcelable {
|
|||
icon = painterResource(R.drawable.ic_refresh),
|
||||
onClick = model::restart,
|
||||
)
|
||||
|
||||
MainActionButton(
|
||||
text = stringResource(R.string.setting_clear_cache),
|
||||
icon = painterResource(R.drawable.ic_delete_forever),
|
||||
enabled = !cacheCleared,
|
||||
colors = IconButtonDefaults.filledTonalIconButtonColors(
|
||||
containerColor = MaterialTheme.colorScheme.error,
|
||||
),
|
||||
onClick = {
|
||||
cacheCleared = true
|
||||
model.clearCache()
|
||||
},
|
||||
modifier = Modifier
|
||||
.padding(top = 14.dp)
|
||||
.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
MainActionButton(
|
||||
text = stringResource(R.string.setting_clear_cache),
|
||||
icon = painterResource(R.drawable.ic_delete_forever),
|
||||
enabled = !cacheCleared,
|
||||
colors = IconButtonDefaults.filledTonalIconButtonColors(
|
||||
containerColor = MaterialTheme.colorScheme.error,
|
||||
),
|
||||
onClick = {
|
||||
cacheCleared = true
|
||||
model.clearCache()
|
||||
},
|
||||
modifier = Modifier
|
||||
.padding(top = 14.dp)
|
||||
.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item(key = "FUN_FACT") {
|
||||
AnimatedContent(
|
||||
targetState = model.funFact,
|
||||
label = "fun fact transition",
|
||||
transitionSpec = {
|
||||
(fadeIn(tween(220, delayMillis = 90)) + slideInHorizontally { it * -2 }) togetherWith
|
||||
(fadeOut(tween(90)) + slideOutHorizontally { it * 2 })
|
||||
}
|
||||
) { text ->
|
||||
Text(
|
||||
text = stringResource(R.string.fun_fact_prefix, stringResource(text)),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier
|
||||
.padding(top = VERTICAL_PADDING, bottom = 25.dp, start = VERTICAL_PADDING, end = VERTICAL_PADDING)
|
||||
.fillMaxWidth()
|
||||
.alpha(.6f)
|
||||
)
|
||||
}
|
||||
FunFact(
|
||||
text = stringResource(model.funFact),
|
||||
state = state,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ class PatchingScreenModel(
|
|||
init {
|
||||
restart()
|
||||
|
||||
// Rotate fun facts every 20s
|
||||
// Rotate fun facts every so often
|
||||
screenModelScope.launch {
|
||||
while (true) {
|
||||
funFact = FUN_FACTS.random()
|
||||
delay(20.seconds)
|
||||
delay(8.seconds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
package com.aliucord.manager.ui.screens.patching.components
|
||||
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.aliucord.manager.R
|
||||
import com.aliucord.manager.ui.screens.patching.PatchingScreenState
|
||||
import com.aliucord.manager.ui.screens.patching.VERTICAL_PADDING
|
||||
|
||||
@Composable
|
||||
fun FunFact(
|
||||
text: String,
|
||||
state: PatchingScreenState,
|
||||
) {
|
||||
AnimatedVisibility(
|
||||
visible = state !is PatchingScreenState.Failed,
|
||||
enter = fadeIn() + slideInVertically { it * 2 },
|
||||
exit = fadeOut() + slideOutVertically { it * 2 },
|
||||
label = "fun fact visibility"
|
||||
) {
|
||||
AnimatedContent(
|
||||
targetState = text,
|
||||
label = "fun fact change",
|
||||
transitionSpec = {
|
||||
val inSpec = fadeIn(tween(220, delayMillis = 90)) + slideInHorizontally { it * -2 }
|
||||
val outSpec = fadeOut(tween(90)) + slideOutHorizontally { it * 2 }
|
||||
inSpec togetherWith outSpec
|
||||
}
|
||||
) { text ->
|
||||
Text(
|
||||
text = stringResource(R.string.fun_fact_prefix, text),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier
|
||||
.padding(top = VERTICAL_PADDING, bottom = 25.dp, start = VERTICAL_PADDING, end = VERTICAL_PADDING)
|
||||
.fillMaxWidth()
|
||||
.alpha(.6f)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,12 +8,12 @@ import com.aliucord.manager.R
|
|||
|
||||
@Composable
|
||||
fun PatchingAppBar(
|
||||
onTryExit: () -> Unit,
|
||||
onBack: () -> Unit,
|
||||
) {
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.installer)) },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onTryExit) {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_back),
|
||||
contentDescription = stringResource(R.string.navigation_back),
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ fun StepGroupCard(
|
|||
}
|
||||
|
||||
LaunchedEffect(groupState) {
|
||||
if (groupState != StepState.Pending)
|
||||
if (groupState == StepState.Running)
|
||||
onExpand()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue