Keep the carb detail sheet across remounts and share carb treatment construction - #758
Merged
Merged
Conversation
Treatment.carb builds a carb entry for both the treatments list and the chart's detail sheet, with one id fallback for entries without a Nightscout _id. Treatment.rootMealsByFPUID and rootMeal(in:) back the FPU-child root lookup in both places.
The chart's carb marks follow a remote meal edit or delete from any screen by running the treatments task as soon as the command resolves.
BGChartView owns the selected carb and its sheet, outside the subtree that is remounted on foregrounding, so an open sheet survives a trip to Notification Center or the background. Double-tap hit-tests carb marks only, so a nearby bolus cannot shadow the carb it sits next to.
bjorkert
added a commit
that referenced
this pull request
Sep 26, 2026
* Add ability to double-click carbs to enter Treatments screen * Keep the carb detail sheet across remounts and share carb treatment construction (#758) * Share carb Treatment construction and root-meal lookup Treatment.carb builds a carb entry for both the treatments list and the chart's detail sheet, with one id fallback for entries without a Nightscout _id. Treatment.rootMealsByFPUID and rootMeal(in:) back the FPU-child root lookup in both places. * Refresh treatments when a remote meal command completes The chart's carb marks follow a remote meal edit or delete from any screen by running the treatments task as soon as the command resolves. * Keep the carb detail sheet in the chart shell BGChartView owns the selected carb and its sheet, outside the subtree that is remounted on foregrounding, so an open sheet survives a trip to Notification Center or the background. Double-tap hit-tests carb marks only, so a nearby bolus cannot shadow the carb it sits next to. --------- Co-authored-by: Jonas Björkert <jonas@bjorkert.se>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #757 (double-tap on a carb mark opens its details). Targets the
touch-carbbranch.BGChartViewremounts its chart subtree ondidBecomeActive, which tore down the@Stateselection and its.sheetinsideMainBGChart.BGChartViewnow ownsselectedTreatmentand the.sheet, outside the remounted subtree;MainBGChartwrites the selection through aBinding. An open sheet survives Notification Center, Control Center and backgrounding, so in-progress edits and thecommandTracker.consume(key:)path inTreatmentDetailVieware kept.Treatmentconstruction.Treatment.carb(nightscoutID:date:carbs:bgValue:trioMeal:loopCarb:)builds carb entries for bothTreatmentsViewModelandCarbTreatment.detailTreatment, including the subtitle rules.nightscoutIDonLoopCarbTreatment/TrioMealTreatmentis optional, and the factory applies the singleunknown-<date>id fallback.onDismissrefresh is gone.MainViewControllerobserves.remoteMealCommandDidCompleteand reschedules the.treatmentstask to now, so the chart follows a remote edit or delete whether it was sent from the chart sheet or the Treatments tab. View-only dismissals trigger no fetch.handleDoubleTaphit-testsmodel.carbsonly, so a bolus/SMB drawn nearer than the (offset) carb dot cannot shadow it. The nearest carb mark wins; one without AID metadata falls through to the zoom preset.Treatment.rootMealsByFPUID(_:)andTreatment.rootMeal(in:)back bothTreatmentsViewModel.rootMeal(forFPUChild:)and the chart sheet's root lookup.MainBGChart: "Double-tap on a carb mark opens its details; elsewhere it cycles zoom presets."