2023-03-03 12:50:50 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2023-03-06 00:34:45 +01:00
|
|
|
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)
|
|
|
|
]),
|
2023-03-06 00:34:45 +01:00
|
|
|
HistoryList<Mood>(
|
|
|
|
history: tasksModel.moodHistory,
|
|
|
|
dateSelector: (Mood mood) => mood.date,
|
|
|
|
entryDataSelector: (Mood mood) => 'Stimmung: ${mood.moodValue}',
|
|
|
|
iconDataSelector: (Mood mood) => mood.moodValue >= 50
|
|
|
|
? Icons.mood_outlined
|
|
|
|
: Icons.mood_bad_outlined,
|
|
|
|
)
|
2023-03-03 12:50:50 +01:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|