Treatments, Carbs & boluses: the insulin label pushes the bolus type and the NS/pump icons out of the row

Open Beginner friendly
#5,481 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
kotlin
Domain
mobile

Research direction

Read ui/src/commonMain/kotlin/app/aaps/ui/compose/treatments/BolusCarbsScreen.kt, especially the bolus row around lines 243–351, and inspect how its children are measured when an insulin label is shown. Reproduce the reported narrow-row layout, then adjust the row so the label remains readable and the bolus type and both icons remain visible. Done when rows with and without an insulin label fit without wrapping the type or hiding the icons.

Written by the indexing model from the issue text.

Description

Found via AI-assisted code review (Claude) of upstream code, while checking a layout problem in my personal build of dev (current dev plus my own local changes). The point below was checked against nightscout/dev 11681e46fe by reading the code and with a layout measurement test (Robolectric, a copy of the bolus Row with the same modifiers and text sizes). It was not reproduced on a phone with an upstream build. Please verify independently before acting on it.

Summary

Treatments → Carbs & boluses: when a bolus row shows the insulin label (the bolus insulin is different from the active one), the row does not fit on a normal phone. The bolus type text wraps to two lines, and the Nightscout and pump-history icons get zero width, so they disappear.

After an insulin change (for example a new concentration) every older bolus shows the label, so the whole list before the change is affected.

Where

ui/src/commonMain/kotlin/app/aaps/ui/compose/treatments/BolusCarbsScreen.kt, bolus row:
https://github.com/nightscout/AndroidAPS/blob/11681e46fea66f70e72989e9e521c5cea8a06944/ui/src/commonMain/kotlin/app/aaps/ui/compose/treatments/BolusCarbsScreen.kt#L243-L351

All children of this Row except the spacer have no weight. Compose measures them one after another, each with the width that is still free. The insulin label (lines 289-297) has no weight and no maxLines, so it takes its full width before the type text and the icons are measured. They get what is left, often nothing.

Measurement

Screen 394 dp wide (1280 px, 520 dpi), font scale 1.1, the row copied with the same modifiers and text sizes:

amount text insulin label type text NS icon pump icon
3,60 ед (0,34 ед) Апидра 55m 8.5h 100 ед 70 dp, 2 lines 0 dp 0 dp
3,60 U (0,34 U) Lyumjev 45m 7.5h U100 76 dp, 1 line 18 dp 0 dp
0,30 ед Ринлиз рапид 45m 7.5h 200 ед 76 dp, 1 line 21 dp 3 dp
2,10 ед (1,05 ед) (no label) 76 dp, 1 line 21 dp 21 dp

Possible fix (only a suggestion)

Put the label on its own line under the time and the amount:

Row(/* same as now */) {
    Column(modifier = Modifier.weight(1f)) {
        Row(verticalAlignment = Alignment.CenterVertically) {
            // time, amount (as now)
        }
        if (bolus.iCfg.insulinLabel != activeLabel) {
            Text(text = bolus.iCfg.insulinLabel, fontSize = 11.sp, color = MaterialTheme.colorScheme.onSurfaceVariant)
        }
    }
    // type text with maxLines = 1, then the icons (as now); the Box spacer is no longer needed
}

With the same measurement every element then keeps its natural width (amount 119 dp, type 76 dp on one line, both icons 21 dp), and the label keeps its full text.

Two variants that look simpler but do not work:

  • Shortening the label with an ellipsis in the same line cuts off the end of the label, which is usually the concentration ("100 ед" / "U100"), the part that matters after a change.
  • Giving only the time + amount group a weight, with the label still outside it, makes it worse: the amount is squeezed to about 11 dp and is drawn one character per line.
Dominant language
Kotlin
Stars
1.2k
Forks
7.4k
Avg merge
1d 7h
Merged PRs (30d)
93

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nightscout/AndroidAPS

All issues in nightscout/AndroidAPS

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.