Fix more UI bugs
This commit is contained in:
parent
a44cd8ba3b
commit
4b7d644c43
|
|
@ -306,74 +306,78 @@ private fun DoPatchBody(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
BoxWithConstraints(modifier.padding(24.dp)) {
|
||||||
modifier
|
val shellBoxMaxHeight =
|
||||||
.fillMaxSize()
|
if (patchState == PatchState.PATCHING) maxHeight
|
||||||
.padding(24.dp)
|
else maxHeight - ButtonDefaults.MinHeight - 12.dp
|
||||||
.wrapContentHeight()
|
Column(
|
||||||
.animateContentSize(spring(stiffness = Spring.StiffnessLow))
|
Modifier
|
||||||
) {
|
.fillMaxSize()
|
||||||
ShimmerAnimation(enabled = patchState == PatchState.PATCHING) {
|
.wrapContentHeight()
|
||||||
CompositionLocalProvider(
|
.animateContentSize(spring(stiffness = Spring.StiffnessLow))
|
||||||
LocalTextStyle provides MaterialTheme.typography.bodySmall.copy(fontFamily = FontFamily.Monospace)
|
) {
|
||||||
) {
|
ShimmerAnimation(enabled = patchState == PatchState.PATCHING) {
|
||||||
val scrollState = rememberLazyListState()
|
CompositionLocalProvider(
|
||||||
LazyColumn(
|
LocalTextStyle provides MaterialTheme.typography.bodySmall.copy(fontFamily = FontFamily.Monospace)
|
||||||
state = scrollState,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.heightIn(max = 320.dp)
|
|
||||||
.clip(RoundedCornerShape(32.dp))
|
|
||||||
.background(brush)
|
|
||||||
.padding(horizontal = 24.dp, vertical = 18.dp)
|
|
||||||
) {
|
) {
|
||||||
items(logs) {
|
val scrollState = rememberLazyListState()
|
||||||
when (it.first) {
|
LazyColumn(
|
||||||
Log.DEBUG -> Text(text = it.second)
|
state = scrollState,
|
||||||
Log.INFO -> Text(text = it.second)
|
modifier = Modifier
|
||||||
Log.ERROR -> Text(text = it.second, color = MaterialTheme.colorScheme.error)
|
.fillMaxWidth()
|
||||||
|
.heightIn(max = shellBoxMaxHeight)
|
||||||
|
.clip(RoundedCornerShape(32.dp))
|
||||||
|
.background(brush)
|
||||||
|
.padding(horizontal = 24.dp, vertical = 18.dp)
|
||||||
|
) {
|
||||||
|
items(logs) {
|
||||||
|
when (it.first) {
|
||||||
|
Log.DEBUG -> Text(text = it.second)
|
||||||
|
Log.INFO -> Text(text = it.second)
|
||||||
|
Log.ERROR -> Text(text = it.second, color = MaterialTheme.colorScheme.error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(scrollState.lastItemIndex) {
|
||||||
|
if (!scrollState.isScrolledToEnd) {
|
||||||
|
scrollState.animateScrollToItem(scrollState.lastItemIndex!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LaunchedEffect(scrollState.lastItemIndex) {
|
if (patchState == PatchState.FINISHED) {
|
||||||
if (!scrollState.isScrolledToEnd) {
|
Row(Modifier.padding(top = 12.dp)) {
|
||||||
scrollState.animateScrollToItem(scrollState.lastItemIndex!!)
|
Button(
|
||||||
}
|
onClick = { navController.popBackStack() },
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
content = { Text(stringResource(R.string.patch_return)) }
|
||||||
|
)
|
||||||
|
Spacer(Modifier.weight(0.2f))
|
||||||
|
Button(
|
||||||
|
onClick = { /* TODO: Install */ },
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
content = { Text(stringResource(R.string.patch_install)) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else if (patchState == PatchState.ERROR) {
|
||||||
|
Row(Modifier.padding(top = 12.dp)) {
|
||||||
|
Button(
|
||||||
|
onClick = { navController.popBackStack() },
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
content = { Text(stringResource(R.string.patch_return)) }
|
||||||
|
)
|
||||||
|
Spacer(Modifier.weight(0.2f))
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
val cm = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
cm.setPrimaryClip(ClipData.newPlainText("LSPatch", logs.joinToString { it.second + "\n" }))
|
||||||
|
},
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
content = { Text(stringResource(R.string.patch_copy_error)) }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (patchState == PatchState.FINISHED) {
|
|
||||||
Row(Modifier.padding(top = 12.dp)) {
|
|
||||||
Button(
|
|
||||||
onClick = { navController.popBackStack() },
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
content = { Text(stringResource(R.string.patch_return)) }
|
|
||||||
)
|
|
||||||
Spacer(Modifier.weight(0.2f))
|
|
||||||
Button(
|
|
||||||
onClick = { /* TODO: Install */ },
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
content = { Text(stringResource(R.string.patch_install)) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else if (patchState == PatchState.ERROR) {
|
|
||||||
Row(Modifier.padding(top = 12.dp)) {
|
|
||||||
Button(
|
|
||||||
onClick = { navController.popBackStack() },
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
content = { Text(stringResource(R.string.patch_return)) }
|
|
||||||
)
|
|
||||||
Spacer(Modifier.weight(0.2f))
|
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
val cm = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
|
||||||
cm.setPrimaryClip(ClipData.newPlainText("LSPatch", logs.joinToString { it.second + "\n" }))
|
|
||||||
},
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
content = { Text(stringResource(R.string.patch_copy_error)) }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue