buildEditingRow function
- required BuildContext context,
- required BPEditorState editorState,
- required dynamic editorService,
- required BPObservation observation,
- required int index,
- required VoidCallback onCancel,
- required VoidCallback onSave,
- required ValueChanged<
DateTime> onTimestampChanged,
Builds an editable DataRow for modifying a BPObservation.
This row shows text fields for systolic, diastolic, and heart rate, a dropdown for the "feeling" field, a multi-line text field for notes, and a timestamp cell for picking date/time down to the minute.
All changes are reflected in editorState.currentEdit
, so the user sees
them in real time. Actual file operations happen only on "Save."
Implementation
DataRow buildEditingRow({
required BuildContext context,
required BPEditorState editorState,
required dynamic editorService,
required BPObservation observation,
required int index,
required VoidCallback onCancel,
required VoidCallback onSave,
required ValueChanged<DateTime> onTimestampChanged,
}) {
// Get the "currentEdit" model that holds unsaved changes.
final currentEdit = editorState.currentEdit ?? observation;
// Make sure we have controllers initialized from "currentEdit."
if (editorState.systolicController == null) {
editorState.initialiseControllers(currentEdit);
}
// Return a row that displays and updates "currentEdit" fields in real time.
return DataRow(
cells: [
buildTimestampCell(
context: context,
editorState: editorState,
observation: observation,
currentEdit: currentEdit,
onTimestampChanged: onTimestampChanged,
),
// Generic numeric cells for systolic, diastolic, heart rate.
numericCell(
controller: editorState.systolicController,
onValueChange: (val) {
editorState.currentEdit = currentEdit.copyWith(systolic: val);
},
),
numericCell(
controller: editorState.diastolicController,
onValueChange: (val) {
editorState.currentEdit = currentEdit.copyWith(diastolic: val);
},
),
numericCell(
controller: editorState.heartRateController,
onValueChange: (val) {
editorState.currentEdit = currentEdit.copyWith(heartRate: val);
},
),
// Feeling dropdown and Notes cell.
feelingCell(editorState, currentEdit),
notesCell(editorState, currentEdit),
// Action buttons for saving and canceling.
actionButtonsCell(
onSave: onSave,
onCancel: onCancel,
),
],
);
}