diff --git a/app/src/main/kotlin/com/stacknoise/haac/app/navigation/ListDetail.kt b/app/src/main/kotlin/com/stacknoise/haac/app/navigation/ListDetail.kt
index c698933..68f7724 100644
--- a/app/src/main/kotlin/com/stacknoise/haac/app/navigation/ListDetail.kt
+++ b/app/src/main/kotlin/com/stacknoise/haac/app/navigation/ListDetail.kt
@@ -23,6 +23,7 @@ import androidx.navigation.NavController
import com.stacknoise.haac.R
import com.stacknoise.haac.core.common.ui.EditorSideSheetWidth
import com.stacknoise.haac.core.common.ui.HaacSideSheet
+import com.stacknoise.haac.core.common.ui.ListPaneWidth
import com.stacknoise.haac.core.common.ui.LocalWindowWidthClass
import com.stacknoise.haac.core.common.ui.WindowWidthClass
import com.stacknoise.haac.core.common.ui.argsViewModel
@@ -37,9 +38,6 @@ import com.stacknoise.haac.feature.schedules.ui.ScheduleEditorScreen
import com.stacknoise.haac.feature.schedules.ui.ScheduleEditorViewModel
import com.stacknoise.haac.feature.schedules.ui.SchedulesScreen
-/** Width of the list beside its detail in landscape (concept 15.7). */
-private val ListWidth = 420.dp
-
/**
* The list with its detail (concept 15.7): beside each other in Expanded, with an empty state with [emptyText] while
* nothing is open; in Medium the list alone and the detail in a side sheet of [sheetWidth]. [onDismiss] closes it.
@@ -55,7 +53,7 @@ private fun ListDetailHost(
) {
if (LocalWindowWidthClass.current == WindowWidthClass.Expanded) {
Row(modifier = Modifier.fillMaxSize()) {
- Box(modifier = Modifier.width(ListWidth).fillMaxHeight().border(1.dp, HaacColors.Outline)) { list() }
+ Box(modifier = Modifier.width(ListPaneWidth).fillMaxHeight().border(1.dp, HaacColors.Outline)) { list() }
Box(modifier = Modifier.weight(1f).fillMaxHeight()) {
if (detailOpen) {
detail()
diff --git a/core/common/src/main/kotlin/com/stacknoise/haac/core/common/ui/CenteredContent.kt b/core/common/src/main/kotlin/com/stacknoise/haac/core/common/ui/CenteredContent.kt
index dd4fa51..a89b410 100644
--- a/core/common/src/main/kotlin/com/stacknoise/haac/core/common/ui/CenteredContent.kt
+++ b/core/common/src/main/kotlin/com/stacknoise/haac/core/common/ui/CenteredContent.kt
@@ -15,6 +15,9 @@ val ReadableContentWidth: Dp = 640.dp
/** Width of the card on the sign-in and lock screens from the medium class on (concept 15.7). */
val CardContentWidth: Dp = 480.dp
+/** Width of the list pane next to a detail pane in the expanded class (concept 15.7). */
+val ListPaneWidth: Dp = 420.dp
+
/**
* Limits the content to [maxWidth] and centres it; Compact keeps the full width.
*
diff --git a/docs/code-index.md b/docs/code-index.md
index 34ff8d6..9eca3fb 100644
--- a/docs/code-index.md
+++ b/docs/code-index.md
@@ -2068,7 +2068,9 @@ Lists every class and function of the app with signature, file and a one-line KD
| `runIconStyle` | `private fun runIconStyle(result: RunResult): IconStyle` | `feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/EntryStyle.kt` | A clock for a run that went well, an amber triangle for a partial one, a red one for a failed or missed run. |
| `runTitle` | `internal fun runTitle(item: NotificationItem): String` | `feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/EntryStyle.kt` | "Morning light ran", "ran only partly", "failed" or "did not run" (missed), with the count of runs (19.11). |
| `runText` | `internal fun runText(item: NotificationItem): AnnotatedString` | `feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/EntryStyle.kt` | The line under a run title (concept 19.11): the time of the run (of the last one if several), what went wrong |
-| `ErrorDetailSheet` | `internal fun ErrorDetailSheet(item: NotificationItem, instanceName: String?, onDismiss: () -> Unit)` | `feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/ErrorDetailSheet.kt` | Detail sheet of an error entry (concept 17.4): code, time, instance, technical description and the HAB code |
+| `ErrorDetailSheet` | `internal fun ErrorDetailSheet(item: NotificationItem, instanceName: String?, onDismiss: () -> Unit)` | `feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/ErrorDetailSheet.kt` | Detail of an error entry (concept 17.4) as a bottom sheet in Compact and a side sheet in Medium; Expanded shows |
+| `ErrorDetailPane` | `internal fun ErrorDetailPane(item: NotificationItem, instanceName: String?, onClose: () -> Unit)` | `feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/ErrorDetailSheet.kt` | The detail of an error entry in a fixed pane next to the list, with a close button (concept 15.7). |
+| `ErrorDetailContent` | `private fun ErrorDetailContent(item: NotificationItem, instanceName: String?)` | `feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/ErrorDetailSheet.kt` | Code, time, instance, technical description and the HAB code of bridge errors; *Copy details* copies them for |
| `DetailRow` | `private fun DetailRow(label: String, value: String)` | `feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/ErrorDetailSheet.kt` | A section label and its value; codes are shown in the mono font. |
| `NotificationActions` | `data class NotificationActions(val onBack: () -> Unit, val onOpen: (NotificationItem) -> Unit, val onMarkAllRead: () -> Unit, val onResolve: (NotificationItem) -> Unit, val onErrorAction: (NotificationItem) -> Unit, val onAddToRoom: (NotificationItem) -> Unit = {}, val onRemoveTiles: (NotificationItem) -> Unit = {}, val onOpenSchedule: (NotificationItem) -> Unit = {}, val onDelete: (NotificationItem) -> Unit = {}, val onDeleteAll: () -> Unit = {})` | `feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/NotificationActions.kt` | Callbacks of the notification list; *Add to room* and *Remove tile* belong to entity entries (concept 9.1), |
| `NotificationBell` | `fun NotificationBell(onClick: () -> Unit, modifier: Modifier = Modifier, viewModel: NotificationBellViewModel = hiltViewModel())` | `feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/NotificationBell.kt` | The bell that opens the notification list, with an accent dot while entries are unread (M-08, M-09). |
diff --git a/feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/ErrorDetailSheet.kt b/feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/ErrorDetailSheet.kt
index 8358d73..7ea0e5a 100644
--- a/feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/ErrorDetailSheet.kt
+++ b/feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/ErrorDetailSheet.kt
@@ -2,22 +2,31 @@ package com.stacknoise.haac.feature.notifications.ui
import android.content.ClipData
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
-import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ClipEntry
import androidx.compose.ui.platform.LocalClipboard
+import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import com.stacknoise.haac.core.common.ui.HaacSheet
+import com.stacknoise.haac.core.common.ui.HaacSideSheet
+import com.stacknoise.haac.core.common.ui.LocalWindowWidthClass
+import com.stacknoise.haac.core.common.ui.WindowWidthClass
import com.stacknoise.haac.core.common.ui.theme.HaacShapes
import com.stacknoise.haac.core.common.ui.theme.MonoFontFamily
import com.stacknoise.haac.core.common.ui.theme.SectionLabelStyle
@@ -32,12 +41,37 @@ import java.time.format.FormatStyle
import kotlinx.coroutines.launch
/**
- * Detail sheet of an error entry (concept 17.4): code, time, instance, technical description and the HAB code
- * of bridge errors; *Copy details* copies them for support requests.
+ * Detail of an error entry (concept 17.4) as a bottom sheet in Compact and a side sheet in Medium; Expanded shows
+ * it as [ErrorDetailPane].
*/
-@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun ErrorDetailSheet(item: NotificationItem, instanceName: String?, onDismiss: () -> Unit) {
+ if (LocalWindowWidthClass.current == WindowWidthClass.Compact) {
+ HaacSheet(onDismiss) { ErrorDetailContent(item, instanceName) }
+ } else {
+ HaacSideSheet(onDismiss) {
+ Column(Modifier.verticalScroll(rememberScrollState())) { ErrorDetailContent(item, instanceName) }
+ }
+ }
+}
+
+/** The detail of an error entry in a fixed pane next to the list, with a close button (concept 15.7). */
+@Composable
+internal fun ErrorDetailPane(item: NotificationItem, instanceName: String?, onClose: () -> Unit) {
+ Column(Modifier.fillMaxSize().verticalScroll(rememberScrollState())) {
+ IconButton(onClick = onClose, modifier = Modifier.align(Alignment.End)) {
+ Icon(painterResource(R.drawable.ic_notifications_close), stringResource(R.string.notifications_close))
+ }
+ ErrorDetailContent(item, instanceName)
+ }
+}
+
+/**
+ * Code, time, instance, technical description and the HAB code of bridge errors; *Copy details* copies them for
+ * support requests.
+ */
+@Composable
+private fun ErrorDetailContent(item: NotificationItem, instanceName: String?) {
val code = item.error ?: ErrorCode.APP_UNEXPECTED
val time = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)
.format(Instant.ofEpochMilli(item.createdAt).atZone(ZoneId.systemDefault()))
@@ -51,21 +85,19 @@ internal fun ErrorDetailSheet(item: NotificationItem, instanceName: String?, onD
)
val clipboard = LocalClipboard.current
val scope = rememberCoroutineScope()
- HaacSheet(onDismiss) {
- Column(modifier = Modifier.navigationBarsPadding().padding(horizontal = 24.dp, vertical = 8.dp)) {
- Text(stringResource(code.message), style = MaterialTheme.typography.titleMedium)
- rows.forEach { (label, value) -> DetailRow(label, value) }
- OutlinedButton(
- onClick = {
- val details = rows.joinToString("\n") { (label, value) -> "$label: $value" }
- scope.launch { clipboard.setClipEntry(ClipEntry(ClipData.newPlainText(code.code, details))) }
- },
- shape = HaacShapes.Button,
- colors = haacOutlinedButtonColors(),
- modifier = Modifier.fillMaxWidth().padding(vertical = 24.dp),
- ) {
- Text(stringResource(R.string.notifications_detail_copy))
- }
+ Column(modifier = Modifier.navigationBarsPadding().padding(horizontal = 24.dp, vertical = 8.dp)) {
+ Text(stringResource(code.message), style = MaterialTheme.typography.titleMedium)
+ rows.forEach { (label, value) -> DetailRow(label, value) }
+ OutlinedButton(
+ onClick = {
+ val details = rows.joinToString("\n") { (label, value) -> "$label: $value" }
+ scope.launch { clipboard.setClipEntry(ClipEntry(ClipData.newPlainText(code.code, details))) }
+ },
+ shape = HaacShapes.Button,
+ colors = haacOutlinedButtonColors(),
+ modifier = Modifier.fillMaxWidth().padding(vertical = 24.dp),
+ ) {
+ Text(stringResource(R.string.notifications_detail_copy))
}
}
}
diff --git a/feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/NotificationsScreen.kt b/feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/NotificationsScreen.kt
index 7fa327b..d49b515 100644
--- a/feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/NotificationsScreen.kt
+++ b/feature/notifications/src/main/kotlin/com/stacknoise/haac/feature/notifications/ui/NotificationsScreen.kt
@@ -4,9 +4,11 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.AlertDialog
@@ -36,7 +38,11 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.stacknoise.haac.core.common.ui.ErrorMessage
+import com.stacknoise.haac.core.common.ui.ListPaneWidth
+import com.stacknoise.haac.core.common.ui.LocalWindowWidthClass
+import com.stacknoise.haac.core.common.ui.WindowWidthClass
import com.stacknoise.haac.core.common.ui.centeredContent
+import com.stacknoise.haac.core.common.ui.theme.HaacColors
import com.stacknoise.haac.core.common.ui.theme.HaacEmptyState
import com.stacknoise.haac.core.common.ui.theme.HaacScreenTitle
import com.stacknoise.haac.core.common.ui.theme.HaacTheme
@@ -68,32 +74,50 @@ fun NotificationsScreen(
) {
val state by viewModel.state.collectAsStateWithLifecycle()
val snackbar = remember { SnackbarHostState() }
- Box(modifier = Modifier.fillMaxSize()) {
- NotificationsContent(
- state = state,
- actions = NotificationActions(
- onBack = onBack,
- onOpen = viewModel::onOpen,
- onMarkAllRead = viewModel::onMarkAllRead,
- onResolve = viewModel::onResolve,
- onErrorAction = { item -> item.error?.let { onErrorAction(it.action, item.serverId) } },
- onAddToRoom = { item ->
- viewModel.onResolve(item)
- onAddToRoom(item.unassigned)
- },
- onOpenSchedule = { item ->
- viewModel.onResolve(item)
- item.run?.scheduleId?.let(onOpenSchedule)
- },
- onRemoveTiles = viewModel::onRemoveTiles,
- onDelete = viewModel::onDelete,
- onDeleteAll = viewModel::onDeleteAll,
- ),
- )
- SnackbarHost(snackbar, modifier = Modifier.align(Alignment.BottomCenter).navigationBarsPadding())
+ val expanded = LocalWindowWidthClass.current == WindowWidthClass.Expanded
+ Row(Modifier.fillMaxSize()) {
+ Box(modifier = if (expanded) Modifier.width(ListPaneWidth).fillMaxHeight() else Modifier.fillMaxSize()) {
+ NotificationsContent(
+ state = state,
+ actions = NotificationActions(
+ onBack = onBack,
+ onOpen = viewModel::onOpen,
+ onMarkAllRead = viewModel::onMarkAllRead,
+ onResolve = viewModel::onResolve,
+ onErrorAction = { item -> item.error?.let { onErrorAction(it.action, item.serverId) } },
+ onAddToRoom = { item ->
+ viewModel.onResolve(item)
+ onAddToRoom(item.unassigned)
+ },
+ onOpenSchedule = { item ->
+ viewModel.onResolve(item)
+ item.run?.scheduleId?.let(onOpenSchedule)
+ },
+ onRemoveTiles = viewModel::onRemoveTiles,
+ onDelete = viewModel::onDelete,
+ onDeleteAll = viewModel::onDeleteAll,
+ ),
+ )
+ SnackbarHost(snackbar, modifier = Modifier.align(Alignment.BottomCenter).navigationBarsPadding())
+ }
+ if (expanded) {
+ Box(Modifier.weight(1f).fillMaxHeight().background(HaacColors.Surface)) {
+ val detail = state.detail
+ if (detail == null) {
+ HaacEmptyState(
+ painterResource(R.drawable.ic_notifications_bell),
+ stringResource(R.string.notifications_detail_empty),
+ )
+ } else {
+ ErrorDetailPane(detail, state.instanceName, onClose = viewModel::onCloseDetail)
+ }
+ }
+ }
}
UndoSnackbar(state.undo, snackbar, viewModel::onUndo, viewModel::onUndoClosed)
- state.detail?.let { ErrorDetailSheet(it, state.instanceName, onDismiss = viewModel::onCloseDetail) }
+ if (!expanded) {
+ state.detail?.let { ErrorDetailSheet(it, state.instanceName, onDismiss = viewModel::onCloseDetail) }
+ }
}
/** Offers *Undo* for the last deletion in [snackbar]; [onClosed] when the offer ran out or was replaced by none. */
diff --git a/feature/notifications/src/main/res/drawable/ic_notifications_close.xml b/feature/notifications/src/main/res/drawable/ic_notifications_close.xml
new file mode 100644
index 0000000..fd8599c
--- /dev/null
+++ b/feature/notifications/src/main/res/drawable/ic_notifications_close.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/feature/notifications/src/main/res/values-de/strings.xml b/feature/notifications/src/main/res/values-de/strings.xml
index eae23bd..3665b97 100644
--- a/feature/notifications/src/main/res/values-de/strings.xml
+++ b/feature/notifications/src/main/res/values-de/strings.xml
@@ -2,6 +2,8 @@
Benachrichtigungen
Zurück
+ Schließen
+ Wähle links einen Fehler, um die Details zu sehen.
Alle als gelesen markieren
Heute
Gestern
diff --git a/feature/notifications/src/main/res/values/strings.xml b/feature/notifications/src/main/res/values/strings.xml
index 65bed06..c3712ed 100644
--- a/feature/notifications/src/main/res/values/strings.xml
+++ b/feature/notifications/src/main/res/values/strings.xml
@@ -2,6 +2,8 @@
Notifications
Back
+ Close
+ Select an error on the left to see its details.
Mark all read
Today
Yesterday