3
3
import 'dart:typed_data' ;
4
4
5
5
import 'package:flutter/material.dart' ;
6
+ // ignore: import_of_legacy_library_into_null_safe
7
+ import 'package:pie_chart/pie_chart.dart' ;
6
8
import 'package:provider/provider.dart' ;
7
9
import 'package:tutor_me/src/colorpallete.dart' ;
8
10
import 'package:tutor_me/src/pages/badges.dart' ;
@@ -12,6 +14,8 @@ import '../../services/models/globals.dart';
12
14
import '../../services/models/users.dart' ;
13
15
import '../../services/services/user_services.dart' ;
14
16
import '../theme/themes.dart' ;
17
+ import '../tutorAndTuteeCollaboration/tuteeGroups/home_tutee_groups.dart' ;
18
+
15
19
16
20
class Home extends StatefulWidget {
17
21
final Globals globals;
@@ -68,19 +72,87 @@ class _HomeState extends State<Home> {
68
72
}
69
73
70
74
getUserType () async {
71
- final type =
72
- await UserServices . getUserType ( widget.globals.getUser.getUserTypeID, widget.globals);
75
+ final type = await UserServices . getUserType (
76
+ widget.globals.getUser.getUserTypeID, widget.globals);
73
77
74
78
userType = type;
75
79
76
80
// getConnections();
77
81
getTuteeProfileImage ();
78
82
}
79
83
84
+ int key = 0 ;
85
+
86
+ Map <String , double > dataMap = {
87
+ "Meetings" : 5 ,
88
+ "Connections" : 3 ,
89
+ "Interactions" : 2 ,
90
+ "Ratings" : 2 ,
91
+ };
92
+
93
+ List <Color > chartColorList = [
94
+ Colors .blue,
95
+ colorLightGreen,
96
+ Colors .orange,
97
+ Colors .yellow,
98
+ ];
99
+
100
+ Widget buildChart () {
101
+ return PieChart (
102
+ key: ValueKey (key),
103
+ dataMap: dataMap,
104
+ initialAngleInDegree: 0 ,
105
+ animationDuration: const Duration (milliseconds: 3500 ),
106
+ chartType: ChartType .ring,
107
+ ringStrokeWidth: 12 ,
108
+ colorList: chartColorList,
109
+ chartLegendSpacing: 34 ,
110
+ chartRadius: MediaQuery .of (context).size.width / 4.2 ,
111
+ chartValuesOptions: ChartValuesOptions (
112
+ showChartValueBackground: true ,
113
+ showChartValues: true ,
114
+ showChartValuesInPercentage: true ,
115
+ showChartValuesOutside: true ,
116
+ decimalPlaces: 1 ,
117
+ chartValueStyle: TextStyle (
118
+ color: const Color .fromARGB (255 , 49 , 47 , 47 ),
119
+ fontWeight: FontWeight .normal,
120
+ fontSize: MediaQuery .of (context).size.width * 0.04 ,
121
+ ),
122
+ ),
123
+ // centerText: 'Progress',
124
+ legendOptions: LegendOptions (
125
+ showLegendsInRow: false ,
126
+ legendPosition: LegendPosition .right,
127
+ showLegends: true ,
128
+ legendShape: BoxShape .circle,
129
+ legendTextStyle: TextStyle (
130
+ fontWeight: FontWeight .bold,
131
+ color: colorDarkGrey,
132
+ fontSize: MediaQuery .of (context).size.width * 0.03 ),
133
+ ),
134
+ );
135
+ }
136
+ // List<
137
+
138
+ // _generateData() {
139
+ // var data = [
140
+ // Task(
141
+ // task: 'Meetings',
142
+ // taskValue: 35.8,
143
+ // color: const Color(0xff3366cc),
144
+ // ),
145
+ // Task(task: 'Connections', taskValue: 4, color: colorOrange),
146
+ // Task(task: 'Badges', taskValue: 1, color: colorLightGreen),
147
+ // Task(task: 'OverAll', taskValue: 32, color: colorBlueTeal),
148
+ // ];
149
+ // }
150
+
80
151
@override
81
152
void initState () {
82
153
super .initState ();
83
154
getUserType ();
155
+ // _generateData();
84
156
}
85
157
86
158
Widget buildBody () {
@@ -114,12 +186,6 @@ class _HomeState extends State<Home> {
114
186
String name = widget.globals.getUser.getName;
115
187
String fullName = name + ' ' + widget.globals.getUser.getLastName;
116
188
117
- // FilePickerResult? filePickerResult;
118
- // String? fileName;
119
- // PlatformFile? file;
120
- // bool isUploading = false;
121
- // File? fileToUpload;
122
-
123
189
return Column (
124
190
crossAxisAlignment: CrossAxisAlignment .start,
125
191
mainAxisAlignment: MainAxisAlignment .spaceBetween,
@@ -202,11 +268,11 @@ class _HomeState extends State<Home> {
202
268
child: Container (
203
269
width: screenWidthSize > 800 ? 500 : screenWidthSize * 0.8 ,
204
270
height: screenHeightSize * 0.2 ,
205
- decoration: const BoxDecoration (
206
- image : DecorationImage (
207
- image : AssetImage ( "assets/Pictures/progressBar.jpg" ),
208
- fit : BoxFit .cover ),
209
- borderRadius : BorderRadius . all ( Radius . circular ( 10 )) ),
271
+ decoration: BoxDecoration (
272
+ // color: Colors.black38,
273
+ border : Border . all (color : colorLightGrey. withOpacity ( 0.6 ) ),
274
+ borderRadius : const BorderRadius . all ( Radius . circular ( 10 )) ),
275
+ child : buildChart ( ),
210
276
),
211
277
),
212
278
SizedBox (height: screenHeightSize * 0.02 ),
@@ -221,7 +287,7 @@ class _HomeState extends State<Home> {
221
287
),
222
288
SizedBox (width: screenWidthSize * 0.02 ),
223
289
Text (
224
- "New meeting scheduled ..." ,
290
+ "How to increase your stats ..." ,
225
291
style: TextStyle (fontSize: screenHeightSize * 0.025 ),
226
292
),
227
293
],
@@ -247,11 +313,11 @@ class _HomeState extends State<Home> {
247
313
),
248
314
SizedBox (width: screenWidthSize * 0.02 ),
249
315
Text (
250
- "New meeting scheduled ..." ,
316
+ "What do the stats mean ? ..." ,
251
317
style: TextStyle (fontSize: screenHeightSize * 0.025 ),
252
318
),
253
319
Text (
254
- "more updates " ,
320
+ "more info " ,
255
321
style: TextStyle (color: highlightColor),
256
322
overflow: TextOverflow .ellipsis,
257
323
),
@@ -296,6 +362,11 @@ class _HomeState extends State<Home> {
296
362
//render Tutees Page
297
363
} else if (index == 1 ) {
298
364
//render Groups Page
365
+ Navigator .push (
366
+ context,
367
+ MaterialPageRoute (
368
+ builder: (context) =>
369
+ HomeTuteeGroups (globals: widget.globals)));
299
370
} else if (index == 2 ) {
300
371
//render Badges Page
301
372
Navigator .of (context).push (MaterialPageRoute (
@@ -391,3 +462,11 @@ class _HomeState extends State<Home> {
391
462
);
392
463
}
393
464
}
465
+
466
+ class Task {
467
+ String task;
468
+ double taskValue;
469
+ Color color;
470
+
471
+ Task ({required this .task, required this .taskValue, required this .color});
472
+ }
0 commit comments