38 lines
1.3 KiB
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/models/workout.dart';
|
|
import 'package:syncfusion_flutter_charts/charts.dart';
|
|
import '../providers/tasks_provider.dart';
|
|
|
|
class WorkoutView extends StatelessWidget {
|
|
const WorkoutView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var tasksModel = context.watch<TasksProvider>();
|
|
return Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
SfCartesianChart(
|
|
primaryXAxis: DateTimeAxis(),
|
|
series: <ChartSeries>[
|
|
LineSeries<Workout, DateTime>(
|
|
dataSource: tasksModel.workoutHistory,
|
|
xValueMapper: (Workout value, _) => value.date,
|
|
yValueMapper: (Workout value, _) => value.motivationBefore),
|
|
LineSeries<Workout, DateTime>(
|
|
dataSource: tasksModel.workoutHistory,
|
|
xValueMapper: (Workout value, _) => value.date,
|
|
yValueMapper: (Workout value, _) => value.motivationAfter)
|
|
],
|
|
),
|
|
Column(
|
|
children: tasksModel.sleepHistory.map((sleep) {
|
|
return Text('${sleep.date}: ${sleep.sleepQualitiyValue}');
|
|
}).toList())
|
|
],
|
|
);
|
|
}
|
|
}
|