cpd_2022_zi/lib/widgets/view_form/sleep_view.dart

36 lines
1.3 KiB
Dart
Raw Normal View History

2023-03-03 12:50:50 +01:00
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:smoke_cess_app/models/sleep.dart';
2023-03-06 00:05:11 +01:00
import 'package:smoke_cess_app/widgets/entry_detail_widget.dart';
import 'package:smoke_cess_app/widgets/history_list_widget.dart';
2023-03-05 20:54:08 +01:00
import 'package:smoke_cess_app/widgets/line_chart_widget.dart';
2023-03-05 18:17:08 +01:00
import 'package:smoke_cess_app/providers/tasks_provider.dart';
2023-03-05 20:54:08 +01:00
import 'package:syncfusion_flutter_charts/charts.dart';
2023-03-03 12:50:50 +01:00
class SleepView extends StatelessWidget {
const SleepView({super.key});
@override
Widget build(BuildContext context) {
2023-03-05 20:54:08 +01:00
TasksProvider tasksModel = context.watch<TasksProvider>();
2023-03-03 12:50:50 +01:00
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
2023-03-05 20:54:08 +01:00
LineChart<Sleep>(
series: [
2023-03-03 12:50:50 +01:00
LineSeries<Sleep, DateTime>(
dataSource: tasksModel.sleepHistory,
xValueMapper: (Sleep value, _) => value.date,
yValueMapper: (Sleep value, _) => value.sleepQualitiyValue)
],
),
2023-03-06 00:05:11 +01:00
HistoryList(
history: tasksModel.sleepHistory,
dateSelector: (Sleep sleep) => sleep.date,
entryDataSelector: (Sleep sleep) =>
'${sleep.sleepDuration.hour}:${sleep.sleepDuration.minute}')
2023-03-03 12:50:50 +01:00
],
);
}
}