A notebook's prose is prose on the page; the file copies go when the instance changes
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
A markdown cell had the code's box without its padding. A PDF's page line is read through a derived state, so a scroll redraws it when the page changes and not at every pixel. Switching to another instance clears the cached copies of the first one's files, as signing out does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
3 files changed
+11
-6
No files matched your search
@@ -256,7 +256,11 @@ fun SettingsScreen(onBack: () -> Unit, onAddInstance: () -> Unit) {
|
||||
val actions = remember {
|
||||
object : SettingsActions {
|
||||
override fun use(instance: Instance) {
|
||||
scope.launch { store.use(instance.id) }
|
||||
scope.launch {
|
||||
store.use(instance.id)
|
||||
// Copies of one instance's files are not kept around while another is in use.
|
||||
FileCache.clear(context)
|
||||
}
|
||||
}
|
||||
|
||||
override fun add() = onAddInstance()
|
||||
|
||||
@@ -189,10 +189,8 @@ fun NotebookBody(notebook: Notebook) {
|
||||
Text(
|
||||
cell.source.ifEmpty { " " },
|
||||
style = if (code) mono else MaterialTheme.typography.bodyMedium.copy(color = palette.ink),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(if (code) palette.codeBg else palette.bg, RoundedCornerShape(8.dp))
|
||||
.padding(if (code) 10.dp else 0.dp),
|
||||
// Code sits on the code's ground; a cell of prose is prose on the page.
|
||||
modifier = Modifier.fillMaxWidth().then(if (code) Modifier.background(palette.codeBg, RoundedCornerShape(8.dp)).padding(10.dp) else Modifier),
|
||||
)
|
||||
if (cell.output.isNotEmpty()) {
|
||||
Text(cell.output, style = mono.copy(color = palette.inkMuted), modifier = Modifier.fillMaxWidth().padding(start = 10.dp, top = 6.dp))
|
||||
|
||||
@@ -32,6 +32,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.produceState
|
||||
@@ -233,6 +234,8 @@ fun PdfBody(path: String, name: String, size: Long, fallback: @Composable (Strin
|
||||
private fun PdfPagesList(pages: PdfPages) {
|
||||
val palette = LocalPalette.current
|
||||
val list = rememberLazyListState()
|
||||
// Read through a derived state: the line is drawn again when the page changes, not at every pixel of a scroll.
|
||||
val first by remember { derivedStateOf { list.firstVisibleItemIndex + 1 } }
|
||||
Column(Modifier.fillMaxSize().background(palette.bgSunken)) {
|
||||
BoxWithConstraints(Modifier.weight(1f).fillMaxWidth()) {
|
||||
val width = with(LocalDensity.current) { maxWidth.toPx() }.toInt().coerceIn(1, 1600)
|
||||
@@ -257,7 +260,7 @@ private fun PdfPagesList(pages: PdfPages) {
|
||||
}
|
||||
}
|
||||
Text(
|
||||
stringResource(R.string.viewer_page, (list.firstVisibleItemIndex + 1).toString(), pages.count.toString()),
|
||||
stringResource(R.string.viewer_page, first.toString(), pages.count.toString()),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = palette.inkMuted,
|
||||
modifier = Modifier.fillMaxWidth().background(palette.bg).padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
|
||||
Reference in new issue
Block a user