Page MenuHomec4science

groupDashboard.Dart
No OneTemporary

File Metadata

Created
Wed, May 22, 08:10

groupDashboard.Dart

import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:Teacher_Dashboard/widgets/custom_app_bar.dart';
import 'package:Teacher_Dashboard/SoCKet.dart';
import 'dart:convert';
import 'package:Teacher_Dashboard/config/palette.dart';
import 'package:Teacher_Dashboard/config/styles.dart';
import 'package:Teacher_Dashboard/data/data.dart';
class GroupDashboard extends StatefulWidget {
@override
_groupDashboardState createState() => _groupDashboardState();
}
class _groupDashboardState extends State<GroupDashboard> {
final TextStyle whiteText = TextStyle(color: Colors.white);
var progress = 0;
var totalTaps = 0;
var inactivity = 0;
var mistakesSlope = 0;
var mistakesIntrepet = 0;
var groupName = "";
var mem1Name = "";
var mem2Name = "";
var mem3Name = "";
@override
void initState() {
super.initState();
///
/// Ask to be notified when messages related to the game
/// are sent by the server
///
// websocket.initCommunication();
websocket.addListener(_onDataReceived);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: CustomAppBar(),
body: _buildBody(context),
);
}
_onDataReceived(message) {
Map<String, dynamic> messageparse = jsonDecode(message);
switch (messageparse['action']) {
case 'progress_update':
Map<String, dynamic> messageparsedata =
jsonDecode(jsonEncode(messageparse['data']));
progress = messageparsedata['progress'];
totalTaps = messageparsedata['totalTaps'];
mistakesSlope = messageparsedata['mistakesSlope'];
mistakesIntrepet = messageparsedata['mistakesIntrepet'];
inactivity = messageparsedata['inactivity'];
debugPrint(totalTaps.toString());
setState(() {});
break;
}
// debugPrint(overallProgressindicators.toString());
// force rebuild
setState(() {});
}
Widget _buildBody(BuildContext context) {
return SingleChildScrollView(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
_buildHeader(),
SizedBox(height: 50.0),
_progressBar(),
SizedBox(height: 50.0),
Row(
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
Container(
height: 190,
color: Colors.blue,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Text(
totalTaps.toString(),
style:
Theme.of(context).textTheme.display1.copyWith(
color: Colors.white,
fontSize: 24.0,
),
),
trailing: Icon(
FontAwesomeIcons.walking,
color: Colors.white,
),
),
Padding(
padding: const EdgeInsets.only(left: 16.0),
child: Text(
'Trials',
style: whiteText,
),
)
],
),
),
const SizedBox(height: 10.0),
Container(
height: 120,
color: Colors.red,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Text(
mistakesIntrepet.toString(),
style:
Theme.of(context).textTheme.display1.copyWith(
color: Colors.white,
fontSize: 24.0,
),
),
trailing: Icon(
Icons.error,
color: Colors.white,
),
),
Padding(
padding: const EdgeInsets.only(left: 16.0),
child: Text(
'Mistakes in finding the Intrepet',
style: whiteText,
),
)
],
),
),
],
),
),
const SizedBox(width: 10.0),
Expanded(
child: Column(
children: <Widget>[
Container(
height: 120,
color: Colors.red,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Text(
mistakesSlope.toString(),
style:
Theme.of(context).textTheme.display1.copyWith(
color: Colors.white,
fontSize: 24.0,
),
),
trailing: Icon(
Icons.error,
color: Colors.white,
),
),
Padding(
padding: const EdgeInsets.only(left: 16.0),
child: Text(
'Mistakes in finding the slope',
style: whiteText,
),
)
],
),
),
const SizedBox(height: 10.0),
Container(
height: 190,
color: (inactivity > 3)
? ((inactivity > 10) ? Colors.red : Colors.yellow)
: Colors.green,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Text(
(inactivity > 3)
? ((inactivity > 10)
? "the group has not been activated for more than 300 seconds"
: "the group has not been activated for more than 30 seconds")
: "The group is active",
style:
Theme.of(context).textTheme.display1.copyWith(
fontSize: 24.0,
color: Colors.black,
),
),
trailing: Icon(
FontAwesomeIcons.running,
color: Colors.black,
),
),
],
),
),
],
),
)
],
)
],
),
);
}
Widget _progressBar() {
return Row(
children: <Widget>[
Container(
height: 100,
width: 100,
padding: const EdgeInsets.all(8.0),
child: CircularProgressIndicator(
value: progress / 3.toDouble(),
valueColor: AlwaysStoppedAnimation(Colors.blue),
backgroundColor: Colors.grey.shade700,
),
),
const SizedBox(width: 20.0),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Overall Progress",
style: TextStyle(color: Colors.black87, fontSize: 24.0),
),
const SizedBox(height: 20.0),
Text(
(3 - progress).toString() + " students to go",
style: TextStyle(color: Colors.black87, fontSize: 16.0),
),
],
),
)
],
);
}
}
Widget _buildHeader() {
return Container(
padding: const EdgeInsets.all(20.0),
decoration: BoxDecoration(
color: Palette.primaryColor,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40.0),
bottomRight: Radius.circular(40.0),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Group 1',
style: const TextStyle(
color: Colors.white,
fontSize: 25.0,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 30),
Row(
children: <Widget>[
Text(
groupsNames[0]['mem1'],
style: const TextStyle(
color: Colors.white,
fontSize: 22.0,
fontWeight: FontWeight.w600,
),
),
SizedBox(width: 20),
Text(
groupsNames[0]['mem2'],
style: const TextStyle(
color: Colors.white,
fontSize: 22.0,
fontWeight: FontWeight.w600,
),
),
SizedBox(width: 20),
Text(
groupsNames[0]['mem3'],
style: const TextStyle(
color: Colors.white,
fontSize: 22.0,
fontWeight: FontWeight.w600,
),
),
Text(
'',
style: const TextStyle(
color: Colors.white70,
fontSize: 15.0,
),
),
SizedBox(height: 40),
],
),
Text(
'Current Activity: Finding the mathematical formula for a line with simulation ',
style: const TextStyle(
color: Colors.white,
fontSize: 22.0,
fontWeight: FontWeight.w600,
),
),
],
),
);
}

Event Timeline