33 lines
993 B
Dart
33 lines
993 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:syncfusion_flutter_charts/charts.dart';
|
|
import '../models/mood.dart';
|
|
import '../providers/tasks_provider.dart';
|
|
|
|
class MoodView extends StatelessWidget {
|
|
const MoodView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var tasksModel = context.watch<TasksProvider>();
|
|
return Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
SfCartesianChart(
|
|
primaryXAxis: DateTimeAxis(),
|
|
series: <ChartSeries>[
|
|
LineSeries<Mood, DateTime>(
|
|
dataSource: tasksModel.moodHistory,
|
|
xValueMapper: (Mood value, _) => value.date,
|
|
yValueMapper: (Mood value, _) => value.moodValue)
|
|
],
|
|
),
|
|
Column(
|
|
children: tasksModel.moodHistory.map((mood) {
|
|
return Text('${mood.date}: ${mood.moodValue}');
|
|
}).toList())
|
|
],
|
|
);
|
|
}
|
|
}
|