cpd_2022_zi/lib/widgets/view_form/sleep_view.dart

38 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:smoke_cess_app/models/sleep.dart';
import 'package:smoke_cess_app/widgets/history_list_widget.dart';
import 'package:smoke_cess_app/widgets/line_chart_widget.dart';
import 'package:smoke_cess_app/providers/tasks_provider.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
class SleepView extends StatelessWidget {
const SleepView({super.key});
@override
Widget build(BuildContext context) {
TasksProvider tasksModel = context.watch<TasksProvider>();
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
LineChart<Sleep>(
series: [
LineSeries<Sleep, DateTime>(
dataSource: tasksModel.sleepHistory,
xValueMapper: (Sleep value, _) => value.date,
yValueMapper: (Sleep value, _) => value.sleepQualitiyValue)
],
),
HistoryList<Sleep>(
history: tasksModel.sleepHistory,
dateSelector: (Sleep sleep) => sleep.date,
entryDataSelector: (Sleep sleep) =>
'${sleep.sleepDuration.hour}:${sleep.sleepDuration.minute}',
entryCommentSelector: (Sleep sleep) => 'Kommentar: ${sleep.comment}',
icon: Icons.bedtime_outlined,
)
],
);
}
}