Med editor: wrap day chips so the whole week is visible; Enhet follows Form
The 7 day chips overflowed the dose-time dialog (no scroll, week cut off) — FlowRow wraps them, with full day names for TalkBack. Enhet auto-fills from Form while it still holds the previous form's default (tablett/kapsel/ml/dråper/doser), killing the apparent Enhet/Form overlap; manual overrides like IU stick. Styrke stays Styrke — it holds '500 mg', which is neither unit nor form. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
b0ff434257
commit
f8e8dca081
1 changed files with 28 additions and 5 deletions
|
|
@ -3,6 +3,8 @@ package no.naiv.meddetsamme.ui
|
|||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
|
|
@ -67,6 +69,19 @@ private val FORM_LABELS = mapOf(
|
|||
MedForm.OTHER to "Annet",
|
||||
)
|
||||
|
||||
/**
|
||||
* Enhet is what doses and stock COUNT (tablett, ml, …); Form is the
|
||||
* pharmaceutical form. They coincide for tablets, which made the two fields
|
||||
* look redundant — so Enhet auto-follows Form while it still holds the
|
||||
* previous form's default, and stays untouched once manually overridden
|
||||
* (IU, penner, …).
|
||||
*/
|
||||
private val DEFAULT_UNIT = mapOf(
|
||||
MedForm.TABLET to "tablett", MedForm.CAPSULE to "kapsel", MedForm.LIQUID to "ml",
|
||||
MedForm.INJECTION to "ml", MedForm.DROPS to "dråper", MedForm.SPRAY to "doser",
|
||||
MedForm.OTHER to "dose",
|
||||
)
|
||||
|
||||
/** Best-effort mapping of FEST's free-form text to our enum; user can override. */
|
||||
private fun guessForm(festForm: String): MedForm = when {
|
||||
"tablett" in festForm.lowercase() -> MedForm.TABLET
|
||||
|
|
@ -233,7 +248,12 @@ fun MedEditScreen(nav: Nav, initialMedId: Long?) {
|
|||
)
|
||||
}
|
||||
|
||||
FormDropdown(form) { form = it }
|
||||
FormDropdown(form) { newForm ->
|
||||
if (unit.isBlank() || unit == DEFAULT_UNIT[form]) {
|
||||
unit = DEFAULT_UNIT.getValue(newForm)
|
||||
}
|
||||
form = newForm
|
||||
}
|
||||
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
|
@ -434,7 +454,7 @@ private fun ScheduleSection(medId: Long, doseTimes: List<DoseTime>, onChanged: (
|
|||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
private fun DoseTimeEditorDialog(
|
||||
medId: Long,
|
||||
|
|
@ -482,9 +502,12 @@ private fun DoseTimeEditorDialog(
|
|||
label = { Text("Antall dager mellom doser") }, singleLine = true,
|
||||
)
|
||||
} else {
|
||||
// Monday-first row of toggles; bit 0 = Sunday underneath.
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
listOf(1 to "M", 2 to "T", 3 to "O", 4 to "T", 5 to "F", 6 to "L", 0 to "S")
|
||||
// Monday-first toggles; bit 0 = Sunday underneath. FlowRow wraps
|
||||
// so the whole week is visible — a plain Row overflowed the dialog.
|
||||
FlowRow(
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
listOf(1 to "man", 2 to "tir", 3 to "ons", 4 to "tor", 5 to "fre", 6 to "lør", 0 to "søn")
|
||||
.forEach { (bit, label) ->
|
||||
val selected = mask and (1 shl bit) != 0
|
||||
FilterChip(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue