Commit d597cbf
Changed files (1)
app
lib
features
measurement_list
app/lib/features/measurement_list/legacy_measurement_list.dart
@@ -28,6 +28,14 @@ class _LegacyMeasurementsListState extends State<LegacyMeasurementsList> {
late final int _sideFlex;
+ late DateFormat formatter;
+
+ @override
+ void initState() {
+ super.initState();
+ formatter = DateFormat('yyyy-MM-dd HH:mm');
+ }
+
Widget _buildHeader() => Row(
children: [
Expanded(
@@ -59,80 +67,78 @@ class _LegacyMeasurementsListState extends State<LegacyMeasurementsList> {
],
);
- Widget _itemBuilder(context, int index) {
- final formatter = DateFormat(context.select<Settings, String>((s) => s.dateFormatString));
- return Column(
- children: [
- Dismissible(
- key: Key(widget.data[index].time.toIso8601String()),
- confirmDismiss: (direction) async {
- if (direction == DismissDirection.startToEnd) { // edit
- await context.createEntry(widget.data[index]);
- return false;
- } else { // delete
- await context.deleteEntry(widget.data[index]);
- return false;
- }
- },
- onDismissed: (direction) {},
- background: Container(
- width: 10,
- decoration:
- BoxDecoration(color: Colors.blue, borderRadius: BorderRadius.circular(5)),
- child: const Align(alignment: Alignment(-0.95, 0), child: Icon(Icons.edit)),
- ),
- secondaryBackground: Container(
- width: 10,
- decoration:
- BoxDecoration(color: Colors.red, borderRadius: BorderRadius.circular(5)),
- child: const Align(alignment: Alignment(0.95, 0), child: Icon(Icons.delete)),
- ),
- child: Container(
- constraints: const BoxConstraints(minHeight: 40),
- child: Row(children: [
- Expanded(
- flex: _sideFlex,
- child: const SizedBox(),
- ),
- Expanded(
- flex: _tableElementsSizes[0],
- child: Text(formatter.format(widget.data[index].time)),),
- Expanded(
- flex: _tableElementsSizes[1],
- child: PressureText(widget.data[index].sys)),
- Expanded(
- flex: _tableElementsSizes[2],
- child: PressureText(widget.data[index].dia),),
- Expanded(
- flex: _tableElementsSizes[3],
- child: NullableText(widget.data[index].pul?.toString()),),
- Expanded(
- flex: _tableElementsSizes[4],
- child: NullableText(() {
- String note = widget.data[index].note ?? '';
- for (final i in widget.data[index].intakes) {
- note += '${i.medicine.designation}(${i.dosis.mg}mg)';
- }
- return note.isEmpty ? null : note;
- }()),
- ),
- Expanded(
- flex: _sideFlex,
- child: const SizedBox(),
- ),
- ],),
- ),
+ Widget _itemBuilder(context, int index) => Column(
+ children: [
+ Dismissible(
+ key: Key(widget.data[index].time.toIso8601String()),
+ confirmDismiss: (direction) async {
+ if (direction == DismissDirection.startToEnd) { // edit
+ await context.createEntry(widget.data[index]);
+ return false;
+ } else { // delete
+ await context.deleteEntry(widget.data[index]);
+ return false;
+ }
+ },
+ onDismissed: (direction) {},
+ background: Container(
+ width: 10,
+ decoration:
+ BoxDecoration(color: Colors.blue, borderRadius: BorderRadius.circular(5)),
+ child: const Align(alignment: Alignment(-0.95, 0), child: Icon(Icons.edit)),
),
- const Divider(
- thickness: 1,
- height: 1,
+ secondaryBackground: Container(
+ width: 10,
+ decoration:
+ BoxDecoration(color: Colors.red, borderRadius: BorderRadius.circular(5)),
+ child: const Align(alignment: Alignment(0.95, 0), child: Icon(Icons.delete)),
),
- ],
- );
- }
+ child: Container(
+ constraints: const BoxConstraints(minHeight: 40),
+ child: Row(children: [
+ Expanded(
+ flex: _sideFlex,
+ child: const SizedBox(),
+ ),
+ Expanded(
+ flex: _tableElementsSizes[0],
+ child: Text(formatter.format(widget.data[index].time)),),
+ Expanded(
+ flex: _tableElementsSizes[1],
+ child: PressureText(widget.data[index].sys)),
+ Expanded(
+ flex: _tableElementsSizes[2],
+ child: PressureText(widget.data[index].dia),),
+ Expanded(
+ flex: _tableElementsSizes[3],
+ child: NullableText(widget.data[index].pul?.toString()),),
+ Expanded(
+ flex: _tableElementsSizes[4],
+ child: NullableText(() {
+ String note = widget.data[index].note ?? '';
+ for (final i in widget.data[index].intakes) {
+ note += '${i.medicine.designation}(${i.dosis.mg}mg)';
+ }
+ return note.isEmpty ? null : note;
+ }()),
+ ),
+ Expanded(
+ flex: _sideFlex,
+ child: const SizedBox(),
+ ),
+ ],),
+ ),
+ ),
+ const Divider(
+ thickness: 1,
+ height: 1,
+ ),
+ ],
+ );
@override
Widget build(BuildContext context) {
+ formatter = DateFormat(context.select<Settings, String>((s) => s.dateFormatString));
if (MediaQuery.of(context).size.width < 1000) {
_tableElementsSizes = [33, 9, 9, 9, 30];
_sideFlex = 1;