android: the viewers and Music/Notes take the shared screen header
SubAppScreen's title was already a document's name on three screens (DocumentDetail, EpisodePlayer, PodcastInfo) — but it had no maxLines, so a long episode title wrapped headlineMedium over three lines and pushed the screen down. It is one ellipsised line now, which is what let the viewers adopt it at all. Two slots make the bespoke bars expressible: leading, for a sidebar or drawer toggle that belongs before the title, and subtitle, for a machine measure of where you are in what is open — the comic reader's page label is the one caller. Music, Notes, Pictures, the PDF viewer and the comic reader now use it, which retires NotesTopBar, PicturesTopBar, MusicTopBar, ReaderTopBar and PdfToolbar (whose file, now only the zoom/history row, becomes PdfControls.kt). Three of those screens name the open document rather than the agent, as they did before. Notes and the PDF viewer keep their special back behaviour by passing it as onBack rather than by installing a second BackHandler: in Notes each pane is its own SubAppScreen, so system back in settings returns to the notebook, and in the PDF viewer back closes the drawer before it leaves the document.
This commit is contained in:
1 parent
f34271ab11
commit
d24a6bf1a4
10 files changed
+478
-615
No files matched your search
+53
-101
@@ -1,19 +1,16 @@
|
||||
package com.gregshuflin.synchronicity.comics
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.gestures.rememberTransformableState
|
||||
import androidx.compose.foundation.gestures.transformable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.PagerState
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
@@ -26,7 +23,6 @@ import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -44,10 +40,8 @@ import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.gregshuflin.synchronicity.ui.BackButton
|
||||
import com.gregshuflin.synchronicity.ui.fillMaxSizeWithSafePadding
|
||||
import com.gregshuflin.synchronicity.ui.SubAppScreen
|
||||
import kotlinx.coroutines.launch
|
||||
import uniffi.synchronicity.ComicNode
|
||||
import uniffi.synchronicity.ReadingDirection
|
||||
@@ -86,8 +80,6 @@ fun ComicReaderScreen(
|
||||
direction = effectiveDirection(nodes, node.id)
|
||||
}
|
||||
|
||||
BackHandler { onBack() }
|
||||
|
||||
val pages = open?.pageIds.orEmpty()
|
||||
val pagerState = rememberPagerState(pageCount = { pages.size })
|
||||
|
||||
@@ -108,16 +100,18 @@ fun ComicReaderScreen(
|
||||
offset = Offset.Zero
|
||||
}
|
||||
|
||||
Surface(
|
||||
modifier = modifier.fillMaxSizeWithSafePadding(),
|
||||
color = MaterialTheme.colorScheme.background,
|
||||
) {
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
ReaderTopBar(
|
||||
title = node.title,
|
||||
pageLabel = pageLabel(loaded, pagerState.currentPage, pages.size, open),
|
||||
direction = direction,
|
||||
onToggleDirection = {
|
||||
SubAppScreen(
|
||||
// The comic names the screen; the page count is the measure of where in it you
|
||||
// are, which is what the subtitle line is for.
|
||||
title = node.title,
|
||||
onBack = onBack,
|
||||
modifier = modifier,
|
||||
subtitle =
|
||||
pageLabel(loaded, pagerState.currentPage, pages.size, open).takeIf { it.isNotEmpty() },
|
||||
actions = {
|
||||
FilterChip(
|
||||
selected = direction == ReadingDirection.RIGHT_TO_LEFT,
|
||||
onClick = {
|
||||
val next =
|
||||
if (direction == ReadingDirection.LEFT_TO_RIGHT)
|
||||
ReadingDirection.RIGHT_TO_LEFT
|
||||
@@ -125,56 +119,51 @@ fun ComicReaderScreen(
|
||||
direction = next
|
||||
coroutineScope.launch { repository.setDirection(nodes, node.id, next) }
|
||||
},
|
||||
onBack = onBack,
|
||||
label = { Text(if (direction == ReadingDirection.RIGHT_TO_LEFT) "RTL" else "LTR") },
|
||||
)
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
},
|
||||
) {
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
|
||||
Box(modifier = Modifier.weight(1f).fillMaxWidth()) {
|
||||
when {
|
||||
!loaded ->
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
pages.isEmpty() ->
|
||||
Text(
|
||||
text = "This comic has no readable pages yet.",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.align(Alignment.Center).padding(24.dp),
|
||||
Box(modifier = Modifier.weight(1f).fillMaxWidth()) {
|
||||
when {
|
||||
!loaded -> CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
pages.isEmpty() ->
|
||||
Text(
|
||||
text = "This comic has no readable pages yet.",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.align(Alignment.Center).padding(24.dp),
|
||||
)
|
||||
else ->
|
||||
HorizontalPager(
|
||||
state = pagerState,
|
||||
userScrollEnabled = scale <= MIN_ZOOM + ZOOM_EPSILON,
|
||||
// Manga (right-to-left) reads with "forward" swiping the opposite way
|
||||
// from Western comics — reversing the pager's layout keeps the physical
|
||||
// swipe direction matching the reading order while page indices still
|
||||
// count up in reading order (0 is always the first page).
|
||||
reverseLayout = direction == ReadingDirection.RIGHT_TO_LEFT,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
) { pageIndex ->
|
||||
val isCurrent = pageIndex == pagerState.currentPage
|
||||
ComicPage(
|
||||
repository = repository,
|
||||
pageId = pages[pageIndex],
|
||||
scale = if (isCurrent) scale else MIN_ZOOM,
|
||||
offset = if (isCurrent) offset else Offset.Zero,
|
||||
onTransform = { zoomChange, panChange ->
|
||||
scale = (scale * zoomChange).coerceIn(MIN_ZOOM, MAX_ZOOM)
|
||||
offset = if (scale <= MIN_ZOOM) Offset.Zero else offset + panChange
|
||||
},
|
||||
)
|
||||
else ->
|
||||
HorizontalPager(
|
||||
state = pagerState,
|
||||
userScrollEnabled = scale <= MIN_ZOOM + ZOOM_EPSILON,
|
||||
// Manga (right-to-left) reads with "forward" swiping the opposite way
|
||||
// from Western comics — reversing the pager's layout keeps the physical
|
||||
// swipe direction matching the reading order while page indices still
|
||||
// count up in reading order (0 is always the first page).
|
||||
reverseLayout = direction == ReadingDirection.RIGHT_TO_LEFT,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
) { pageIndex ->
|
||||
val isCurrent = pageIndex == pagerState.currentPage
|
||||
ComicPage(
|
||||
repository = repository,
|
||||
pageId = pages[pageIndex],
|
||||
scale = if (isCurrent) scale else MIN_ZOOM,
|
||||
offset = if (isCurrent) offset else Offset.Zero,
|
||||
onTransform = { zoomChange, panChange ->
|
||||
scale = (scale * zoomChange).coerceIn(MIN_ZOOM, MAX_ZOOM)
|
||||
offset =
|
||||
if (scale <= MIN_ZOOM) Offset.Zero else offset + panChange
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pages.isNotEmpty()) {
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
ReaderBottomBar(
|
||||
pagerState = pagerState,
|
||||
pageCount = pages.size,
|
||||
direction = direction,
|
||||
)
|
||||
}
|
||||
if (pages.isNotEmpty()) {
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
ReaderBottomBar(pagerState = pagerState, pageCount = pages.size, direction = direction)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,43 +209,6 @@ private fun ReaderBottomBar(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ReaderTopBar(
|
||||
title: String,
|
||||
pageLabel: String,
|
||||
direction: ReadingDirection,
|
||||
onToggleDirection: () -> Unit,
|
||||
onBack: () -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Column(modifier = Modifier.weight(1f).padding(start = 8.dp)) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (pageLabel.isNotEmpty()) {
|
||||
Text(
|
||||
text = pageLabel,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
FilterChip(
|
||||
selected = direction == ReadingDirection.RIGHT_TO_LEFT,
|
||||
onClick = onToggleDirection,
|
||||
label = { Text(if (direction == ReadingDirection.RIGHT_TO_LEFT) "RTL" else "LTR") },
|
||||
)
|
||||
Spacer(Modifier.width(4.dp))
|
||||
BackButton(onClick = onBack)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun ComicPage(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gregshuflin.synchronicity.music
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
@@ -21,7 +20,6 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material.icons.filled.MusicNote
|
||||
import androidx.compose.material.icons.filled.Pause
|
||||
@@ -31,7 +29,6 @@ import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.VerticalDivider
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -56,7 +53,7 @@ import com.gregshuflin.synchronicity.podcast.AudioPlayerProvider
|
||||
import com.gregshuflin.synchronicity.podcast.PlaybackState
|
||||
import com.gregshuflin.synchronicity.podcast.ui.formatDuration
|
||||
import com.gregshuflin.synchronicity.ui.MediaSlider
|
||||
import com.gregshuflin.synchronicity.ui.fillMaxSizeWithSafePadding
|
||||
import com.gregshuflin.synchronicity.ui.SubAppScreen
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -92,85 +89,63 @@ fun MusicScreen(onBack: () -> Unit, modifier: Modifier = Modifier) {
|
||||
}
|
||||
}
|
||||
|
||||
BackHandler { onBack() }
|
||||
|
||||
Surface(
|
||||
modifier = modifier.fillMaxSizeWithSafePadding(),
|
||||
color = MaterialTheme.colorScheme.background,
|
||||
SubAppScreen(
|
||||
title = "Music",
|
||||
onBack = onBack,
|
||||
modifier = modifier,
|
||||
leading = {
|
||||
IconButton(onClick = { sidebarVisible = !sidebarVisible }) {
|
||||
Icon(
|
||||
Icons.Default.Menu,
|
||||
contentDescription = if (sidebarVisible) "Hide library" else "Show library",
|
||||
)
|
||||
}
|
||||
},
|
||||
) {
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
MusicTopBar(
|
||||
sidebarVisible = sidebarVisible,
|
||||
onToggleSidebar = { sidebarVisible = !sidebarVisible },
|
||||
onBack = onBack,
|
||||
)
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
MusicContentArea(
|
||||
modifier = Modifier.weight(1f),
|
||||
tracks = tracks,
|
||||
selectedTrack = selectedTrack,
|
||||
blobAvailability = blobAvailability,
|
||||
isLoadingAudio = isLoadingAudio,
|
||||
sidebarVisible = sidebarVisible,
|
||||
onCloseSidebar = { sidebarVisible = false },
|
||||
onOpenSidebar = { sidebarVisible = true },
|
||||
onTrackSelect = { track ->
|
||||
selectedTrack = track
|
||||
blobAvailability = BlobAvailability.Unknown
|
||||
sidebarVisible = false
|
||||
scope.launch {
|
||||
// Availability check is local-only — no network activity.
|
||||
val local = repository.isBlobLocal(track.id)
|
||||
blobAvailability =
|
||||
if (local) BlobAvailability.Local else BlobAvailability.RemoteOnly
|
||||
|
||||
MusicContentArea(
|
||||
modifier = Modifier.weight(1f),
|
||||
tracks = tracks,
|
||||
selectedTrack = selectedTrack,
|
||||
blobAvailability = blobAvailability,
|
||||
isLoadingAudio = isLoadingAudio,
|
||||
sidebarVisible = sidebarVisible,
|
||||
onCloseSidebar = { sidebarVisible = false },
|
||||
onOpenSidebar = { sidebarVisible = true },
|
||||
onTrackSelect = { track ->
|
||||
selectedTrack = track
|
||||
blobAvailability = BlobAvailability.Unknown
|
||||
sidebarVisible = false
|
||||
scope.launch {
|
||||
// Availability check is local-only — no network activity.
|
||||
val local = repository.isBlobLocal(track.id)
|
||||
blobAvailability =
|
||||
if (local) BlobAvailability.Local else BlobAvailability.RemoteOnly
|
||||
|
||||
// Load audio: local path or stream from peer, depending on availability.
|
||||
isLoadingAudio = true
|
||||
val uri = repository.getAudioUri(context, track.id)
|
||||
if (uri != null) {
|
||||
audioPlayerManager.loadUri(uri.toString(), track.title)
|
||||
// If we streamed from a peer, update the label now that it succeeded.
|
||||
if (!local) blobAvailability = BlobAvailability.Streamed
|
||||
}
|
||||
isLoadingAudio = false
|
||||
// Load audio: local path or stream from peer, depending on availability.
|
||||
isLoadingAudio = true
|
||||
val uri = repository.getAudioUri(context, track.id)
|
||||
if (uri != null) {
|
||||
audioPlayerManager.loadUri(uri.toString(), track.title)
|
||||
// If we streamed from a peer, update the label now that it succeeded.
|
||||
if (!local) blobAvailability = BlobAvailability.Streamed
|
||||
}
|
||||
},
|
||||
)
|
||||
isLoadingAudio = false
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
|
||||
MusicPlayerBar(
|
||||
track = selectedTrack,
|
||||
playbackState = playbackState,
|
||||
isLoadingAudio = isLoadingAudio,
|
||||
onPlay = { audioPlayerManager.play() },
|
||||
onPause = { audioPlayerManager.pause() },
|
||||
onSeek = { position -> audioPlayerManager.seekTo(position) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MusicTopBar(sidebarVisible: Boolean, onToggleSidebar: () -> Unit, onBack: () -> Unit) {
|
||||
Box(modifier = Modifier.fillMaxWidth().padding(horizontal = 4.dp)) {
|
||||
Text(
|
||||
text = "Music",
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Medium,
|
||||
modifier = Modifier.align(Alignment.Center),
|
||||
MusicPlayerBar(
|
||||
track = selectedTrack,
|
||||
playbackState = playbackState,
|
||||
isLoadingAudio = isLoadingAudio,
|
||||
onPlay = { audioPlayerManager.play() },
|
||||
onPause = { audioPlayerManager.pause() },
|
||||
onSeek = { position -> audioPlayerManager.seekTo(position) },
|
||||
)
|
||||
IconButton(onClick = onToggleSidebar, modifier = Modifier.align(Alignment.CenterStart)) {
|
||||
Icon(
|
||||
Icons.Default.Menu,
|
||||
contentDescription = if (sidebarVisible) "Hide library" else "Show library",
|
||||
)
|
||||
}
|
||||
IconButton(onClick = onBack, modifier = Modifier.align(Alignment.CenterEnd)) {
|
||||
Icon(Icons.AutoMirrored.Default.ArrowBack, contentDescription = "Back")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
@@ -15,16 +14,19 @@ import androidx.compose.animation.shrinkHorizontally
|
||||
import androidx.compose.foundation.gestures.awaitEachGesture
|
||||
import androidx.compose.foundation.gestures.awaitFirstDown
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.VerticalDivider
|
||||
@@ -47,10 +49,10 @@ import androidx.compose.ui.unit.dp
|
||||
import com.gregshuflin.synchronicity.NativeLib
|
||||
import com.gregshuflin.synchronicity.notes.markup.ImageContext
|
||||
import com.gregshuflin.synchronicity.notes.markup.LinkContext
|
||||
import com.gregshuflin.synchronicity.ui.SubAppScreen
|
||||
import com.gregshuflin.synchronicity.ui.errors.LocalSnackbarController
|
||||
import com.gregshuflin.synchronicity.ui.errors.launchReportingFailure
|
||||
import com.gregshuflin.synchronicity.ui.errors.reportFailure
|
||||
import com.gregshuflin.synchronicity.ui.fillMaxSizeWithSafePadding
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import uniffi.synchronicity.DocumentAvailability
|
||||
@@ -64,8 +66,8 @@ private const val TAG = "NotesScreen"
|
||||
|
||||
/**
|
||||
* Which top-level pane the Notes agent shows — the notebook/note browser, or its own settings
|
||||
* screen (gear icon in [NotesTopBar]). Distinct from [NotesViewMode], which only ever picks how the
|
||||
* *open note's body* renders. See docs/notes-markup-rendering.md §5.5.
|
||||
* screen (gear icon in the Notes header). Distinct from [NotesViewMode], which only ever picks how
|
||||
* the *open note's body* renders. See docs/notes-markup-rendering.md §5.5.
|
||||
*/
|
||||
private enum class NotesScreenPane {
|
||||
NOTEBOOK,
|
||||
@@ -240,221 +242,234 @@ fun NotesScreen(nativeLib: NativeLib, onBack: () -> Unit, modifier: Modifier = M
|
||||
}
|
||||
}
|
||||
|
||||
BackHandler { handleBackNavigation() }
|
||||
|
||||
// ── UI ────────────────────────────────────────────────────────────────────
|
||||
|
||||
Surface(
|
||||
modifier = modifier.fillMaxSizeWithSafePadding(),
|
||||
color = MaterialTheme.colorScheme.background,
|
||||
) {
|
||||
if (screenPane == NotesScreenPane.SETTINGS) {
|
||||
NotesSettingsScreen(
|
||||
mathDialect = mathDialect,
|
||||
onMathDialectChange = { newDialect ->
|
||||
mathDialect = newDialect
|
||||
scope.launchReportingFailure(snackbar, TAG, "change math dialect") {
|
||||
repository.setMathDialect(newDialect).bind()
|
||||
}
|
||||
},
|
||||
proseFont = proseFont,
|
||||
onProseFontChange = { newFont ->
|
||||
proseFont = newFont
|
||||
scope.launchReportingFailure(snackbar, TAG, "change note body typeface") {
|
||||
nativeLib.settings.setProseFont(newFont).bind()
|
||||
}
|
||||
},
|
||||
onBack = { screenPane = NotesScreenPane.NOTEBOOK },
|
||||
)
|
||||
} else {
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
NotesTopBar(
|
||||
leftSidebarVisible = leftSidebarVisible,
|
||||
onToggleLeftSidebar = {
|
||||
// Each pane is its own SubAppScreen, so each brings its own back handling: system
|
||||
// back in settings returns to the notebook rather than leaving Notes altogether.
|
||||
if (screenPane == NotesScreenPane.SETTINGS) {
|
||||
NotesSettingsScreen(
|
||||
modifier = modifier,
|
||||
mathDialect = mathDialect,
|
||||
onMathDialectChange = { newDialect ->
|
||||
mathDialect = newDialect
|
||||
scope.launchReportingFailure(snackbar, TAG, "change math dialect") {
|
||||
repository.setMathDialect(newDialect).bind()
|
||||
}
|
||||
},
|
||||
proseFont = proseFont,
|
||||
onProseFontChange = { newFont ->
|
||||
proseFont = newFont
|
||||
scope.launchReportingFailure(snackbar, TAG, "change note body typeface") {
|
||||
nativeLib.settings.setProseFont(newFont).bind()
|
||||
}
|
||||
},
|
||||
onBack = { screenPane = NotesScreenPane.NOTEBOOK },
|
||||
)
|
||||
} else {
|
||||
SubAppScreen(
|
||||
title = "Notes",
|
||||
onBack = { handleBackNavigation() },
|
||||
modifier = modifier,
|
||||
leading = {
|
||||
IconButton(
|
||||
onClick = {
|
||||
leftSidebarVisible = !leftSidebarVisible
|
||||
if (leftSidebarVisible) rightSidebarVisible = false
|
||||
},
|
||||
rightSidebarVisible = rightSidebarVisible,
|
||||
onToggleRightSidebar = {
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.Menu,
|
||||
contentDescription =
|
||||
if (leftSidebarVisible) "Hide sidebar" else "Show sidebar",
|
||||
)
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
IconButton(onClick = { screenPane = NotesScreenPane.SETTINGS }) {
|
||||
Icon(Icons.Default.Settings, contentDescription = "Notes settings")
|
||||
}
|
||||
IconButton(
|
||||
onClick = {
|
||||
rightSidebarVisible = !rightSidebarVisible
|
||||
if (rightSidebarVisible) leftSidebarVisible = false
|
||||
},
|
||||
onBack = { handleBackNavigation() },
|
||||
onOpenSettings = { screenPane = NotesScreenPane.SETTINGS },
|
||||
)
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.Menu,
|
||||
contentDescription = if (rightSidebarVisible) "Hide panel" else "Show panel",
|
||||
)
|
||||
}
|
||||
},
|
||||
) {
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
|
||||
NotesContentArea(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
noteId = selectedNoteId,
|
||||
title = editingTitle,
|
||||
body = editingBody,
|
||||
format = editingFormat,
|
||||
bodyAvailability = bodyAvailability,
|
||||
onAbandonAbsentBody = {
|
||||
val id = selectedNoteId
|
||||
if (id != null) {
|
||||
scope.launchReportingFailure(snackbar, TAG, "start this note over") {
|
||||
repository.abandonAbsentBody(id).bind()
|
||||
val note = repository.getNote(id)
|
||||
editingBody = note.content.body
|
||||
editingFormat = note.content.format
|
||||
bodyAvailability = note.availability
|
||||
}
|
||||
NotesContentArea(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
noteId = selectedNoteId,
|
||||
title = editingTitle,
|
||||
body = editingBody,
|
||||
format = editingFormat,
|
||||
bodyAvailability = bodyAvailability,
|
||||
onAbandonAbsentBody = {
|
||||
val id = selectedNoteId
|
||||
if (id != null) {
|
||||
scope.launchReportingFailure(snackbar, TAG, "start this note over") {
|
||||
repository.abandonAbsentBody(id).bind()
|
||||
val note = repository.getNote(id)
|
||||
editingBody = note.content.body
|
||||
editingFormat = note.content.format
|
||||
bodyAvailability = note.availability
|
||||
}
|
||||
},
|
||||
viewMode = viewMode,
|
||||
mathDialect = mathDialect,
|
||||
proseFont = proseFont,
|
||||
wikilinkTitles = wikilinkTitles,
|
||||
linkContext = linkContext,
|
||||
imageContext = imageContext,
|
||||
onTitleChange = { editingTitle = it },
|
||||
onBodyChange = { editingBody = it },
|
||||
onFormatChange = { newFormat ->
|
||||
editingFormat = newFormat
|
||||
val id = selectedNoteId
|
||||
if (id != null) {
|
||||
// Genuinely unexpected past this point: the format is its own
|
||||
// artifact, so this applies even to a note whose body hasn't
|
||||
// synced to this device.
|
||||
scope.launchReportingFailure(snackbar, TAG, "change format") {
|
||||
repository.setNoteFormat(id, newFormat).bind()
|
||||
}
|
||||
}
|
||||
},
|
||||
viewMode = viewMode,
|
||||
mathDialect = mathDialect,
|
||||
proseFont = proseFont,
|
||||
wikilinkTitles = wikilinkTitles,
|
||||
linkContext = linkContext,
|
||||
imageContext = imageContext,
|
||||
onTitleChange = { editingTitle = it },
|
||||
onBodyChange = { editingBody = it },
|
||||
onFormatChange = { newFormat ->
|
||||
editingFormat = newFormat
|
||||
val id = selectedNoteId
|
||||
if (id != null) {
|
||||
// Genuinely unexpected past this point: the format is its own
|
||||
// artifact, so this applies even to a note whose body hasn't
|
||||
// synced to this device.
|
||||
scope.launchReportingFailure(snackbar, TAG, "change format") {
|
||||
repository.setNoteFormat(id, newFormat).bind()
|
||||
}
|
||||
},
|
||||
onViewModeChange = { newMode ->
|
||||
// NoteEditorPane already calls onSaveRequest (below) when a mode change
|
||||
// makes the source no longer editable — this just updates/persists the
|
||||
// mode.
|
||||
viewMode = newMode
|
||||
scope.launchReportingFailure(snackbar, TAG, "change view mode") {
|
||||
repository.setViewMode(newMode).bind()
|
||||
}
|
||||
},
|
||||
onViewModeChange = { newMode ->
|
||||
// NoteEditorPane already calls onSaveRequest (below) when a mode change
|
||||
// makes the source no longer editable — this just updates/persists the
|
||||
// mode.
|
||||
viewMode = newMode
|
||||
scope.launchReportingFailure(snackbar, TAG, "change view mode") {
|
||||
repository.setViewMode(newMode).bind()
|
||||
}
|
||||
},
|
||||
leftSidebarVisible = leftSidebarVisible,
|
||||
rightSidebarVisible = rightSidebarVisible,
|
||||
onCloseLeftSidebar = { leftSidebarVisible = false },
|
||||
onCloseRightSidebar = { rightSidebarVisible = false },
|
||||
onOpenLeftSidebar = { leftSidebarVisible = true },
|
||||
onOpenRightSidebar = { rightSidebarVisible = true },
|
||||
onSaveRequest = {
|
||||
scope.launch {
|
||||
saveCurrentNote()
|
||||
reloadCurrentNotebook()
|
||||
}
|
||||
},
|
||||
leftSidebarOverlay = {
|
||||
AnimatedVisibility(
|
||||
visible = leftSidebarVisible,
|
||||
enter =
|
||||
expandHorizontally(
|
||||
animationSpec =
|
||||
tween(
|
||||
durationMillis = ANIM_DURATION_ENTER_MS,
|
||||
easing = FastOutSlowInEasing,
|
||||
),
|
||||
expandFrom = Alignment.Start,
|
||||
),
|
||||
exit =
|
||||
shrinkHorizontally(
|
||||
animationSpec =
|
||||
tween(
|
||||
durationMillis = ANIM_DURATION_EXIT_MS,
|
||||
easing = FastOutSlowInEasing,
|
||||
),
|
||||
shrinkTowards = Alignment.Start,
|
||||
),
|
||||
) {
|
||||
Row {
|
||||
NotebookSidebar(
|
||||
modifier = Modifier.width(SIDEBAR_WIDTH_DP.dp),
|
||||
notebooks = notebooks,
|
||||
selectedNotebookId = selectedNotebookId,
|
||||
selectedNoteId = selectedNoteId,
|
||||
searchQuery = searchQuery,
|
||||
onSearchQueryChange = { searchQuery = it },
|
||||
onNotebookSelect = { id ->
|
||||
scope.launch {
|
||||
saveCurrentNote()
|
||||
selectedNotebookId = id
|
||||
selectedNoteId = null
|
||||
}
|
||||
},
|
||||
onCreateNotebook = { showCreateNotebookDialog = true },
|
||||
onNoteSelect = { id ->
|
||||
scope.launch {
|
||||
saveCurrentNote()
|
||||
selectedNoteId = id
|
||||
leftSidebarVisible = false
|
||||
}
|
||||
},
|
||||
onCollectionToggle = { collectionId ->
|
||||
val nbId = selectedNotebookId
|
||||
if (nbId != null) {
|
||||
notebooks =
|
||||
notebooks.map { nb ->
|
||||
if (nb.id == nbId)
|
||||
nb.copy(
|
||||
items =
|
||||
nb.items.toggleCollection(collectionId)
|
||||
)
|
||||
else nb
|
||||
}
|
||||
}
|
||||
},
|
||||
onCreateNote = { parentCollectionId ->
|
||||
createNoteInCollection = parentCollectionId
|
||||
},
|
||||
onCreateCollection = { parentCollectionId ->
|
||||
createCollectionInCollection = parentCollectionId
|
||||
},
|
||||
onRename = { id, currentTitle ->
|
||||
renameTarget = Pair(id, currentTitle)
|
||||
},
|
||||
onDelete = { id -> deleteTarget = id },
|
||||
)
|
||||
VerticalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
}
|
||||
},
|
||||
leftSidebarVisible = leftSidebarVisible,
|
||||
rightSidebarVisible = rightSidebarVisible,
|
||||
onCloseLeftSidebar = { leftSidebarVisible = false },
|
||||
onCloseRightSidebar = { rightSidebarVisible = false },
|
||||
onOpenLeftSidebar = { leftSidebarVisible = true },
|
||||
onOpenRightSidebar = { rightSidebarVisible = true },
|
||||
onSaveRequest = {
|
||||
scope.launch {
|
||||
saveCurrentNote()
|
||||
reloadCurrentNotebook()
|
||||
}
|
||||
},
|
||||
rightSidebarOverlay = {
|
||||
AnimatedVisibility(
|
||||
visible = rightSidebarVisible,
|
||||
enter =
|
||||
expandHorizontally(
|
||||
animationSpec =
|
||||
tween(
|
||||
durationMillis = ANIM_DURATION_ENTER_MS,
|
||||
easing = FastOutSlowInEasing,
|
||||
),
|
||||
expandFrom = Alignment.End,
|
||||
),
|
||||
exit =
|
||||
shrinkHorizontally(
|
||||
animationSpec =
|
||||
tween(
|
||||
durationMillis = ANIM_DURATION_EXIT_MS,
|
||||
easing = FastOutSlowInEasing,
|
||||
),
|
||||
shrinkTowards = Alignment.End,
|
||||
),
|
||||
) {
|
||||
Row {
|
||||
VerticalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
NoteTabSidebar(
|
||||
modifier = Modifier.width(SIDEBAR_WIDTH_DP.dp).fillMaxHeight(),
|
||||
activeTab = activeRightTab,
|
||||
onTabSelect = { activeRightTab = it },
|
||||
)
|
||||
}
|
||||
},
|
||||
leftSidebarOverlay = {
|
||||
AnimatedVisibility(
|
||||
visible = leftSidebarVisible,
|
||||
enter =
|
||||
expandHorizontally(
|
||||
animationSpec =
|
||||
tween(
|
||||
durationMillis = ANIM_DURATION_ENTER_MS,
|
||||
easing = FastOutSlowInEasing,
|
||||
),
|
||||
expandFrom = Alignment.Start,
|
||||
),
|
||||
exit =
|
||||
shrinkHorizontally(
|
||||
animationSpec =
|
||||
tween(
|
||||
durationMillis = ANIM_DURATION_EXIT_MS,
|
||||
easing = FastOutSlowInEasing,
|
||||
),
|
||||
shrinkTowards = Alignment.Start,
|
||||
),
|
||||
) {
|
||||
Row {
|
||||
NotebookSidebar(
|
||||
modifier = Modifier.width(SIDEBAR_WIDTH_DP.dp),
|
||||
notebooks = notebooks,
|
||||
selectedNotebookId = selectedNotebookId,
|
||||
selectedNoteId = selectedNoteId,
|
||||
searchQuery = searchQuery,
|
||||
onSearchQueryChange = { searchQuery = it },
|
||||
onNotebookSelect = { id ->
|
||||
scope.launch {
|
||||
saveCurrentNote()
|
||||
selectedNotebookId = id
|
||||
selectedNoteId = null
|
||||
}
|
||||
},
|
||||
onCreateNotebook = { showCreateNotebookDialog = true },
|
||||
onNoteSelect = { id ->
|
||||
scope.launch {
|
||||
saveCurrentNote()
|
||||
selectedNoteId = id
|
||||
leftSidebarVisible = false
|
||||
}
|
||||
},
|
||||
onCollectionToggle = { collectionId ->
|
||||
val nbId = selectedNotebookId
|
||||
if (nbId != null) {
|
||||
notebooks =
|
||||
notebooks.map { nb ->
|
||||
if (nb.id == nbId)
|
||||
nb.copy(
|
||||
items =
|
||||
nb.items.toggleCollection(
|
||||
collectionId
|
||||
)
|
||||
)
|
||||
else nb
|
||||
}
|
||||
}
|
||||
},
|
||||
onCreateNote = { parentCollectionId ->
|
||||
createNoteInCollection = parentCollectionId
|
||||
},
|
||||
onCreateCollection = { parentCollectionId ->
|
||||
createCollectionInCollection = parentCollectionId
|
||||
},
|
||||
onRename = { id, currentTitle ->
|
||||
renameTarget = Pair(id, currentTitle)
|
||||
},
|
||||
onDelete = { id -> deleteTarget = id },
|
||||
)
|
||||
VerticalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
}
|
||||
}
|
||||
},
|
||||
rightSidebarOverlay = {
|
||||
AnimatedVisibility(
|
||||
visible = rightSidebarVisible,
|
||||
enter =
|
||||
expandHorizontally(
|
||||
animationSpec =
|
||||
tween(
|
||||
durationMillis = ANIM_DURATION_ENTER_MS,
|
||||
easing = FastOutSlowInEasing,
|
||||
),
|
||||
expandFrom = Alignment.End,
|
||||
),
|
||||
exit =
|
||||
shrinkHorizontally(
|
||||
animationSpec =
|
||||
tween(
|
||||
durationMillis = ANIM_DURATION_EXIT_MS,
|
||||
easing = FastOutSlowInEasing,
|
||||
),
|
||||
shrinkTowards = Alignment.End,
|
||||
),
|
||||
) {
|
||||
Row {
|
||||
VerticalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
NoteTabSidebar(
|
||||
modifier = Modifier.width(SIDEBAR_WIDTH_DP.dp).fillMaxHeight(),
|
||||
activeTab = activeRightTab,
|
||||
onTabSelect = { activeRightTab = it },
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ import uniffi.synchronicity.ProseFont
|
||||
/**
|
||||
* The Notes agent's own settings screen — a statement about how *this* Notes agent's markup is
|
||||
* authored (currently just the math dialect), which is why it lives here rather than as a tab on
|
||||
* the shared Settings screen (`settings/SettingsScreen.kt`). Reached via the gear icon in
|
||||
* `NotesTopBar`, per docs/notes-markup-rendering.md §5.5/§6.
|
||||
* the shared Settings screen (`settings/SettingsScreen.kt`). Reached via the gear icon in the Notes
|
||||
* header, per docs/notes-markup-rendering.md §5.5/§6.
|
||||
*/
|
||||
@Composable
|
||||
fun NotesSettingsScreen(
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.gregshuflin.synchronicity.notes
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
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.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
internal fun NotesTopBar(
|
||||
leftSidebarVisible: Boolean,
|
||||
onToggleLeftSidebar: () -> Unit,
|
||||
rightSidebarVisible: Boolean,
|
||||
onToggleRightSidebar: () -> Unit,
|
||||
onBack: () -> Unit,
|
||||
onOpenSettings: () -> Unit,
|
||||
) {
|
||||
Box(modifier = Modifier.fillMaxWidth().padding(horizontal = 4.dp)) {
|
||||
Text(
|
||||
text = "Notes",
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Medium,
|
||||
modifier = Modifier.align(Alignment.Center),
|
||||
)
|
||||
IconButton(
|
||||
onClick = onToggleLeftSidebar,
|
||||
modifier = Modifier.align(Alignment.CenterStart),
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.Menu,
|
||||
contentDescription = if (leftSidebarVisible) "Hide sidebar" else "Show sidebar",
|
||||
)
|
||||
}
|
||||
Row(modifier = Modifier.align(Alignment.CenterEnd)) {
|
||||
IconButton(onClick = onOpenSettings) {
|
||||
Icon(Icons.Default.Settings, contentDescription = "Notes settings")
|
||||
}
|
||||
IconButton(onClick = onToggleRightSidebar) {
|
||||
Icon(
|
||||
Icons.Default.Menu,
|
||||
contentDescription = if (rightSidebarVisible) "Hide panel" else "Show panel",
|
||||
)
|
||||
}
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(Icons.AutoMirrored.Default.ArrowBack, contentDescription = "Back")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-34
@@ -5,7 +5,6 @@ import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowForward
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material.icons.filled.Remove
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
@@ -15,40 +14,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.gregshuflin.synchronicity.ui.BackButton
|
||||
|
||||
@Composable
|
||||
fun PdfToolbar(
|
||||
title: String,
|
||||
onMenuClick: () -> Unit,
|
||||
onBack: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Row(
|
||||
modifier =
|
||||
modifier.fillMaxWidth().padding(start = 4.dp, end = 16.dp, top = 8.dp, bottom = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
IconButton(onClick = onMenuClick) {
|
||||
Icon(
|
||||
Icons.Default.Menu,
|
||||
contentDescription = "Menu",
|
||||
tint = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
BackButton(onClick = onBack)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Secondary controls row shown directly below the title: visited-page history arrows on the left
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gregshuflin.synchronicity.pdfs
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
@@ -9,6 +8,7 @@ import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -22,9 +22,9 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.gregshuflin.synchronicity.NativeLib
|
||||
import com.gregshuflin.synchronicity.ui.SectionHeading
|
||||
import com.gregshuflin.synchronicity.ui.SubAppScreen
|
||||
import com.gregshuflin.synchronicity.ui.errors.LocalSnackbarController
|
||||
import com.gregshuflin.synchronicity.ui.errors.launchReportingFailure
|
||||
import com.gregshuflin.synchronicity.ui.fillMaxSizeWithSafePadding
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -103,14 +103,6 @@ private fun PdfViewerScreenContent(
|
||||
|
||||
LaunchedEffect(documentId) { reloadBookmarks() }
|
||||
|
||||
BackHandler {
|
||||
if (drawerState.isOpen) {
|
||||
scope.launch { drawerState.close() }
|
||||
} else {
|
||||
onBack()
|
||||
}
|
||||
}
|
||||
|
||||
ModalNavigationDrawer(
|
||||
drawerState = drawerState,
|
||||
drawerContent = {
|
||||
@@ -155,13 +147,30 @@ private fun PdfViewerScreenContent(
|
||||
)
|
||||
},
|
||||
) {
|
||||
Column(modifier = Modifier.fillMaxSizeWithSafePadding()) {
|
||||
PdfToolbar(
|
||||
title = pdfName,
|
||||
onMenuClick = { scope.launch { drawerState.open() } },
|
||||
onBack = onBack,
|
||||
)
|
||||
|
||||
SubAppScreen(
|
||||
// The open PDF names the screen, so this is the one title the user cares
|
||||
// about here — "PDF" would name a category they already knew they were in.
|
||||
title = pdfName,
|
||||
// Back closes the drawer before it leaves the document. The header's own
|
||||
// button is under the scrim while the drawer is open, so both affordances
|
||||
// can share one answer.
|
||||
onBack = {
|
||||
if (drawerState.isOpen) {
|
||||
scope.launch { drawerState.close() }
|
||||
} else {
|
||||
onBack()
|
||||
}
|
||||
},
|
||||
leading = {
|
||||
IconButton(onClick = { scope.launch { drawerState.open() } }) {
|
||||
Icon(
|
||||
Icons.Default.Menu,
|
||||
contentDescription = "Menu",
|
||||
tint = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
}
|
||||
},
|
||||
) {
|
||||
PdfControlsRow(state = pdfState)
|
||||
|
||||
PdfViewer(
|
||||
|
||||
+74
-106
@@ -1,7 +1,6 @@
|
||||
package com.gregshuflin.synchronicity.pictures
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.tween
|
||||
@@ -38,7 +37,6 @@ import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.VerticalDivider
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -61,10 +59,9 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.gregshuflin.synchronicity.NativeLib
|
||||
import com.gregshuflin.synchronicity.ui.BackButton
|
||||
import com.gregshuflin.synchronicity.ui.SectionHeading
|
||||
import com.gregshuflin.synchronicity.ui.SubAppScreen
|
||||
import com.gregshuflin.synchronicity.ui.SynSearchBar
|
||||
import com.gregshuflin.synchronicity.ui.fillMaxSizeWithSafePadding
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import uniffi.synchronicity.DocumentItem
|
||||
@@ -93,8 +90,6 @@ fun PicturesScreen(nativeLib: NativeLib, onBack: () -> Unit, modifier: Modifier
|
||||
var offset by remember { mutableStateOf(Offset.Zero) }
|
||||
var rotationDeg by remember { mutableFloatStateOf(0f) }
|
||||
|
||||
BackHandler { onBack() }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
val loaded =
|
||||
withContext(Dispatchers.IO) {
|
||||
@@ -130,84 +125,86 @@ fun PicturesScreen(nativeLib: NativeLib, onBack: () -> Unit, modifier: Modifier
|
||||
|
||||
val selectedIndex = images.indexOfFirst { it.id == selectedId }
|
||||
|
||||
Surface(
|
||||
modifier = modifier.fillMaxSizeWithSafePadding(),
|
||||
color = MaterialTheme.colorScheme.background,
|
||||
SubAppScreen(
|
||||
// The open picture names the screen; "Pictures" is only the empty-library case.
|
||||
title = images.find { it.id == selectedId }?.title ?: "Pictures",
|
||||
onBack = onBack,
|
||||
modifier = modifier,
|
||||
leading = {
|
||||
IconButton(onClick = { sidebarVisible = !sidebarVisible }) {
|
||||
Icon(
|
||||
Icons.Default.Menu,
|
||||
contentDescription = if (sidebarVisible) "Close library" else "Open library",
|
||||
tint = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
}
|
||||
},
|
||||
) {
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
PicturesTopBar(
|
||||
title = images.find { it.id == selectedId }?.title ?: "Pictures",
|
||||
sidebarVisible = sidebarVisible,
|
||||
onToggleSidebar = { sidebarVisible = !sidebarVisible },
|
||||
onBack = onBack,
|
||||
)
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
PicturesRotateBar(
|
||||
onRotateCcw = { rotationDeg = (rotationDeg - 90f) % 360f },
|
||||
onRotateCw = { rotationDeg = (rotationDeg + 90f) % 360f },
|
||||
)
|
||||
|
||||
PicturesRotateBar(
|
||||
onRotateCcw = { rotationDeg = (rotationDeg - 90f) % 360f },
|
||||
onRotateCw = { rotationDeg = (rotationDeg + 90f) % 360f },
|
||||
)
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
|
||||
PicturesContentArea(
|
||||
modifier = Modifier.weight(1f).fillMaxWidth(),
|
||||
loadState = loadState,
|
||||
scale = scale,
|
||||
offset = offset,
|
||||
rotationDeg = rotationDeg,
|
||||
onTransform = { scaleChange, panChange ->
|
||||
scale = (scale * scaleChange).coerceIn(MIN_ZOOM, MAX_ZOOM)
|
||||
offset = offset + panChange
|
||||
},
|
||||
sidebarOverlay = {
|
||||
AnimatedVisibility(
|
||||
visible = sidebarVisible,
|
||||
enter =
|
||||
expandHorizontally(
|
||||
animationSpec = tween(ANIM_ENTER_MS, easing = FastOutSlowInEasing),
|
||||
expandFrom = Alignment.Start,
|
||||
),
|
||||
exit =
|
||||
shrinkHorizontally(
|
||||
animationSpec = tween(ANIM_EXIT_MS, easing = FastOutSlowInEasing),
|
||||
shrinkTowards = Alignment.Start,
|
||||
),
|
||||
) {
|
||||
Row {
|
||||
ImageLibrarySidebar(
|
||||
images = images,
|
||||
selectedId = selectedId,
|
||||
modifier = Modifier.width(SIDEBAR_WIDTH_DP.dp),
|
||||
onImageSelect = { id ->
|
||||
selectedId = id
|
||||
sidebarVisible = false
|
||||
},
|
||||
)
|
||||
VerticalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
}
|
||||
PicturesContentArea(
|
||||
modifier = Modifier.weight(1f).fillMaxWidth(),
|
||||
loadState = loadState,
|
||||
scale = scale,
|
||||
offset = offset,
|
||||
rotationDeg = rotationDeg,
|
||||
onTransform = { scaleChange, panChange ->
|
||||
scale = (scale * scaleChange).coerceIn(MIN_ZOOM, MAX_ZOOM)
|
||||
offset = offset + panChange
|
||||
},
|
||||
sidebarOverlay = {
|
||||
AnimatedVisibility(
|
||||
visible = sidebarVisible,
|
||||
enter =
|
||||
expandHorizontally(
|
||||
animationSpec = tween(ANIM_ENTER_MS, easing = FastOutSlowInEasing),
|
||||
expandFrom = Alignment.Start,
|
||||
),
|
||||
exit =
|
||||
shrinkHorizontally(
|
||||
animationSpec = tween(ANIM_EXIT_MS, easing = FastOutSlowInEasing),
|
||||
shrinkTowards = Alignment.Start,
|
||||
),
|
||||
) {
|
||||
Row {
|
||||
ImageLibrarySidebar(
|
||||
images = images,
|
||||
selectedId = selectedId,
|
||||
modifier = Modifier.width(SIDEBAR_WIDTH_DP.dp),
|
||||
onImageSelect = { id ->
|
||||
selectedId = id
|
||||
sidebarVisible = false
|
||||
},
|
||||
)
|
||||
VerticalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
|
||||
PicturesBottomBar(
|
||||
scale = scale,
|
||||
hasPrevious = selectedIndex > 0,
|
||||
hasNext = selectedIndex in 0 until images.size - 1,
|
||||
onResetZoom = {
|
||||
scale = 1f
|
||||
offset = Offset.Zero
|
||||
},
|
||||
onPrevious = { if (selectedIndex > 0) selectedId = images[selectedIndex - 1].id },
|
||||
onNext = {
|
||||
if (selectedIndex in 0 until images.size - 1)
|
||||
selectedId = images[selectedIndex + 1].id
|
||||
},
|
||||
)
|
||||
}
|
||||
PicturesBottomBar(
|
||||
scale = scale,
|
||||
hasPrevious = selectedIndex > 0,
|
||||
hasNext = selectedIndex in 0 until images.size - 1,
|
||||
onResetZoom = {
|
||||
scale = 1f
|
||||
offset = Offset.Zero
|
||||
},
|
||||
onPrevious = { if (selectedIndex > 0) selectedId = images[selectedIndex - 1].id },
|
||||
onNext = {
|
||||
if (selectedIndex in 0 until images.size - 1)
|
||||
selectedId = images[selectedIndex + 1].id
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,35 +236,6 @@ private fun PicturesContentArea(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PicturesTopBar(
|
||||
title: String,
|
||||
sidebarVisible: Boolean,
|
||||
onToggleSidebar: () -> Unit,
|
||||
onBack: () -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 4.dp, vertical = 2.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
IconButton(onClick = onToggleSidebar) {
|
||||
Icon(
|
||||
Icons.Default.Menu,
|
||||
contentDescription = if (sidebarVisible) "Close library" else "Open library",
|
||||
tint = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
modifier = Modifier.weight(1f),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
BackButton(onClick = onBack)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PicturesRotateBar(onRotateCcw: () -> Unit, onRotateCw: () -> Unit) {
|
||||
Row(
|
||||
|
||||
@@ -8,8 +8,15 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
/** Start padding of the header row when a [SubAppScreen] leading control sits in it. */
|
||||
private val LEADING_START_PADDING = 4.dp
|
||||
|
||||
/** Start padding of the header row with no leading control, and its padding everywhere else. */
|
||||
private val HEADER_PADDING = 16.dp
|
||||
|
||||
/**
|
||||
* The one screen header, and the shell every agent screen sits in.
|
||||
*
|
||||
@@ -20,6 +27,15 @@ import androidx.compose.ui.unit.dp
|
||||
* it here rather than placing a bar somewhere in their own content, which is what produced four
|
||||
* different search placements across five screens.
|
||||
*
|
||||
* **The title is often not the screen's name.** A viewer or a detail screen names the thing it has
|
||||
* open — the document, the episode, the comic — and those names are arbitrary length, so the title
|
||||
* is always one ellipsised line. A header that grew to three lines because a podcast episode had a
|
||||
* long title would push the thing being read off the screen.
|
||||
*
|
||||
* @param leading a control that belongs *before* the title, which in practice means a sidebar or
|
||||
* drawer toggle for the screen's own navigation. Screen-level actions go in [actions] instead.
|
||||
* @param subtitle a second line under the title, for a machine-ish measure of what is open ("Page 4
|
||||
* of 122"). Not for a description — it is one ellipsised line in a dim tone.
|
||||
* @param search the screen's filter bar, usually a [SynSearchBar]. Null for screens with nothing to
|
||||
* filter, which is most of them.
|
||||
*/
|
||||
@@ -32,6 +48,8 @@ fun SubAppScreen(
|
||||
// (e.g. a screen with its own bottom navigation bar), set this to false so the
|
||||
// window insets aren't padded twice.
|
||||
applySafePadding: Boolean = true,
|
||||
leading: (@Composable () -> Unit)? = null,
|
||||
subtitle: String? = null,
|
||||
actions: @Composable RowScope.() -> Unit = {},
|
||||
search: (@Composable () -> Unit)? = null,
|
||||
content: @Composable ColumnScope.() -> Unit,
|
||||
@@ -46,15 +64,36 @@ fun SubAppScreen(
|
||||
) {
|
||||
Column {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
modifier =
|
||||
Modifier.fillMaxWidth()
|
||||
.padding(
|
||||
// A leading icon button carries its own tap-target padding, so the
|
||||
// full gutter on top of it would inset the glyph twice over.
|
||||
start = if (leading == null) HEADER_PADDING else LEADING_START_PADDING,
|
||||
end = HEADER_PADDING,
|
||||
top = HEADER_PADDING,
|
||||
bottom = HEADER_PADDING,
|
||||
),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
leading?.invoke()
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (subtitle != null) {
|
||||
Text(
|
||||
text = subtitle,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
actions()
|
||||
BackButton(onClick = onBack)
|
||||
}
|
||||
|
||||
@@ -836,7 +836,7 @@ on every recomposition — the LRU that actually matters is still the one
|
||||
inside the Rust call.
|
||||
|
||||
The Notes agent also gained the first per-agent settings screen on Android
|
||||
(`NotesSettingsScreen.kt`, reached via a gear icon in `NotesTopBar`, with a
|
||||
(`NotesSettingsScreen.kt`, reached via the gear icon in the Notes header, with a
|
||||
private `NotesScreenPane` enum in `NotesScreen.kt` picking between it and the
|
||||
notebook browser — distinct from `NotesViewMode`, exactly the same
|
||||
Notebook/Settings-vs-Edit/Preview/Split distinction §5.5 draws on desktop).
|
||||
|
||||
Reference in new issue
Block a user