@@ -9,6 +9,8 @@ import 'package:mental_health/features/auth/domain/entities/auth/googleapisignin
9
9
import 'package:mental_health/features/meditation/presentation/bloc/dailyQuote/daily_quote_bloc.dart' ;
10
10
import 'package:mental_health/features/meditation/presentation/bloc/dailyQuote/daily_quote_event.dart' ;
11
11
import 'package:mental_health/features/meditation/presentation/bloc/dailyQuote/daily_quote_state.dart' ;
12
+ import 'package:mental_health/features/meditation/presentation/bloc/mood_data/mood_data_bloc.dart' ;
13
+ import 'package:mental_health/features/meditation/presentation/bloc/mood_data/mood_data_state.dart' ;
12
14
import 'package:mental_health/features/meditation/presentation/bloc/mood_message/mood_message_bloc.dart' ;
13
15
import 'package:mental_health/features/meditation/presentation/bloc/mood_message/mood_message_event.dart' ;
14
16
import 'package:mental_health/features/meditation/presentation/bloc/mood_message/mood_message_state.dart' ;
@@ -42,54 +44,6 @@ class _MeditationPageState extends State<MeditationPage> {
42
44
TooltipBehavior (enable: true , format: 'point.x : point.y%' );
43
45
__tooltipBehavior = _tooltipBehavior;
44
46
45
- __chartData = < ChartSampleData > [
46
- ChartSampleData (
47
- x: 'Mon' , y: 16 , secondSeriesYValue: 8 , thirdSeriesYValue: 13 ),
48
- ChartSampleData (
49
- x: 'Tue' , y: 8 , secondSeriesYValue: 10 , thirdSeriesYValue: 7 ),
50
- ChartSampleData (
51
- x: 'Wed' , y: 12 , secondSeriesYValue: 10 , thirdSeriesYValue: 5 ),
52
- ChartSampleData (
53
- x: 'Thurs' , y: 4 , secondSeriesYValue: 8 , thirdSeriesYValue: 14 ),
54
- ChartSampleData (
55
- x: 'Fri' , y: 8 , secondSeriesYValue: 5 , thirdSeriesYValue: 4 ),
56
- ChartSampleData (
57
- x: 'Sat' , y: 3 , secondSeriesYValue: 3 , thirdSeriesYValue: 6 ),
58
- ];
59
-
60
- dataSources = < ChartSampleData > [
61
- ChartSampleData (
62
- x: 'Happy' ,
63
- y: 62.70 ,
64
- text: '10%' ,
65
- pointColor: const Color .fromRGBO (69 , 186 , 161 , 1.0 )),
66
- ChartSampleData (
67
- x: 'Neutral' ,
68
- y: 29.20 ,
69
- text: '10%' ,
70
- pointColor: const Color .fromRGBO (230 , 135 , 111 , 1.0 )),
71
- ChartSampleData (
72
- x: 'Sad' ,
73
- y: 85.20 ,
74
- text: '100%' ,
75
- pointColor: const Color .fromRGBO (145 , 132 , 202 , 1.0 )),
76
- ChartSampleData (
77
- x: 'Calm' ,
78
- y: 85.20 ,
79
- text: '100%' ,
80
- pointColor: const Color .fromRGBO (145 , 132 , 202 , 1.0 )),
81
- ChartSampleData (
82
- x: 'Relax' ,
83
- y: 85.20 ,
84
- text: '100%' ,
85
- pointColor: const Color .fromRGBO (145 , 132 , 202 , 1.0 )),
86
- ChartSampleData (
87
- x: 'Focus' ,
88
- y: 45.70 ,
89
- text: '100%' ,
90
- pointColor: const Color .fromRGBO (235 , 96 , 143 , 1.0 ))
91
- ];
92
-
93
47
_annotationSources = < CircularChartAnnotation > [
94
48
CircularChartAnnotation (
95
49
widget: ClipRRect (
@@ -800,7 +754,65 @@ class _MeditationPageState extends State<MeditationPage> {
800
754
textAlign: TextAlign .center,
801
755
),
802
756
//graph
803
- _buildColumnChart ()
757
+ BlocBuilder <MoodDataBloc ,MoodDataState >(builder: (context,state){
758
+ if (state is MoodDataLoaded ){
759
+ __chartData = < ChartSampleData > [
760
+ ChartSampleData (x: 'Mon' , y: num .parse (state.moodDatainfo.happy), secondSeriesYValue: num .parse (state.moodDatainfo.neutral), thirdSeriesYValue: num .parse (state.moodDatainfo.calm)),
761
+ ChartSampleData (x: 'Tue' , y: num .parse (state.moodDatainfo.happy), secondSeriesYValue: num .parse (state.moodDatainfo.neutral), thirdSeriesYValue: num .parse (state.moodDatainfo.calm)),
762
+ ChartSampleData (x: 'Wed' , y: num .parse (state.moodDatainfo.happy), secondSeriesYValue: num .parse (state.moodDatainfo.neutral), thirdSeriesYValue: num .parse (state.moodDatainfo.calm)),
763
+ ChartSampleData (x: 'Thurs' , y: num .parse (state.moodDatainfo.happy), secondSeriesYValue: num .parse (state.moodDatainfo.neutral), thirdSeriesYValue: num .parse (state.moodDatainfo.calm)),
764
+ ChartSampleData (x: 'Fri' , y: num .parse (state.moodDatainfo.happy), secondSeriesYValue: num .parse (state.moodDatainfo.neutral), thirdSeriesYValue: num .parse (state.moodDatainfo.calm)),
765
+ ChartSampleData (x: 'Sat' , y: num .parse (state.moodDatainfo.happy), secondSeriesYValue: num .parse (state.moodDatainfo.neutral), thirdSeriesYValue: num .parse (state.moodDatainfo.calm)),
766
+ ChartSampleData (x: 'Sun' , y: num .parse (state.moodDatainfo.happy), secondSeriesYValue: num .parse (state.moodDatainfo.neutral), thirdSeriesYValue: num .parse (state.moodDatainfo.calm)),
767
+
768
+ ];
769
+
770
+ num total = num .parse (state.moodDatainfo.happy)+ num .parse (state.moodDatainfo.neutral)+ num .parse (state.moodDatainfo.sad)+ num .parse (state.moodDatainfo.calm)+ num .parse (state.moodDatainfo.relax)+ num .parse (state.moodDatainfo.focus);
771
+ dataSources = < ChartSampleData > [
772
+ ChartSampleData (
773
+ x: 'Happy' ,
774
+ y: num .parse (state.moodDatainfo.happy)/ total,
775
+ text: '10%' ,
776
+ pointColor: const Color .fromRGBO (69 , 186 , 161 , 1.0 )),
777
+ ChartSampleData (
778
+ x: 'Neutral' ,
779
+ y: num .parse (state.moodDatainfo.neutral)/ total,
780
+ text: '10%' ,
781
+ pointColor: const Color .fromRGBO (230 , 135 , 111 , 1.0 )),
782
+ ChartSampleData (
783
+ x: 'Sad' ,
784
+ y: num .parse (state.moodDatainfo.sad)/ total,
785
+ text: '100%' ,
786
+ pointColor: const Color .fromRGBO (145 , 132 , 202 , 1.0 )),
787
+ ChartSampleData (
788
+ x: 'Calm' ,
789
+ y: num .parse (state.moodDatainfo.calm)/ total,
790
+ text: '100%' ,
791
+ pointColor: const Color .fromRGBO (145 , 132 , 202 , 1.0 )),
792
+ ChartSampleData (
793
+ x: 'Relax' ,
794
+ y: num .parse (state.moodDatainfo.relax)/ total,
795
+ text: '100%' ,
796
+ pointColor: const Color .fromRGBO (145 , 132 , 202 , 1.0 )),
797
+ ChartSampleData (
798
+ x: 'Focus' ,
799
+ y: num .parse (state.moodDatainfo.focus)/ total,
800
+ text: '100%' ,
801
+ pointColor: const Color .fromRGBO (235 , 96 , 143 , 1.0 ))
802
+ ];
803
+ return _buildColumnChart ();
804
+ }
805
+ if (state is MoodDataLoading ){
806
+ return const Text ("loading" );
807
+ }
808
+
809
+ if (state is MoodDataError ){
810
+ return Text (state.message);
811
+ }
812
+ return Container ();
813
+
814
+ })
815
+
804
816
],
805
817
),
806
818
),
@@ -852,6 +864,7 @@ class _MeditationPageState extends State<MeditationPage> {
852
864
return Container ();
853
865
},
854
866
),
867
+
855
868
],
856
869
),
857
870
),
0 commit comments