1import 'package:blood_pressure_app/data_util/entry_context.dart';
 2import 'package:blood_pressure_app/features/input/forms/add_entry_form.dart';
 3import 'package:blood_pressure_app/features/measurement_list/measurement_list_entry.dart';
 4import 'package:blood_pressure_app/model/storage/settings_store.dart';
 5import 'package:flutter/material.dart';
 6import 'package:blood_pressure_app/l10n/app_localizations.dart';
 7import 'package:health_data_store/health_data_store.dart';
 8import 'package:provider/provider.dart';
 9
10/// List that renders measurements and medicine intakes.
11///
12/// Contains a headline with information about the meaning of "columns".
13class MeasurementList extends StatelessWidget {
14  /// Create a list to display measurements and intakes.
15  const MeasurementList({super.key,
16    required this.entries,
17  });
18
19  /// Entries sorted with newest comming first.
20  final List<FullEntry> entries;
21
22  @override
23  Widget build(BuildContext context) {
24    final localizations = AppLocalizations.of(context)!;
25    final settings = context.watch<Settings>();
26    return Column(
27      mainAxisSize: MainAxisSize.min,
28      children: [
29        Column(
30          children: [
31            Row(
32              children: [
33                const Expanded(
34                  flex: 4,
35                  child: SizedBox(),),
36                Expanded(
37                  flex: 30,
38                  child: Text(localizations.sysLong,
39                    overflow: TextOverflow.ellipsis,
40                    style: TextStyle(fontWeight: FontWeight.bold, color: settings.sysColor),),),
41                Expanded(
42                  flex: 30,
43                  child: Text(localizations.diaLong,
44                    overflow: TextOverflow.ellipsis,
45                    style: TextStyle(fontWeight: FontWeight.bold, color: settings.diaColor),),),
46                Expanded(
47                  flex: 30,
48                  child: Text(localizations.pulLong,
49                    overflow: TextOverflow.ellipsis,
50                    style: TextStyle(fontWeight: FontWeight.bold, color: settings.pulColor),),),
51                const Expanded(
52                  flex: 20,
53                  child: SizedBox(),),
54              ],
55            ),
56            const SizedBox(
57              height: 10,
58            ),
59            Divider(
60              height: 0,
61              thickness: 2,
62              color: Theme.of(context).colorScheme.primaryContainer,
63            ),
64          ],
65        ),
66        Expanded(
67          child: ListView.builder(
68            // Fix actions blocked by floating buttons on different screens
69            // and font sizes by adding empty offset to bottom.
70            padding: const EdgeInsets.only(bottom: 300),
71            itemCount: entries.length,
72            itemBuilder: (context, idx) => MeasurementListRow(
73              data: entries[idx],
74              onRequestEdit: () => context.createEntry(entries[idx].asAddEntry),
75            ),
76          ),
77        ),
78      ],
79    );
80  }
81}