cpd_2022_zi/lib/widgets/view_form/mood_view.dart

37 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/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-03 12:50:50 +01:00
import 'package:syncfusion_flutter_charts/charts.dart';
2023-03-05 18:17:08 +01:00
import 'package:smoke_cess_app/models/mood.dart';
import 'package:smoke_cess_app/providers/tasks_provider.dart';
2023-03-03 12:50:50 +01:00
class MoodView extends StatelessWidget {
const MoodView({super.key});
@override
Widget build(BuildContext context) {
var tasksModel = context.watch<TasksProvider>();
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
2023-03-05 20:54:08 +01:00
LineChart(series: [
LineSeries<Mood, DateTime>(
dataSource: tasksModel.moodHistory,
xValueMapper: (Mood value, _) => value.date,
yValueMapper: (Mood value, _) => value.moodValue)
]),
HistoryList<Mood>(
history: tasksModel.moodHistory,
dateSelector: (Mood mood) => mood.date,
entryDataSelector: (Mood mood) => 'Stimmung: ${mood.moodValue}',
2023-03-06 14:55:56 +01:00
entryCommentSelector: (Mood mood) => 'Kommentar: ${mood.comment}',
iconDataSelector: (Mood mood) => mood.moodValue >= 50
? Icons.mood_outlined
: Icons.mood_bad_outlined,
)
2023-03-03 12:50:50 +01:00
],
);
}
}