38 lines
1.4 KiB
Dart
38 lines
1.4 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.toString().padLeft(2, "0")}',
|
|
entryCommentSelector: (Sleep sleep) => 'Kommentar: ${sleep.comment}',
|
|
icon: Icons.bedtime_outlined,
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|