Commit b6a2c51
Changed files (3)
lib/components/measurement_list.dart
@@ -1,6 +1,7 @@
import 'package:blood_pressure_app/model/blood_pressure.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
+import 'package:intl/intl.dart';
class MeasurementList extends StatelessWidget {
const MeasurementList({super.key});
@@ -9,52 +10,116 @@ class MeasurementList extends StatelessWidget {
Widget build(BuildContext context) {
// TODO: implement build
return Container(
- child: Consumer<BloodPressureModel>(
- builder: (context, model, child) {
- List<BloodPressureRecord> items = model.getLastX(30);
- if (items.isNotEmpty && items.first.diastolic > 0) {
- return ListView.builder(
- itemCount: items.length,
- shrinkWrap: true,
- itemBuilder: (context, index) {
- return buildListItem(items[index]);
+ child: Column(
+ children: [
+ buildTableHeader(context),
+ Expanded(
+ flex: 100,
+ child: Consumer<BloodPressureModel>(
+ builder: (context, model, child) {
+ List<BloodPressureRecord> items = model.getLastX(30);
+ if (items.isNotEmpty && items.first.diastolic > 0) {
+ return ListView.builder(
+ itemCount: items.length,
+ shrinkWrap: true,
+ itemBuilder: (context, index) {
+ return buildListItem(items[index]);
+ }
+ );
+ } else {
+ return const Text('Es existieren noch keine Werte');
}
- );
- } else {
- return const Text('Es existieren noch keine Werte');
- }
- })
+ }
+ ),
+ )
+ ],
+ )
);
}
Widget buildListItem(BloodPressureRecord record) {
+ final DateFormat formater = DateFormat('yyyy-MM-dd H:mm:s');
return Container(
+ margin: EdgeInsets.only(bottom: 5),
child: Row(
children: [
+ const Expanded(
+ flex: 5,
+ child: SizedBox(),
+ ),
Expanded(
- flex: 10,
+ flex: 9,
+ child: Text(formater.format(record.creationTime))
+ ),
+ Expanded(
+ flex: 7,
child: Text(record.systolic.toString())
),
Expanded(
- flex: 10,
+ flex: 7,
child: Text(record.diastolic.toString())
),
Expanded(
- flex: 10,
+ flex: 7,
child: Text(record.pulse.toString())
),
Expanded(
- flex: 70,
+ flex: 60,
child: Text(record.notes)
),
+ const Expanded(
+ flex: 5,
+ child: SizedBox(),
+ ),
]
),
);
}
- Widget buildColumnSeperator() {
- return const SizedBox(
- width: 8,
+
+ Widget buildTableHeader(BuildContext context) {
+ return Container(
+ child: Column (
+ children: [
+ Row(
+ children: const [
+ Expanded(
+ flex: 5,
+ child: SizedBox(),
+ ),
+ Expanded(
+ flex: 9,
+ child: Text("timestamp", style: TextStyle(fontWeight: FontWeight.bold))
+ ),
+ Expanded(
+ flex: 7,
+ child: Text("systolic", style: TextStyle(fontWeight: FontWeight.bold))
+ ),
+ Expanded(
+ flex: 7,
+ child: Text("diastolic", style: TextStyle(fontWeight: FontWeight.bold))
+ ),
+ Expanded(
+ flex: 7,
+ child: Text("pulse", style: TextStyle(fontWeight: FontWeight.bold))
+ ),
+ Expanded(
+ flex: 60,
+ child: Text("notes", style: TextStyle(fontWeight: FontWeight.bold))
+ ),
+ Expanded(
+ flex: 5,
+ child: SizedBox(),
+ ),
+ ],
+ ),
+ Divider(
+ height: 20,
+ thickness: 1,
+ color: Theme.of(context).primaryColor,
+ )
+ ]
+ ),
);
}
}
pubspec.lock
@@ -75,6 +75,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
+ intl:
+ dependency: "direct main"
+ description:
+ name: intl
+ sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.18.1"
js:
dependency: transitive
description:
pubspec.yaml
@@ -36,6 +36,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
+ intl: ^0.18.1
dev_dependencies:
flutter_test: