Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,15 @@ class BookDetailViewModel(
load()
}
is ApiResult.Failure -> {
// Close the calendar dialog so the error is visible: the snackbar
// lives at the screen Scaffold level, behind the open DatePickerDialog.
when {
res.code == ErrorCodes.CONFLICT ->
_state.update { it.copy(reserveBusy = false, snackbar = null, snackbarRes = R.string.snackbar_request_conflict) }
_state.update { it.copy(reserveBusy = false, showLoanSheet = false, snackbar = null, snackbarRes = R.string.snackbar_request_conflict) }
res.message.isNotBlank() ->
_state.update { it.copy(reserveBusy = false, snackbar = res.message, snackbarRes = null) }
_state.update { it.copy(reserveBusy = false, showLoanSheet = false, snackbar = res.message, snackbarRes = null) }
else ->
_state.update { it.copy(reserveBusy = false, snackbar = null, snackbarRes = R.string.snackbar_request_error) }
_state.update { it.copy(reserveBusy = false, showLoanSheet = false, snackbar = null, snackbarRes = R.string.snackbar_request_error) }
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/com/pinakes/app/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.pinakes.app.ui.theme

import android.app.Activity
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

/** User-selectable theme. Default is [LIGHT] (DESIGN.md: "Light is the default theme"). */
enum class ThemeMode { LIGHT, DARK, SYSTEM }
Expand All @@ -17,6 +21,21 @@ fun PinakesTheme(
ThemeMode.DARK -> true
ThemeMode.SYSTEM -> isSystemInDarkTheme()
}

// With edge-to-edge the status/navigation bars are transparent, so the system
// soft-button + status icons must follow the APP theme, not the system dark
// mode — otherwise a light app under a dark-mode system shows white icons on a
// light background (invisible). Light theme → dark icons; dark theme → light.
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
val controller = WindowCompat.getInsetsController(window, view)
controller.isAppearanceLightStatusBars = !dark
controller.isAppearanceLightNavigationBars = !dark
}
}

MaterialTheme(
colorScheme = if (dark) DarkColors else LightColors,
typography = PinakesTypography,
Expand Down