diff --git a/Dashboard/lib/model/turn.dart b/Dashboard/lib/model/turn.dart index 7213fae..7679d86 100644 --- a/Dashboard/lib/model/turn.dart +++ b/Dashboard/lib/model/turn.dart @@ -1,25 +1,25 @@ import 'package:Teacher_Dashboard/model/cellulo.dart'; class Turn { String id; // String _title; // String _description; int numAttempts = 0; int elapsedTime = 0; var mistakes = { "slope": 0, "initialPoint": 0, "intercept": 0, }; Cellulo cellulox = new Cellulo(); Cellulo celluloy = new Cellulo(); Cellulo cellulov = new Cellulo(); var mapHit = { - 'Circles': [0, 0, 0, 0, 0, 0], - 'Rectangles': [0, 0, 0, 0, 0], - 'Polygons': [0, 0, 0, 0, 0, 0], + 'Circles': [0, 0, 0, 0, 0, 0, 0, 0], + 'Rectangles': [0, 0, 0, 0, 0, 0, 0], + 'Polygons': [0, 0, 0, 0, 0, 0, 0], }; Turn(); } diff --git a/Dashboard/lib/screens/Debriefing.dart b/Dashboard/lib/screens/Debriefing.dart index 6ede1ca..f5b90f0 100644 --- a/Dashboard/lib/screens/Debriefing.dart +++ b/Dashboard/lib/screens/Debriefing.dart @@ -1,284 +1,618 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:Teacher_Dashboard/widgets/custom_app_bar.dart'; import 'dart:convert'; import 'package:Teacher_Dashboard/config/palette.dart'; import 'package:Teacher_Dashboard/config/styles.dart'; import 'dart:async'; import './screens.dart'; import 'package:Teacher_Dashboard/model/Class.dart'; import 'package:Teacher_Dashboard/model/Group.dart'; import 'package:firebase_database/firebase_database.dart'; import 'package:Teacher_Dashboard/model/activities/activity.Dart'; import 'package:step_progress_indicator/step_progress_indicator.dart'; import 'package:Teacher_Dashboard/widgets/hexagonPainter.Dart'; import 'package:Teacher_Dashboard/widgets/celluloMap.Dart'; +import 'package:Teacher_Dashboard/widgets/mapShapeMaker.dart'; + import 'package:provider/provider.dart'; //import 'package:Teacher_Dashboard/model/core/models/productModel.dart'; //import 'package:Teacher_Dashboard/model/core/viewmodels/CRUDModel.dart'; //import 'package:provider/provider.dart'; class Debriefing extends StatefulWidget { @override DebriefingState createState() => DebriefingState(); } class DebriefingState extends State { bool mistakesSwitch = false; bool rankingSwitch = false; bool robotPatternSwitch = true; int numofgroups = thisClass.groups.length; int currentstepActivation = 0; String pauseButtonText = 'Pause All'; final FirebaseDatabase _database = FirebaseDatabase.instance; @override void initState() { super.initState(); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { // final productProvider = Provider.of(context); return Scaffold( backgroundColor: Colors.white, appBar: AppBar( - backgroundColor: Palette.primaryColor, - elevation: 0.0, - title: Text('Debreifing'), - // leading: IconButton( - // icon: const Icon(Icons.menu), - // iconSize: 28.0, - // onPressed: () {}, - // ), - // actions: [ - // IconButton( - // icon: const Icon(Icons.notifications_none), - // iconSize: 28.0, - // onPressed: () {}, - // ), - // ], - ), + backgroundColor: Palette.primaryColor, + elevation: 0.0, + title: Text('Debreifing'), + // leading: IconButton( + // icon: const Icon(Icons.menu), + // iconSize: 28.0, + // onPressed: () {}, + // ), + // actions: [ + // IconButton( + // icon: const Icon(Icons.notifications_none), + // iconSize: 28.0, + // onPressed: () {}, + // ), + // ], + ), body: Column(children: [ SizedBox( height: 800, child: Consumer( builder: (context, model, child) => Container( child: ListView.builder( itemCount: thisClass.groups.length, itemBuilder: (context, int position) { return Card( child: ListTile( onLongPress: () { Navigator.push( context, MaterialPageRoute( builder: (context) => GroupDashboard(currentgroupID: position))); }, title: Row(children: [ SizedBox(width: 17), Stack(children: [ CircularStepProgressIndicator( totalSteps: 3, // currentStep: // thisClass.groups[position].activities[0].progress, width: 100, customColor: (index) => thisClass .groups[position] .activities[acList.indexOf(thisClass .groups[position].currentActivity)] .progress[index] > -2 ? (thisClass .groups[position] .activities[acList.indexOf(thisClass .groups[position] .currentActivity)] .progress[index] > -1 ? (thisClass .groups[position] .activities[acList.indexOf(thisClass.groups[position].currentActivity)] .progress[index] > 0 ? Colors.green : Colors.blue) : Colors.red) : Colors.grey, ), Positioned( bottom: 45, right: 28, child: Center( child: Text( thisClass.groups[position].id, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 13), )), ), ]), SizedBox(width: 25), minituare(position, 1, mistakesSwitch, rankingSwitch, robotPatternSwitch), SizedBox( width: 25, ), minituare(position, 2, mistakesSwitch, rankingSwitch, robotPatternSwitch), SizedBox( width: 25, ), minituare(position, 3, mistakesSwitch, rankingSwitch, robotPatternSwitch), ]), trailing: Icon(Icons.more_vert), )); }, )), )), /* Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'Show Students Mistakes', style: TextStyle( fontSize: 15.0, // color: Colors.white, fontWeight: FontWeight.bold), ), SizedBox(width: 5), Checkbox( //title: const Text('Animate Slowly'), value: mistakesSwitch, onChanged: (bool value) { setState(() { mistakesSwitch = value; }); }, // secondary: const Icon(Icons.hourglass_empty), ), SizedBox(width: 300), /* Text( 'Show Students robot pattern', style: TextStyle( fontSize: 15.0, // color: Colors.white, fontWeight: FontWeight.bold), ), SizedBox(width: 5), Checkbox( value: robotPatternSwitch, onChanged: (bool value) { setState(() { robotPatternSwitch = value; }); }, // secondary: const Icon(Icons.hourglass_empty), ), */ ]), */ ])); } } Widget minituare(int position, int turn, bool mistakesSwitch, bool rankingSwitch, bool robotpatternSwitch) { var colors = [Colors.grey, Colors.red, Colors.blue, Colors.green]; List gColor; + double screenSizeWidth = 90; + double screenSizeHeight = 90; + double mapSizeWidth = 860; + double mapSizeHeight = 860; + int activityID = acList.indexOf(thisClass.groups[position].currentActivity); + int turnID = turn - 1; + int groupID = position; List gridAcsPath = [ "assets/images/GridOnlyPositive.svg", "assets/images/Grid.svg", "assets/images/Grid_Ac5_Screen.svg", "assets/images/Grid_Ac6_Screen.svg", "assets/images/Grid_Ac5_Screen.svg", "assets/images/Grid_Ac6_Screen.svg", "assets/images/Grid_Ac7_Screen.svg", "assets/images/Grid_Ac8_Screen.svg", ]; + List pointPosition = [ + Offset(80, 80), + Offset(760, 80), + Offset(80, 760), + Offset(760, 760) + ]; + var mapShape = [ + [ + { + 'numCircles': 4, + 'originCircles': [ + Offset(390, 300), + Offset(190, 170), + Offset(60, 360), + Offset(560, 690) + ], + 'radiuosCircles': [60.0, 70.0, 60.0, 60.0], + 'numRectangles': 2, + 'originRectangles': [Offset(300, 30), Offset(300, 560)], + 'widthRectangles': [150.0, 100.0], + 'heightRectangles': [50.0, 250.0], + 'numPolygons': 5, + 'sidesofPolygon': [3, 3, 5, 4, 4], + 'radiusPolygon': [60.0, 70.0, 70.0, 60.0, 80.0], + 'centerPolygon': [ + Offset(60, 230), + Offset(600, 90), + Offset(600, 250), + Offset(600, 500), + Offset(780, 400) + ], + 'startCenter': pointPosition[2], + 'endCenter': pointPosition[1] + }, + { + 'numCircles': 2, + 'originCircles': [ + Offset(380, 320), + Offset(160, 290), + ], + 'radiuosCircles': [60.0, 70.0], + 'numRectangles': 3, + 'originRectangles': [ + Offset(100, 500), + Offset(700, 560), + Offset(500, 360) + ], + 'widthRectangles': [150.0, 100.0, 80.0], + 'heightRectangles': [50.0, 250.0, 230.0], + 'numPolygons': 4, + 'sidesofPolygon': [3, 5, 4, 4], + 'radiusPolygon': [70.0, 80.0, 70.0, 70.0], + 'centerPolygon': [ + Offset(300, 90), + Offset(600, 60), + Offset(500, 650), + Offset(780, 300) + ], + 'startCenter': pointPosition[0], + 'endCenter': pointPosition[3] + }, + { + 'numCircles': 3, + 'originCircles': [ + Offset(260, 170), + Offset(490, 560), + Offset(690, 590), + ], + 'radiuosCircles': [80.0, 70.0, 70.0], + 'numRectangles': 2, + 'originRectangles': [Offset(500, 30), Offset(350, 560)], + 'widthRectangles': [150.0, 100.0], + 'heightRectangles': [80.0, 300.0], + 'numPolygons': 3, + 'sidesofPolygon': [3, 4, 4], + 'radiusPolygon': [70.0, 90.0, 80.0], + 'centerPolygon': [ + Offset(40, 630), + Offset(70, 390), + Offset(620, 220), + ], + 'startCenter': pointPosition[2], + 'endCenter': pointPosition[1] + }, + ], + [ + { + 'numCircles': 0, + 'originCircles': [ + Offset(390, 300), + Offset(160, 70), + Offset(60, 360), + Offset(560, 690) + ], + 'radiuosCircles': [60.0, 50.0, 50.0, 40.0], + 'numRectangles': 5, + 'originRectangles': [ + Offset(300, 30), + Offset(200, 560), + Offset(400, 760), + Offset(780, 460), + Offset(650, 500) + ], + 'widthRectangles': [150.0, 100.0, 50.0, 100.0, 100.0], + 'heightRectangles': [50.0, 250.0, 300.0, 50.0, 100.0], + 'numPolygons': 4, + 'sidesofPolygon': [4, 4, 4, 4], + 'radiusPolygon': [70.0, 70.0, 50.0, 60.0, 50.0], + 'centerPolygon': [ + Offset(60, 280), + Offset(500, 140), + Offset(600, 200), + Offset(500, 500), + Offset(680, 400) + ], + 'startCenter': pointPosition[2], + 'endCenter': pointPosition[1] + }, + { + 'numCircles': 0, + 'originCircles': [ + Offset(390, 300), + Offset(160, 70), + Offset(60, 360), + Offset(560, 690) + ], + 'radiuosCircles': [60.0, 50.0, 50.0, 40.0], + 'numRectangles': 4, + 'originRectangles': [ + Offset(300, 30), + Offset(300, 560), + Offset(500, 560), + Offset(750, 360) + ], + 'widthRectangles': [ + 150.0, + 100.0, + 50.0, + 150.0, + ], + 'heightRectangles': [50.0, 250.0, 250.0, 300.0], + 'numPolygons': 4, + 'sidesofPolygon': [4, 4, 4, 4], + 'radiusPolygon': [80.0, 60.0, 50.0, 60.0], + 'centerPolygon': [ + Offset(100, 330), + Offset(600, 90), + Offset(500, 200), + Offset(400, 350), + ], + 'startCenter': pointPosition[0], + 'endCenter': pointPosition[3] + }, + { + 'numCircles': 0, + 'originCircles': [ + Offset(390, 300), + Offset(160, 70), + Offset(60, 360), + Offset(560, 690) + ], + 'radiuosCircles': [60.0, 50.0, 50.0, 40.0], + 'numRectangles': 3, + 'originRectangles': [ + Offset(350, 70), + Offset(300, 560), + Offset(700, 520) + ], + 'widthRectangles': [350.0, 300.0, 100.0], + 'heightRectangles': [50.0, 250.0, 100.0], + 'numPolygons': 3, + 'sidesofPolygon': [4, 4, 4], + 'radiusPolygon': [100.0, 60.0, 70.0], + 'centerPolygon': [ + Offset(80, 230), + Offset(650, 190), + Offset(400, 250), + ], + 'startCenter': pointPosition[2], + 'endCenter': pointPosition[1] + }, + ], + [ + { + 'numCircles': 0, + 'originCircles': [Offset(0, 0)], + 'radiuosCircles': [0.0], + 'numRectangles': 7, + 'originRectangles': [ + Offset(100, 200), + Offset(100, 560), + Offset(600, 630), + Offset(780, 360), + Offset(300, 300), + Offset(500, 260), + Offset(300, 560) + ], + 'widthRectangles': [150.0, 100.0, 50.0, 80.0, 150.0, 100.0, 100.0], + 'heightRectangles': [70.0, 100.0, 200.0, 300.0, 40.0, 300.0, 200.0], + 'numPolygons': 0, + 'sidesofPolygon': [0], + 'radiusPolygon': [0.0], + 'centerPolygon': [Offset(0, 0)], + 'startCenter': pointPosition[2], + 'endCenter': pointPosition[1] + }, + { + 'numCircles': 0, + 'originCircles': [Offset(0, 0)], + 'radiuosCircles': [0.0], + 'numRectangles': 7, + 'originRectangles': [ + Offset(690, 430), + Offset(500, 560), + Offset(430, 130), + Offset(300, 760), + Offset(100, 230), + Offset(100, 460), + Offset(700, 260) + ], + 'widthRectangles': [150.0, 100.0, 200.0, 100.0, 210.0, 210.0, 110.0], + 'heightRectangles': [150.0, 250.0, 50.0, 250.0, 50.0, 200.0, 90.0], + 'numPolygons': 0, + 'sidesofPolygon': [3, 3, 5, 4, 4], + 'radiusPolygon': [30.0, 40.0, 40.0, 40.0, 50.0], + 'centerPolygon': [ + Offset(40, 130), + Offset(700, 90), + Offset(600, 200), + Offset(600, 500), + Offset(780, 400) + ], + 'startCenter': pointPosition[0], + 'endCenter': pointPosition[3] + }, + { + 'numCircles': 0, + 'originCircles': [Offset(0, 0)], + 'radiuosCircles': [0.0], + 'numRectangles': 7, + 'originRectangles': [ + Offset(300, 130), + Offset(500, 460), + Offset(750, 530), + Offset(600, 130), + Offset(600, 730), + Offset(100, 530), + Offset(350, 460) + ], + 'widthRectangles': [160.0, 90.0, 150.0, 100.0, 150.0, 200.0, 50.0], + 'heightRectangles': [130.0, 270.0, 150.0, 250.0, 100.0, 70.0, 250.0], + 'numPolygons': 0, + 'sidesofPolygon': [0], + 'radiusPolygon': [0.0], + 'centerPolygon': [Offset(0, 0)], + 'startCenter': pointPosition[2], + 'endCenter': pointPosition[1] + }, + ] + ]; + return Container( width: 130, height: 180, decoration: BoxDecoration( border: Border.all( width: 0.5, color: colors[ thisClass.groups[position].activities[0].progress[turn - 1] + 2])), child: Stack(children: [ Positioned( - bottom: 65, - right: 30, - width: 90, - height: 90, - child: celluloMap( - gridAcsPath[ - acList.indexOf(thisClass.groups[position].currentActivity)], - turn, - acList.indexOf(thisClass.groups[position].currentActivity), - robotpatternSwitch, - thisClass - .groups[position] - .activities[acList - .indexOf(thisClass.groups[position].currentActivity)] - .turns[turn - 1] - .cellulov - .x, - thisClass - .groups[position] - .activities[acList - .indexOf(thisClass.groups[position].currentActivity)] - .turns[turn - 1] - .cellulov - .y, - 90, - 90)), + bottom: 65, + right: 30, + width: 90, + height: 90, + child: (acList.indexOf(thisClass.groups[position].currentActivity) > + 2) + ? celluloMap( + gridAcsPath[acList + .indexOf(thisClass.groups[position].currentActivity)], + turn, + acList.indexOf(thisClass.groups[position].currentActivity), + robotpatternSwitch, + thisClass + .groups[position] + .activities[acList + .indexOf(thisClass.groups[position].currentActivity)] + .turns[turn - 1] + .cellulov + .x, + thisClass + .groups[position] + .activities[acList + .indexOf(thisClass.groups[position].currentActivity)] + .turns[turn - 1] + .cellulov + .y, + 90, + 90) + : Container( + width: screenSizeWidth, + height: screenSizeHeight, + child: Stack(children: [ + CustomPaint( + //size: Size(200, 200), + painter: MapShapeMaker( + screenSizeWidth / mapSizeWidth, + screenSizeHeight / mapSizeHeight, + mapShape[activityID][turnID]['numRectangles'], + mapShape[activityID][turnID]['originRectangles'], + mapShape[activityID][turnID]['widthRectangles'], + mapShape[activityID][turnID]['heightRectangles'], + mapShape[activityID][turnID]['numCircles'], + mapShape[activityID][turnID]['originCircles'], + mapShape[activityID][turnID]['radiuosCircles'], + mapShape[activityID][turnID]['numPolygons'], + mapShape[activityID][turnID]['sidesofPolygon'], + mapShape[activityID][turnID]['radiusPolygon'], + mapShape[activityID][turnID]['centerPolygon'], + mapShape[activityID][turnID]['startCenter'], + mapShape[activityID][turnID]['endCenter'], + (thisClass.groups.length > 0) + ? thisClass.groups[groupID] + .activities[activityID].turns[turnID].mapHit + : { + 'Circles': [0, 0, 0, 0, 0, 0, 0], + 'Rectangles': [0, 0, 0, 0, 0, 0], + 'Polygons': [0, 0, 0, 0, 0, 0, 0], + })), + celluloMap2( + turnID + 1, + activityID, + true, + (thisClass.groups.length > 0) + ? thisClass.groups[groupID].activities[activityID] + .turns[turnID].cellulov.x + : [0, 0], + (thisClass.groups.length > 0) + ? thisClass.groups[groupID].activities[activityID] + .turns[turnID].cellulov.y + : [0, 0], + (thisClass.groups.length > 0) + ? thisClass.groups[groupID].activities[activityID] + .turns[turnID].cellulox.x + : [0, 0], + (thisClass.groups.length > 0) + ? thisClass.groups[groupID].activities[activityID] + .turns[turnID].cellulox.y + : [0, 0], + (thisClass.groups.length > 0) + ? thisClass.groups[groupID].activities[activityID] + .turns[turnID].celluloy.x + : [0, 0], + (thisClass.groups.length > 0) + ? thisClass.groups[groupID].activities[activityID] + .turns[turnID].celluloy.y + : [0, 0], + screenSizeWidth, + screenSizeHeight), + ])), + ), Positioned( bottom: 155, right: 27, child: Text( ((turn > 1) ? ((turn > 2) ? 'Third ' : 'Second ') : 'First ') + "Turn ", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14), )), Positioned(bottom: 4, right: 50, child: Text(rankingSwitch ? "" : "")), Positioned( bottom: 25, right: 6, child: Text( mistakesSwitch ? (thisClass.groups[position].activities[0].progress[turn - 1] > -2 ? (thisClass.groups[position].activities[0].mistakes['slope'][turn - 1] == 0 && thisClass.groups[position].activities[0].mistakes['initialPoint'][turn - 1] == 0 ? 'No Mistakes' : (thisClass.groups[position].activities[0].mistakes['slope'][turn - 1] > 0 && thisClass.groups[position].activities[0] .mistakes['initialPoint'][turn - 1] > 0 ? 'Mistakes in finding\n Slope and\n Initial Points' : (thisClass.groups[position].activities[0].mistakes['slope'][turn - 1] > 0 && thisClass.groups[position].activities[0] .mistakes['initialPoint'][turn - 1] == 0 ? 'Mistakes in finding\n slope' : 'Mistakes in finding\n initial points'))) : '') : '', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14), ), ) ])); } diff --git a/Dashboard/lib/screens/Monitoring.Dart b/Dashboard/lib/screens/Monitoring.Dart index 4ec4203..601de7d 100644 --- a/Dashboard/lib/screens/Monitoring.Dart +++ b/Dashboard/lib/screens/Monitoring.Dart @@ -1,475 +1,566 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:Teacher_Dashboard/widgets/custom_app_bar.dart'; import 'dart:convert'; import 'package:Teacher_Dashboard/config/palette.dart'; import 'package:Teacher_Dashboard/config/styles.dart'; import 'dart:async'; import './screens.dart'; import 'package:Teacher_Dashboard/model/Class.dart'; import 'package:Teacher_Dashboard/model/Group.dart'; import 'package:Teacher_Dashboard/model/activities/activity.Dart'; import 'package:firebase_database/firebase_database.dart'; import 'package:Teacher_Dashboard/model/activities/activity.Dart'; import 'package:step_progress_indicator/step_progress_indicator.dart'; import 'package:Teacher_Dashboard/widgets/hexagonPainter.Dart'; import 'package:Teacher_Dashboard/widgets/celluloMap.Dart'; import 'package:syncfusion_flutter_gauges/gauges.dart'; import 'package:provider/provider.dart'; import 'package:material_segmented_control/material_segmented_control.dart'; import 'package:Teacher_Dashboard/widgets/showAlertDialog.Dart'; //import 'package:syncfusion_flutter_gauges/gauges.dart' //import 'package:Teacher_Dashboard/model/core/models/productModel.dart'; //import 'package:Teacher_Dashboard/model/core/viewmodels/CRUDModel.dart'; //import 'package:provider/provider.dart'; class Monitoring extends StatefulWidget { @override MonitoringState createState() => MonitoringState(); } class MonitoringState extends State { bool mistakesSwitch = false; bool rankingSwitch = false; bool robotPatternSwitch = false; int numofgroups = thisClass.groups.length; - int _currentSelection = 0; + int _currentSelection = (thisClass.groups.length > 0) + ? acList.indexOf(thisClass.groups[0].currentActivity) + : 0; int currentstepActivation = 0; String pauseButtonText = 'Pause All'; List mistakesList = [ - 'Mistakes in Finding Slope', - 'Mistakes in Finding Intercept', - 'Mistakes in Finding Intercept', - 'Mistakes in Moving the Joint Robot', + ' Guessing Slope', + ' Guessing Intercept', + 'Robot Speed and Slope', + ' Moving the Joint Robot', ]; Map _children = { 0: Text(acListD[0]), 1: Text(acListD[1]), 2: Text(acListD[2]), 3: Text(acListD[3]), 4: Text(acListD[4]), 5: Text(acListD[5]), 6: Text(acListD[6]), 7: Text(acListD[7]), }; final FirebaseDatabase _database = FirebaseDatabase.instance; @override void initState() { print(thisClass.finishedGroupsNum); super.initState(); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { // final productProvider = Provider.of(context); return Scaffold( backgroundColor: Colors.white, appBar: AppBar( backgroundColor: Palette.primaryColor, elevation: 0.0, title: Text('Monitor your class'), leading: IconButton( icon: const Icon(Icons.search), iconSize: 28.0, onPressed: () {}, ), // actions: [ // IconButton( // icon: const Icon(Icons.notifications_none), // iconSize: 28.0, // onPressed: () {}, // ), // ], ), body: Column(children: [ Padding( padding: EdgeInsets.all(16.0), - child: Text( - "Control the current class activities:", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), - )), + child: Card( + color: Colors.lightBlue, + child: ListTile( + title: Text( + "Control the current class activities:", + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + )))), MaterialSegmentedControl( children: _children, selectionIndex: _currentSelection, borderColor: Colors.grey, selectedColor: Colors.blue, unselectedColor: Colors.white, borderRadius: 32.0, disabledChildren: [ // 3, ], onSegmentChosen: (index) { showAlertDialog(context, 'Pay Attention', 'Are you sure you want to change the activity for all teams?'); setState(() { _currentSelection = index; thisClass.finishedGroupsNum[index] = 0; for (int i = 0; i < thisClass.groups.length; i++) { _database .reference() .child(thisClass.sessionID) .child('groups') .child(thisClass.groupIDs[i]) .child('currentActivity') .set( acList[index], ); } }); }, ), Row( // mainAxisSize: MainAxisSize.min, children: [ + SizedBox( + width: 300, + ), Center( child: MaterialButton( color: Colors.red, elevation: 0, onPressed: () { setState(() { if (pauseButtonText == 'Pause All') pauseButtonText = 'Resume All'; else pauseButtonText = 'Pause All'; }); for (int groupID = 0; groupID < thisClass.groups.length; groupID++) { if (pauseButtonText == 'Pause All') _database .reference() .child(thisClass.sessionID) .child('groups') .child(thisClass.groupIDs[groupID]) .child('isPaused') .set(false); if (pauseButtonText == 'Resume All') _database .reference() .child(thisClass.sessionID) .child('groups') .child(thisClass.groupIDs[groupID]) .child('isPaused') .set(true); } }, child: Container( padding: EdgeInsets.all(15.0), child: Text( pauseButtonText, textAlign: TextAlign.center, style: TextStyle( fontSize: 20.0, color: Colors.white, fontWeight: FontWeight.w500), ), ), ), ), ], ), SizedBox(height: 20), - Text( - "Monitor the class progress :", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), - ), + Padding( + padding: EdgeInsets.all(16.0), + child: Card( + color: Colors.lightBlue, + child: ListTile( + title: Text( + "Monitor the class progress:", + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + )))), Consumer( builder: (context, model, child) => Row(children: [ + Column(children: [ + Container( + width: 200, + height: 100, + padding: const EdgeInsets.all(8), + child: Card( + child: Column(children: [ + CircularStepProgressIndicator( + totalSteps: 4, + width: 50, + height: 50, + padding: 10, + // currentStep: 1, + customColor: (index) => + (thisClass.groups.length > 0) + ? (thisClass.finishedGroupsNum[ + _currentSelection] / + thisClass.groups.length >= + (index + 1) * 0.25 + ? Colors.green + : Colors.grey) + : Colors.grey, + ), + Text( + mistakesList[0], + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 14), + ), + ])), + // color: Colors.teal[100], + ), + Container( + width: 200, + height: 100, + padding: const EdgeInsets.all(8), + child: Card( + child: Column(children: [ + CircularStepProgressIndicator( + totalSteps: 4, + width: 50, + height: 50, + padding: 10, + // currentStep: 1, + customColor: (index) => + (thisClass.groups.length > 0) + ? (thisClass.finishedGroupsNum[ + _currentSelection] / + thisClass.groups.length >= + (index + 1) * 0.25 + ? Colors.green + : Colors.grey) + : Colors.grey, + ), + Text( + mistakesList[2], + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 14), + ), + ])), + // color: Colors.teal[100], + ), + ]), SizedBox( - height: 150, - width: 400, - child: ListView.builder( - itemCount: 3, - itemBuilder: (context, int position) { - return Card( - child: Row(children: [ - SizedBox(width: 17), - Text( - mistakesList[position], - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - ), - SizedBox(width: 25), - StepProgressIndicator( - currentStep: - thisClass.aggregatedMistakes[position], - totalSteps: 100, - padding: 0, - size: 10, - // currentStep: - // thisClass.groups[position].activities[0].progress, - // width: 100, - /* - customColor: (index) => thisClass - .groups[position] - .activities[acList.indexOf(thisClass - .groups[position] - .currentActivity)] - .progress[index] > - -2 - ? (thisClass - .groups[position] - .activities[acList.indexOf( - thisClass.groups[position] - .currentActivity)] - .progress[index] > - -1 - ? (thisClass - .groups[position] - .activities[acList.indexOf(thisClass.groups[position].currentActivity)] - .progress[index] > - 0 - ? Colors.green - : Colors.blue) - : Colors.red) - : Colors.grey, - */ - ), - ]), - ); - }, - )), + width: 20, + ), + Column(children: [ + Container( + width: 200, + height: 100, + padding: const EdgeInsets.all(8), + child: Card( + child: Column(children: [ + CircularStepProgressIndicator( + totalSteps: 4, + width: 50, + height: 50, + padding: 10, + // currentStep: 1, + customColor: (index) => + (thisClass.groups.length > 0) + ? (thisClass.finishedGroupsNum[ + _currentSelection] / + thisClass.groups.length >= + (index + 1) * 0.25 + ? Colors.green + : Colors.grey) + : Colors.grey, + ), + Text( + mistakesList[1], + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 16), + ), + ])), + // color: Colors.teal[100], + ), + Container( + width: 220, + height: 100, + padding: const EdgeInsets.all(8), + child: Card( + child: Column(children: [ + CircularStepProgressIndicator( + totalSteps: 4, + width: 50, + height: 50, + padding: 10, + // currentStep: 1, + customColor: (index) => + (thisClass.groups.length > 0) + ? (thisClass.finishedGroupsNum[ + _currentSelection] / + thisClass.groups.length >= + (index + 1) * 0.25 + ? Colors.green + : Colors.grey) + : Colors.grey, + ), + Text( + mistakesList[3], + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 16), + ), + ])), + // color: Colors.teal[100], + ), + ]), SizedBox( width: 50, ), - Column( + Card( + child: Column( children: [ CircularStepProgressIndicator( totalSteps: 4, - width: 150, - height: 150, + width: 100, + height: 100, padding: 10, // currentStep: 1, customColor: (index) => (thisClass.groups.length > 0) ? (thisClass.finishedGroupsNum[ _currentSelection] / thisClass.groups.length >= (index + 1) * 0.25 ? Colors.green : Colors.grey) : Colors.grey, ), SizedBox( height: 10, ), Text( thisClass.finishedGroupsNum[_currentSelection] .toString() + ' groups have finihsed the activity', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 16), ), ], - ), + )), ])), - SizedBox(height: 50), - Text( - "Monitor All groups progress:", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), - ), + SizedBox(height: 20), + Padding( + padding: EdgeInsets.all(16.0), + child: Card( + color: Colors.lightBlue, + child: ListTile( + title: Text( + "Monitor All groups progress:", + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + )))), SizedBox( - height: 450, + height: 430, child: Consumer( builder: (context, model, child) => Container( child: ListView.builder( itemCount: thisClass.groups.length, itemBuilder: (context, int position) { return Card( child: ListTile( onLongPress: () { Navigator.push( context, MaterialPageRoute( builder: (context) => GroupDashboard(currentgroupID: position))); }, title: Row(children: [ Stack(children: [ CustomPaint( size: Size(100, 100), painter: HexagonPainter( Offset(50, 50), 40.0, (thisClass.groups[position].cellulox.status == 2 && thisClass.groups[position].celluloy .status == 2 && thisClass.groups[position] .tabletStatus == 'YES') ? Colors.green : Colors.green), ), CustomPaint( size: Size(100, 100), painter: HexagonPainter( Offset(50, 50), 30.0, Colors.white), ), Container( width: 100, height: 100, child: Center( child: Text( thisClass.groups[position].id, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 13), ))), ]), SizedBox(width: 17), Container( width: 100, height: 100, child: Stack(children: [ CircularStepProgressIndicator( totalSteps: 3, // currentStep: // thisClass.groups[position].activities[0].progress, width: 100, customColor: (index) => thisClass .groups[position] .activities[acList.indexOf(thisClass .groups[position] .currentActivity)] .progress[index] > -2 ? (thisClass .groups[position] .activities[acList.indexOf( thisClass.groups[position] .currentActivity)] .progress[index] > -1 ? (thisClass .groups[position] .activities[acList.indexOf(thisClass.groups[position].currentActivity)] .progress[index] > 0 ? Colors.green : Colors.blue) : Colors.red) : Colors.grey, ), Center(child: Text('Progress')), ])), SizedBox(width: 25), SizedBox( width: 25, ), Column( children: [ Container( width: 100, height: 100, child: SfRadialGauge(axes: [ RadialAxis( minimum: 0, maximum: 150, ranges: [ GaugeRange( startValue: 0, endValue: 50, color: Colors.orange, startWidth: 10, endWidth: 10), GaugeRange( startValue: 50, endValue: 100, color: Colors.green, startWidth: 10, endWidth: 10), GaugeRange( startValue: 100, endValue: 150, color: Colors.red, startWidth: 10, endWidth: 10) ], pointers: [ NeedlePointer( value: thisClass .groups[position].engagement) ], annotations: [ GaugeAnnotation( angle: 90, positionFactor: 0.5) ]) ])), Text('Total Engagement') ], ), SizedBox( width: 25, ), Column( children: [ Container( width: 100, height: 100, child: SfRadialGauge( axes: [ RadialAxis( showAxisLine: false, // ticksPosition: ElementsPosition.outside, // labelsPosition: ElementsPosition.outside, startAngle: 270, endAngle: 270, useRangeColorForAxis: true, interval: 10, axisLabelStyle: GaugeTextStyle( fontWeight: FontWeight.w500, fontSize: 2), majorTickStyle: MajorTickStyle( length: 0.15, lengthUnit: GaugeSizeUnit.factor, thickness: 1), minorTicksPerInterval: 4, labelOffset: 15, minorTickStyle: MinorTickStyle( length: 0.04, lengthUnit: GaugeSizeUnit.factor, thickness: 1), ranges: [ GaugeRange( startValue: 0, endValue: 50.0 + 10 * position, color: Color(0xFFF8B195), sizeUnit: GaugeSizeUnit.factor, rangeOffset: 0.06, startWidth: 0.05, endWidth: 0.25), GaugeRange( startValue: 51 - position * 3.8, endValue: 100, rangeOffset: 0.06, sizeUnit: GaugeSizeUnit.factor, color: Color(0xFF355C7D), startWidth: 0.05, endWidth: 0.25), ]) ], ), ), - Text('Realtive Engagement '), + Text('Realtive Engagement'), ], ), ]), trailing: Icon(Icons.more_vert), )); }, )), )), ])); } } diff --git a/Dashboard/lib/screens/groupDashboard.Dart b/Dashboard/lib/screens/groupDashboard.Dart index 4ca0d11..abc99dd 100644 --- a/Dashboard/lib/screens/groupDashboard.Dart +++ b/Dashboard/lib/screens/groupDashboard.Dart @@ -1,1141 +1,1248 @@ 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/widgets/celluloMap.Dart'; import 'dart:convert'; import 'package:Teacher_Dashboard/config/palette.dart'; import 'dart:async'; import 'package:Teacher_Dashboard/model/Class.dart'; import 'package:Teacher_Dashboard/model/Group.dart'; import 'package:Teacher_Dashboard/model/activities/activity.Dart'; import 'package:Teacher_Dashboard/config/palette.dart'; import 'package:firebase_database/firebase_database.dart'; import 'package:step_progress_indicator/step_progress_indicator.dart'; import 'package:Teacher_Dashboard/widgets/mapShapeMaker.dart'; import 'package:flutter_svg/flutter_svg.dart'; //import 'package:Teacher_Dashboard/model/core/models/productModel.dart'; //import 'package:Teacher_Dashboard/model/core/viewmodels/CRUDModel.dart'; import 'package:provider/provider.dart'; class GroupDashboard extends StatefulWidget { final int currentgroupID; GroupDashboard({Key key, this.currentgroupID}) : super(key: key); @override GroupDashboardState createState() => GroupDashboardState(); } class GroupDashboardState extends State { final TextStyle whiteText = TextStyle(color: Colors.white, fontSize: 20); Timer timer; final FirebaseDatabase _database = FirebaseDatabase.instance; var progress; int groupID = 0; int studentListIndex = 0; int activityID = 0; int activityListIndex = 0; int turnID = 0; List gColor; + bool celluloxSwitch = true; + bool celluloySwitch = true; double mapSizeWidth = 860; double mapSizeHeight = 860; - double screenSizeWidth = 500; - double screenSizeHeight = 500; + double screenSizeWidth = 450; + double screenSizeHeight = 450; static List pointPosition = [ Offset(80, 80), Offset(760, 80), Offset(80, 760), Offset(760, 760) ]; var mapShape = [ [ { 'numCircles': 4, 'originCircles': [ Offset(390, 300), Offset(190, 170), Offset(60, 360), Offset(560, 690) ], 'radiuosCircles': [60.0, 70.0, 60.0, 60.0], 'numRectangles': 2, 'originRectangles': [Offset(300, 30), Offset(300, 560)], 'widthRectangles': [150.0, 100.0], 'heightRectangles': [50.0, 250.0], 'numPolygons': 5, 'sidesofPolygon': [3, 3, 5, 4, 4], 'radiusPolygon': [60.0, 70.0, 70.0, 60.0, 80.0], 'centerPolygon': [ Offset(60, 230), Offset(600, 90), Offset(600, 250), Offset(600, 500), Offset(780, 400) ], 'startCenter': pointPosition[2], 'endCenter': pointPosition[1] }, { 'numCircles': 2, 'originCircles': [ Offset(380, 320), Offset(160, 290), ], 'radiuosCircles': [60.0, 70.0], 'numRectangles': 3, 'originRectangles': [ Offset(100, 500), Offset(700, 560), Offset(500, 360) ], 'widthRectangles': [150.0, 100.0, 80.0], 'heightRectangles': [50.0, 250.0, 230.0], 'numPolygons': 4, 'sidesofPolygon': [3, 5, 4, 4], 'radiusPolygon': [70.0, 80.0, 70.0, 70.0], 'centerPolygon': [ Offset(300, 90), Offset(600, 60), Offset(500, 650), Offset(780, 300) ], 'startCenter': pointPosition[0], 'endCenter': pointPosition[3] }, { 'numCircles': 3, 'originCircles': [ Offset(260, 170), Offset(490, 560), Offset(690, 590), ], 'radiuosCircles': [80.0, 70.0, 70.0], 'numRectangles': 2, 'originRectangles': [Offset(500, 30), Offset(350, 560)], 'widthRectangles': [150.0, 100.0], 'heightRectangles': [80.0, 300.0], 'numPolygons': 3, 'sidesofPolygon': [3, 4, 4], 'radiusPolygon': [70.0, 90.0, 80.0], 'centerPolygon': [ Offset(40, 630), Offset(70, 390), Offset(620, 220), ], 'startCenter': pointPosition[2], 'endCenter': pointPosition[1] }, ], [ { 'numCircles': 0, 'originCircles': [ Offset(390, 300), Offset(160, 70), Offset(60, 360), Offset(560, 690) ], 'radiuosCircles': [60.0, 50.0, 50.0, 40.0], 'numRectangles': 5, 'originRectangles': [ Offset(300, 30), Offset(200, 560), Offset(400, 760), Offset(780, 460), Offset(650, 500) ], 'widthRectangles': [150.0, 100.0, 50.0, 100.0, 100.0], 'heightRectangles': [50.0, 250.0, 300.0, 50.0, 100.0], 'numPolygons': 4, 'sidesofPolygon': [4, 4, 4, 4], 'radiusPolygon': [70.0, 70.0, 50.0, 60.0, 50.0], 'centerPolygon': [ Offset(60, 280), Offset(500, 140), Offset(600, 200), Offset(500, 500), Offset(680, 400) ], 'startCenter': pointPosition[2], 'endCenter': pointPosition[1] }, { 'numCircles': 0, 'originCircles': [ Offset(390, 300), Offset(160, 70), Offset(60, 360), Offset(560, 690) ], 'radiuosCircles': [60.0, 50.0, 50.0, 40.0], 'numRectangles': 4, 'originRectangles': [ Offset(300, 30), Offset(300, 560), Offset(500, 560), Offset(750, 360) ], 'widthRectangles': [ 150.0, 100.0, 50.0, 150.0, ], 'heightRectangles': [50.0, 250.0, 250.0, 300.0], 'numPolygons': 4, 'sidesofPolygon': [4, 4, 4, 4], 'radiusPolygon': [80.0, 60.0, 50.0, 60.0], 'centerPolygon': [ Offset(100, 330), Offset(600, 90), Offset(500, 200), Offset(400, 350), ], 'startCenter': pointPosition[0], 'endCenter': pointPosition[3] }, { 'numCircles': 0, 'originCircles': [ Offset(390, 300), Offset(160, 70), Offset(60, 360), Offset(560, 690) ], 'radiuosCircles': [60.0, 50.0, 50.0, 40.0], 'numRectangles': 3, 'originRectangles': [ Offset(350, 70), Offset(300, 560), Offset(700, 520) ], 'widthRectangles': [350.0, 300.0, 100.0], 'heightRectangles': [50.0, 250.0, 100.0], 'numPolygons': 3, 'sidesofPolygon': [4, 4, 4], 'radiusPolygon': [100.0, 60.0, 70.0], 'centerPolygon': [ Offset(80, 230), Offset(650, 190), Offset(400, 250), ], 'startCenter': pointPosition[2], 'endCenter': pointPosition[1] }, ], [ { 'numCircles': 0, 'originCircles': [Offset(0, 0)], 'radiuosCircles': [0.0], - 'numRectangles': 7, + 'numRectangles': 4, 'originRectangles': [ Offset(300, 30), Offset(100, 560), Offset(600, 630), Offset(780, 360), Offset(300, 300), Offset(500, 260), Offset(300, 560) ], 'widthRectangles': [150.0, 100.0, 50.0, 80.0, 150.0, 100.0, 100.0], 'heightRectangles': [70.0, 100.0, 200.0, 300.0, 40.0, 300.0, 200.0], 'numPolygons': 0, 'sidesofPolygon': [0], 'radiusPolygon': [0.0], 'centerPolygon': [Offset(0, 0)], 'startCenter': pointPosition[2], 'endCenter': pointPosition[1] }, { 'numCircles': 0, 'originCircles': [Offset(0, 0)], 'radiuosCircles': [0.0], - 'numRectangles': 6, + 'numRectangles': 4, 'originRectangles': [ Offset(690, 430), Offset(500, 560), Offset(430, 130), Offset(300, 760), Offset(100, 230), Offset(100, 460) ], 'widthRectangles': [150.0, 100.0, 200.0, 100.0, 210.0, 210.0], 'heightRectangles': [150.0, 250.0, 50.0, 250.0, 50.0, 300.0], 'numPolygons': 0, 'sidesofPolygon': [3, 3, 5, 4, 4], 'radiusPolygon': [30.0, 40.0, 40.0, 40.0, 50.0], 'centerPolygon': [ Offset(40, 130), Offset(700, 90), Offset(600, 200), Offset(600, 500), Offset(780, 400) ], 'startCenter': pointPosition[0], 'endCenter': pointPosition[3] }, { 'numCircles': 0, 'originCircles': [Offset(0, 0)], 'radiuosCircles': [0.0], - 'numRectangles': 7, + 'numRectangles': 4, 'originRectangles': [ Offset(300, 130), Offset(500, 460), Offset(750, 530), Offset(600, 130), Offset(600, 730), Offset(100, 530), Offset(350, 460) ], 'widthRectangles': [160.0, 90.0, 150.0, 100.0, 150.0, 300.0, 50.0], 'heightRectangles': [130.0, 270.0, 150.0, 250.0, 100.0, 70.0, 250.0], 'numPolygons': 0, 'sidesofPolygon': [0], 'radiusPolygon': [0.0], 'centerPolygon': [Offset(0, 0)], 'startCenter': pointPosition[2], 'endCenter': pointPosition[1] }, ] ]; List gridAcsPath = [ "assets/images/GridOnlyPositive.svg", "assets/images/Grid.svg", "assets/images/Grid_Ac5_Screen.svg", "assets/images/Grid_Ac6_Screen.svg", "assets/images/Grid_Ac5_Screen.svg", "assets/images/Grid_Ac6_Screen.svg", "assets/images/Grid_Ac7_Screen.svg", "assets/images/Grid_Ac8_Screen.svg", ]; var _currentSliderValue = RangeValues(0.0, 1); var _currentCelluloSliderValue = 0.5; String pauseButtonText = 'Pause'; @override void initState() { super.initState(); if (widget.currentgroupID != null) groupID = widget.currentgroupID; } //@override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( backgroundColor: Palette.primaryColor, elevation: 0.0, title: Text('Intervene the groups'), // leading: IconButton( // icon: const Icon(Icons.menu), // iconSize: 28.0, // onPressed: () {}, // ), // actions: [ // IconButton( // icon: const Icon(Icons.notifications_none), // iconSize: 28.0, // onPressed: () {}, // ), // ], ), body: SingleChildScrollView( // padding: const EdgeInsets.all(10.0), child: Row(children: [ Consumer( builder: (context, model, child) => Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: 200, decoration: BoxDecoration( color: Palette.primaryColor, border: Border.all(color: Colors.purple), // borderRadius: new BorderRadius.circular(25.0), ), child: Text( 'Groups', style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 18), )), Container( height: 480, width: 200, // margin: const EdgeInsets.all(15.0), // padding: const EdgeInsets.all(10.0), decoration: BoxDecoration( color: Palette.primaryColor, border: Border.all(color: Colors.purple), // borderRadius: new BorderRadius.circular(25.0), ), child: ListView.builder( itemCount: thisClass.groups.length, itemBuilder: (context, int position) { return ListTile( leading: Icon( Icons.group_work, color: Colors.white, ), onTap: () { setState(() { studentListIndex = position; groupID = position; }); }, title: Text( thisClass.groups[position].id, style: TextStyle( color: (studentListIndex == position) ? Colors.blue : Colors.white, fontWeight: FontWeight.bold, fontSize: 18), ), ); })), Container( width: 200, decoration: BoxDecoration( color: Palette.primaryColor, border: Border.all(color: Colors.purple), // borderRadius: new BorderRadius.circular(25.0), ), child: Text( 'Activities', style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 18), )), Container( height: 340, width: 200, // margin: const EdgeInsets.all(15.0), // padding: const EdgeInsets.all(10.0), decoration: BoxDecoration( color: Palette.primaryColor, border: Border.all(color: Colors.purple), // borderRadius: new BorderRadius.circular(25.0), ), child: ListView.builder( itemCount: acList.length, itemBuilder: (context, int position) { return ListTile( leading: Icon( Icons.description, color: Colors.white, ), onTap: () { setState(() { activityListIndex = position; // print(acList.length); activityID = position; }); }, title: Text( acListD[position], style: TextStyle( color: (activityListIndex == position) ? Colors.blue : Colors.white, fontWeight: FontWeight.bold, fontSize: 18), ), ); })) ])), SizedBox(width: 20), Consumer( builder: (context, model, child) => Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 1, ), Row( // crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack(children: [ CircularStepProgressIndicator( totalSteps: 3, // currentStep: // thisClass.groups[position].activities[0].progress, width: 100, customColor: (index) => (thisClass.groups.length > 0) ? (thisClass .groups[groupID] .activities[activityID] .progress[index] > -2 ? (thisClass .groups[groupID] .activities[activityID] .progress[index] > -1 ? (thisClass .groups[groupID] .activities[activityID] .progress[index] > 0 ? Colors.green : Colors.blue) : Colors.red) : Colors.grey) : Colors.grey, ), Positioned( bottom: 45, right: 18, child: Text( '', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 15), )), ]), SizedBox(width: 10), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Icon(Icons.group), Text( (thisClass.groups.length > 0) ? (' ' + thisClass.groups[groupID].id) : '', style: TextStyle( fontSize: 30.0, color: Colors.black, fontWeight: FontWeight.w500), ), ], ), SizedBox(height: 25), Row( // crossAxisAlignment: CrossAxisAlignment.start, children: [ Row(children: [ Icon(Icons.person), Text( (thisClass.groups.length > 0) ? thisClass .groups[groupID].member1name : '', style: TextStyle( fontSize: 20.0, color: Colors.black, fontWeight: FontWeight.w500), ), ]), SizedBox(width: 20), Row(children: [ Icon(Icons.person), Text( (thisClass.groups.length > 0) ? thisClass .groups[groupID].member2name : '', style: TextStyle( fontSize: 20.0, color: Colors.black, fontWeight: FontWeight.w500), ), ]), SizedBox(width: 20), Row(children: [ Icon(Icons.person), Text( (thisClass.groups.length > 0) ? thisClass .groups[groupID].member3name : '', style: TextStyle( fontSize: 20.0, color: Colors.black, fontWeight: FontWeight.w500), ), ]) ]), ]), ]), SizedBox( height: 20, ), Container( width: 500, child: StepProgressIndicator( totalSteps: 50, // currentStep: thisClass.groups[position].inactivity.length, size: 10, padding: 0, customColor: (index) => Palette.primaryColor)), SizedBox( height: 20, ), Row( // mainAxisSize: MainAxisSize.min, children: [ infoTile( (thisClass.groups.length > 0) ? thisClass.groups[groupID].activities[activityID] .turns[turnID].numAttempts .toString() : '0', 'Attempts', Colors.blue), infoTileTime( 'Performing in', (thisClass.groups.length > 0) ? thisClass.groups[groupID].activities[activityID] .turns[turnID].elapsedTime : 0, Colors.blue), Text((thisClass.groups.length > 0) ? '( below Average)' : ''), ]), SizedBox( height: 20, ), //SizedBox(width: 10), Text( "The activity map with students robot path:", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), SizedBox(height: 20), Row( // mainAxisSize: MainAxisSize.min, children: [ Column( // mainAxisSize: MainAxisSize.min, children: [ Stack( children: [ Container( width: screenSizeWidth, height: screenSizeHeight, child: (activityID > 2) ? celluloMap( gridAcsPath[activityID], turnID + 1, activityID, true, (thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[activityID] .turns[turnID] .cellulov .x .sublist( (_currentSliderValue .start * thisClass .groups[ groupID] .activities[ activityID] .turns[turnID] .cellulox .x .length) .toInt(), (_currentSliderValue.end * thisClass .groups[ groupID] .activities[ activityID] .turns[turnID] .cellulov .x .length) .toInt()) : [0, 0], (thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[activityID] .turns[turnID] .cellulov .y .sublist( (_currentSliderValue .start * thisClass .groups[ groupID] .activities[ activityID] .turns[turnID] .cellulox .x .length) .toInt(), (_currentSliderValue.end * thisClass .groups[ groupID] .activities[ activityID] .turns[turnID] .cellulox .x .length) .toInt()) : [0, 0], screenSizeWidth, screenSizeHeight, ) : Container( width: screenSizeWidth, height: screenSizeHeight, child: Stack(children: [ CustomPaint( //size: Size(200, 200), painter: MapShapeMaker( screenSizeWidth / mapSizeWidth, screenSizeHeight / mapSizeHeight, mapShape[activityID][turnID] ['numRectangles'], mapShape[activityID][turnID] ['originRectangles'], mapShape[activityID][turnID] ['widthRectangles'], mapShape[activityID][turnID] ['heightRectangles'], mapShape[activityID][turnID] ['numCircles'], mapShape[activityID][turnID] ['originCircles'], mapShape[activityID][turnID] ['radiuosCircles'], mapShape[activityID][turnID] ['numPolygons'], mapShape[activityID][turnID] ['sidesofPolygon'], mapShape[activityID][turnID] ['radiusPolygon'], mapShape[activityID][turnID] ['centerPolygon'], mapShape[activityID][turnID] ['startCenter'], mapShape[activityID][turnID] ['endCenter'], (thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[ activityID] .turns[turnID] .mapHit : { 'Circles': [ 0, 0, 0, 0, 0, 0, 0 ], 'Rectangles': [ + 0, + 0, 0, 0, 0, 0, 0, 0 ], 'Polygons': [ 0, 0, 0, 0, 0, 0, 0 ], })), celluloMap2( turnID + 1, activityID, true, (thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[activityID] .turns[turnID] .cellulov .x .sublist( (_currentSliderValue.start * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length) .toInt(), (_currentSliderValue.end * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length) .toInt()) : [0, 0], (thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[activityID] .turns[turnID] .cellulov .y .sublist( (_currentSliderValue.start * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length) .toInt(), (_currentSliderValue.end * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length) .toInt()) : [0, 0], (thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[activityID] .turns[turnID] .cellulox .x .sublist( (_currentSliderValue.start * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length) .toInt(), (_currentSliderValue.end * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length) .toInt()) : [0, 0], (thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[activityID] .turns[turnID] .cellulox .y .sublist((_currentSliderValue.start * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length).toInt(), (_currentSliderValue.end * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length).toInt()) : [0, 0], (thisClass.groups.length > 0) ? thisClass.groups[groupID].activities[activityID].turns[turnID].celluloy.x.sublist((_currentSliderValue.start * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length).toInt(), (_currentSliderValue.end * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length).toInt()) : [0, 0], (thisClass.groups.length > 0) ? thisClass.groups[groupID].activities[activityID].turns[turnID].celluloy.y.sublist((_currentSliderValue.start * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length).toInt(), (_currentSliderValue.end * thisClass.groups[groupID].activities[activityID].turns[turnID].cellulox.x.length).toInt()) : [0, 0], screenSizeWidth, screenSizeHeight), ])), ), Positioned( // x: Alignment( // 2 * ((celluloyPosition[0] + 40) / mapSizeWidth) - 1, // 2 * ((celluloyPosition[1] + 40) / mapSizeHeight) - 1), left: ((thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[activityID] .turns[turnID] .cellulov .x[ (_currentCelluloSliderValue * thisClass .groups[groupID] .activities[ activityID] .turns[turnID] .cellulov .x .length) .toInt()] : 100.0) * screenSizeWidth / mapSizeWidth - 30, top: ((thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[activityID] .turns[turnID] .cellulov .y[ (_currentCelluloSliderValue * thisClass .groups[groupID] .activities[ activityID] .turns[turnID] .cellulov .y .length) .toInt()] : 200.0) * screenSizeWidth / mapSizeWidth - 30, width: 60, height: 60, child: Card( child: SvgPicture.asset( "assets/images/celluloPurple.svg", height: 60, width: 60), ), ), ], ), + Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Robot Red Path', + style: TextStyle( + fontSize: 15.0, + // color: Colors.white, + fontWeight: FontWeight.bold), + ), + SizedBox(width: 5), + Checkbox( + //title: const Text('Animate Slowly'), + value: celluloxSwitch, + onChanged: (bool value) { + setState(() { + celluloxSwitch = value; + }); + }, + // secondary: const Icon(Icons.hourglass_empty), + ), + Text( + 'Robot Blue Path', + style: TextStyle( + fontSize: 15.0, + // color: Colors.white, + fontWeight: FontWeight.bold), + ), + SizedBox(width: 5), + Checkbox( + //title: const Text('Animate Slowly'), + value: celluloxSwitch, + onChanged: (bool value) { + setState(() { + celluloxSwitch = value; + }); + }, + // secondary: const Icon(Icons.hourglass_empty), + ), + + /* + Text( + 'Show Students robot pattern', + style: TextStyle( + fontSize: 15.0, + // color: Colors.white, + fontWeight: FontWeight.bold), + ), + SizedBox(width: 5), + Checkbox( + value: robotPatternSwitch, + onChanged: (bool value) { + setState(() { + robotPatternSwitch = value; + }); + }, + // secondary: const Icon(Icons.hourglass_empty), + ), + */ + ]), + Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Robot Purple Path', + style: TextStyle( + fontSize: 15.0, + // color: Colors.white, + fontWeight: FontWeight.bold), + ), + SizedBox(width: 5), + Checkbox( + //title: const Text('Animate Slowly'), + value: celluloxSwitch, + onChanged: (bool value) { + setState(() { + celluloxSwitch = value; + }); + }, + // secondary: const Icon(Icons.hourglass_empty), + ), + + /* + Text( + 'Show Students robot pattern', + style: TextStyle( + fontSize: 15.0, + // color: Colors.white, + fontWeight: FontWeight.bold), + ), + SizedBox(width: 5), + Checkbox( + value: robotPatternSwitch, + onChanged: (bool value) { + setState(() { + robotPatternSwitch = value; + }); + }, + // secondary: const Icon(Icons.hourglass_empty), + ), + */ + ]), SizedBox(height: 20), Text( "Change the range values of Robot paths: ", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 15), ), RangeSlider( activeColor: Colors.purple, values: _currentSliderValue, min: 0.0, max: 1.0, // divisions: 5, // label: _currentSliderValue.round().toString(), onChanged: (RangeValues value) { setState(() { _currentSliderValue = value; }); }), Text( "Move the cellulo along its path: ", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 15), ), Slider( activeColor: Colors.purple, value: _currentCelluloSliderValue, min: 0, max: 1, // divisions: 5, // label: _currentSliderValue.round().toString(), onChanged: (double value) { setState(() { _currentCelluloSliderValue = value; }); }), ]), + /* Column( // mainAxisSize: MainAxisSize.min, children: [ infoTile( (thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[activityID] .turns[turnID] .mistakes['slope'] .toString() : '0', 'Mistakes in finding slope', Colors.blue), (activityID == 0) ? infoTile( (thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[activityID] .turns[turnID] .mistakes['initialPoint'] .toString() : '0', 'Mistakes in finding initial Point', Colors.blue) : infoTile( (thisClass.groups.length > 0) ? thisClass .groups[groupID] .activities[activityID] .turns[turnID] .mistakes['intercept'] .toString() : '0', 'Mistakes in finding intercept', Colors.blue), ]) */ ]), SizedBox(height: 30), Row( // mainAxisSize: MainAxisSize.min, children: [ SizedBox(width: 100), FloatingActionButton( heroTag: "prevButton", tooltip: 'Previous Turn', onPressed: () { if (turnID > 0) { setState(() { turnID = turnID - 1; }); } }, child: Icon(Icons.skip_previous), backgroundColor: Palette.primaryColor, ), SizedBox(width: 10), Text( ((turnID + 1 > 1) ? ((turnID + 1 > 2) ? 'Third ' : 'Second ') : 'First ') + "Turn ", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), SizedBox(width: 10), FloatingActionButton( heroTag: "nextButton", tooltip: 'Next Turn', onPressed: () { // print('turnID' + turnID.toString()); if (turnID < 2) { setState(() { turnID = turnID + 1; }); } }, child: Icon(Icons.skip_next), backgroundColor: Palette.primaryColor, ), ]), SizedBox(height: 40), /* Row( // mainAxisSize: MainAxisSize.min, children: [ SizedBox(width: 325), Container( width: 200, child: MaterialButton( color: Colors.red, elevation: 0, onPressed: () { if (pauseButtonText == 'Pause') { pauseButtonText = 'Resume'; } else { pauseButtonText = 'Pause'; // dbRef.child("1").child("isPaused").set(true); } if (pauseButtonText == 'Pause') _database .reference() .child(thisClass.sessionID) .child('groups') .child(thisClass.groupIDs[groupID]) .child('isPaused') .set(false); if (pauseButtonText == 'Resume') _database .reference() .child(thisClass.sessionID) .child('groups') .child(thisClass.groupIDs[groupID]) .child('isPaused') .set(true); }, child: Container( padding: EdgeInsets.all(15.0), child: Text( pauseButtonText, textAlign: TextAlign.center, style: TextStyle( fontSize: 20.0, color: Colors.white, fontWeight: FontWeight.w500), ), ), ), ), SizedBox(width: 20), ], ) */ ], ), ) ]), ), ); } Container infoTile(String title, String count, MaterialColor color) { return Container( width: 120, // margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(10.0), decoration: BoxDecoration( color: color, borderRadius: BorderRadius.circular(10.0), ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( title, style: const TextStyle( color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.bold, ), ), Text( count, style: const TextStyle( color: Colors.white, fontSize: 15.0, fontWeight: FontWeight.w600, ), ), ], ), ); } Container infoTileTime(String title, int count, MaterialColor color) { return Container( width: 220, // margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(10.0), decoration: BoxDecoration( color: color, // borderRadius: BorderRadius.circular(10.0), ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( title, style: const TextStyle( color: Colors.white, fontSize: 15.0, fontWeight: FontWeight.bold, ), ), Text( ((count > 60000) ? ((count / 60000).round().toString() + ' miutes') : '') + ' ' + ((count % 60000) / 1000).round().toString() + ' Seconds', style: const TextStyle( color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.w600, ), ), ], ), ); } } diff --git a/Dashboard/lib/screens/home_screen.dart b/Dashboard/lib/screens/home_screen.dart index d636eca..c1e8b62 100644 --- a/Dashboard/lib/screens/home_screen.dart +++ b/Dashboard/lib/screens/home_screen.dart @@ -1,430 +1,443 @@ import 'package:Teacher_Dashboard/model/Class.dart'; import 'package:Teacher_Dashboard/screens/screens.dart'; import 'package:flutter/material.dart'; import 'package:Teacher_Dashboard/model/activities/activity.Dart'; import 'package:Teacher_Dashboard/model/core/services/api.dart'; import 'package:Teacher_Dashboard/config/palette.dart'; import 'package:Teacher_Dashboard/config/styles.dart'; import 'package:firebase_database/firebase_database.dart'; import 'package:Teacher_Dashboard/widgets/widgets.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'dart:convert'; import 'package:provider/provider.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:Teacher_Dashboard/widgets/showAlertDialog.Dart'; class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() => _HomeScreenState(); } class _HomeScreenState extends State with SingleTickerProviderStateMixin { var isallgroupsconnected = false; - bool joinEnabled = false; + bool joinEnabled = true; Animation animation; AnimationController _controller; String numConnectedGroups = '0'; + bool joinenables = true; String startAcdropdownValue; final FirebaseDatabase _database = FirebaseDatabase.instance; // List products; @override void initState() { super.initState(); } Widget _title() { return RichText( textAlign: TextAlign.center, text: TextSpan( text: 'C', style: GoogleFonts.portLligatSans( textStyle: Theme.of(context).textTheme.display1, fontSize: 30, fontWeight: FontWeight.w700, color: Colors.white, ), children: [ TextSpan( text: 'ell', style: TextStyle(color: Colors.black, fontSize: 30), ), TextSpan( text: 'ulo', style: TextStyle(color: Colors.white, fontSize: 30), ), ]), ); } @override Widget build(BuildContext context) { // final productProvider = Provider.of(context); final screenHeight = MediaQuery.of(context).size.height; TextEditingController controllerSessionID = TextEditingController(); return Scaffold( appBar: AppBar( backgroundColor: Palette.primaryColor, elevation: 0.0, title: Text('Setup your class'), leading: IconButton( icon: const Icon(Icons.settings), iconSize: 28.0, onPressed: () {}, ), // actions: [ // IconButton( // icon: const Icon(Icons.notifications_none), // iconSize: 28.0, // onPressed: () {}, // ), // ], ), body: CustomScrollView( physics: ClampingScrollPhysics(), slivers: [ _overalClass(screenHeight), SliverToBoxAdapter( child: Column(children: [ SizedBox( height: 50, ), Padding( padding: EdgeInsets.symmetric(horizontal: 32), child: Material( elevation: 2.0, borderRadius: BorderRadius.all(Radius.circular(30)), child: TextField( controller: controllerSessionID, onChanged: (String value) {}, cursorColor: Colors.deepOrange, decoration: InputDecoration( hintText: "Session ID", prefixIcon: Material( elevation: 0, borderRadius: BorderRadius.all(Radius.circular(30)), child: Icon( Icons.lock, color: Palette.primaryColor, ), ), border: InputBorder.none, contentPadding: EdgeInsets.symmetric(horizontal: 25, vertical: 13)), ), ), ), SizedBox( height: 25, ), Padding( padding: EdgeInsets.symmetric(horizontal: 32), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(100)), - color: Palette.primaryColor), + color: + joinEnabled ? Palette.primaryColor : Colors.grey), child: FlatButton( child: Text( "Join", style: TextStyle( color: Colors.white, fontWeight: FontWeight.w700, fontSize: 18), ), - onPressed: () { - if (thisClass.groups.length > 0) { - thisClass.groups.clear(); - thisClass.groupIDs = new List(); - thisClass.desetupDatabse(); - } - if (controllerSessionID.text != '') { - thisClass.sessionID = controllerSessionID.text; + onPressed: () => { + (joinEnabled) + ? { + if (thisClass.groups.length > 0) + { + thisClass.groups.clear(), + thisClass.groupIDs = new List(), + thisClass.desetupDatabse(), + }, + if (controllerSessionID.text != '') + { + thisClass.sessionID = + controllerSessionID.text, - // locator.registerLazySingleton(() => Api(Firestore.instance.collection('sessions').doc(controllerSessionID.text) thisClass.sessionID)); + // locator.registerLazySingleton(() => Api(Firestore.instance.collection('sessions').doc(controllerSessionID.text) thisClass.sessionID)); - thisClass.setupDatabse(); - showAlertDialog( - context, - '', - 'Your class has been set up to session' + - thisClass.sessionID); - } else { - showAlertDialog( - context, '', 'Please specify a session ID'); - } + thisClass.setupDatabse(), + showAlertDialog( + context, + '', + 'Your class has been set up to session' + + thisClass.sessionID), + } + else + { + showAlertDialog(context, '', + 'Please specify a session ID'), + }, + joinEnabled = false, + } + : null, }, ), )), SizedBox( height: 50, ), Padding( padding: EdgeInsets.symmetric(horizontal: 32), child: Container( width: 500, child: DropdownButton( hint: Text('Students start the session with activity: '), value: startAcdropdownValue, icon: Icon(Icons.arrow_downward), iconSize: 24, elevation: 16, style: TextStyle(color: Colors.deepPurple), onChanged: (String newValue) { setState(() { startAcdropdownValue = newValue; }); }, items: acListD .map>((String value) { return DropdownMenuItem( value: value, child: Text(value), ); }).toList(), ))), SizedBox( height: 25, ), Padding( padding: EdgeInsets.symmetric(horizontal: 32), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(100)), color: Palette.primaryColor), child: FlatButton( child: Text( "Start the session", style: TextStyle( color: Colors.white, fontWeight: FontWeight.w700, fontSize: 18), ), onPressed: () { - if (startAcdropdownValue != '') { + print(startAcdropdownValue); + if (startAcdropdownValue != '' && + startAcdropdownValue != null) { for (int i = 0; i < thisClass.groups.length; i++) { _database .reference() .child(thisClass.sessionID) .child('groups') .child(thisClass.groupIDs[i]) .child('currentActivity') .set( acList[acListD.indexOf(startAcdropdownValue)], ); } Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => BottomNavScreen())); } else { - showAlertDialog( - context, '', 'Please specify an activity'); + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => BottomNavScreen())); } }, ), )), ]), ), - // _controlClass(screenHeight), -// _recentAc(screenHeight), - // _alarms(screenHeight), ], ), ); } SliverToBoxAdapter _controlClass(double screenHeight) { Color color1 = Color(0xffFC5CF0); Color color2 = Color(0xffFE8852); return SliverToBoxAdapter( child: Container( child: Stack( children: [ Container( padding: const EdgeInsets.symmetric(vertical: 5.0, horizontal: 16.0), margin: const EdgeInsets.only( top: 30, left: 20.0, right: 20.0, bottom: 20.0), decoration: BoxDecoration( gradient: LinearGradient( colors: [color1, color2], ), borderRadius: BorderRadius.circular(30.0)), child: Row( children: [ Spacer(), ], ), ), Center( child: IconButton( color: Colors.white, icon: Icon(FontAwesomeIcons.pause), onPressed: () {}, tooltip: "Pause the student", )), ], ), )); } SliverToBoxAdapter _overalClass(double screenHeight) { return SliverToBoxAdapter( child: Container( padding: const EdgeInsets.all(20.0), decoration: BoxDecoration( gradient: LinearGradient( colors: [Color(0xFFAD9FE4), Palette.primaryColor], ), borderRadius: BorderRadius.only( bottomLeft: Radius.circular(40.0), bottomRight: Radius.circular(40.0), ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Center(child: Image.asset('assets/images/cellulo.png')), const SizedBox(height: 20.0), Row(mainAxisAlignment: MainAxisAlignment.center, children: [ Column( children: [ Consumer( builder: (context, model, child) => Text( thisClass.groups.length.toString(), style: const TextStyle( color: Colors.white, fontSize: 60.0, fontWeight: FontWeight.w500, ), textAlign: TextAlign.center, )), SizedBox(height: screenHeight * 0.015), Row( children: [ Icon(Icons.group, color: Colors.white), Text( " Connected Groups", style: const TextStyle( color: Colors.white, fontSize: 16.0, fontWeight: FontWeight.w500, ), textAlign: TextAlign.center, ) ], ) ], ), ]), ], ), ), ); } SliverToBoxAdapter _recentAc(double screenHeight) { return SliverToBoxAdapter( child: Container( margin: const EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0, ), padding: const EdgeInsets.all(10.0), height: screenHeight * 0.15, decoration: BoxDecoration( gradient: LinearGradient( colors: [Color(0xFFAD9FE4), Palette.primaryColor], ), borderRadius: BorderRadius.circular(20.0), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Image.asset('assets/images/cellulo.png'), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Do you want to see how many robots are working?', style: const TextStyle( color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.bold, ), ), SizedBox(height: screenHeight * 0.03), Text( 'Click on the button below', style: const TextStyle( color: Colors.white, fontSize: 16.0, ), maxLines: 2, ), ], ) ], ), ), ); } SliverToBoxAdapter _alarms(double screenHeight) { return SliverToBoxAdapter( child: Container( margin: const EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0, ), padding: const EdgeInsets.all(10.0), height: screenHeight * 0.15, decoration: BoxDecoration( gradient: LinearGradient( colors: [Color(0xFFAD9FE4), Palette.primaryColor], ), borderRadius: BorderRadius.circular(20.0), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Icon( Icons.alarm, color: Colors.red, size: 94.0, semanticLabel: 'Text to announce in accessibility modes', ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'One group has problem with robot', style: const TextStyle( color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.bold, ), ), SizedBox(height: screenHeight * 0.03), Text( 'One group is not progressing..For details press here', style: const TextStyle( color: Colors.white, fontSize: 16.0, ), maxLines: 2, ), ], ) ], ), ), ); } } diff --git a/Dashboard/lib/widgets/arrow.dart b/Dashboard/lib/widgets/arrow.dart index 28a2e90..52578af 100644 --- a/Dashboard/lib/widgets/arrow.dart +++ b/Dashboard/lib/widgets/arrow.dart @@ -1,91 +1,91 @@ import 'package:flutter/material.dart'; import 'package:arrow_path/arrow_path.dart'; -import 'package:student/model/Cellulo.dart'; +//import 'package:student/model/Cellulo.dart'; import "dart:math" as math; class Arrow extends CustomPainter { // <-- CustomPainter class var celluloxPosition; var celluloyPosition; var coeffScreenMapWidth; var coeffScreenMapHeight; double directionx; double directiony; Offset celluloyM; Offset celluloxM; Arrow(this.celluloxPosition, this.celluloyPosition, this.coeffScreenMapWidth, this.coeffScreenMapHeight, this.directionx, this.directiony) { celluloxM = Offset(celluloxPosition[0] * coeffScreenMapWidth, celluloxPosition[1] * coeffScreenMapHeight); celluloyM = Offset(celluloyPosition[0] * coeffScreenMapWidth, celluloyPosition[1] * coeffScreenMapHeight); /* directionx = 0; directiony = 0; if (math.sqrt(math.pow(directionx, 2) + math.pow(directiony, 2)) < 80) directionx = 0; else if (directionx > 40) directionx = 1; else if (directionx < -40) { directionx = -1; } else { directionx = 0; } if (math.sqrt(math.pow(directionx, 2) + math.pow(directiony, 2)) < 80) directiony = 0; else if (directiony > 40) directiony = 1; else if (directiony < -40) { directiony = -1; } else { directiony = 0; } */ if (directionx > 40) directionx = 40; if (directionx < -40) directionx = -40; if (directiony > 40) directiony = 40; if (directiony < -40) directiony = -40; } @override void paint(Canvas canvas, Size size) { // print('ddddd' + directiony.toString()); Path path; Path path2; Paint paintblue = Paint() ..color = Colors.blue ..style = PaintingStyle.stroke ..strokeCap = StrokeCap.round ..strokeJoin = StrokeJoin.round ..strokeWidth = 3.0; Paint paintRed = Paint() ..color = Colors.red ..style = PaintingStyle.stroke ..strokeCap = StrokeCap.round ..strokeJoin = StrokeJoin.round ..strokeWidth = 3.0; if (directionx.abs() > 20) { path = Path(); path.moveTo(celluloxM.dx - 10, celluloxM.dy - 10); path.relativeCubicTo(0, 0, 0, 0, directionx, 0); path = ArrowPath.make(path: path); canvas.drawPath(path, paintRed); } if (directiony.abs() > 20) { path2 = Path(); path2.moveTo(celluloyM.dx + 20, celluloyM.dy + 15); path2.relativeCubicTo(0, 0, 0, 0, 0, directiony); path2 = ArrowPath.make(path: path2); canvas.drawPath(path2, paintblue); } //canvas.drawLine(p1, p2, paint); } @override bool shouldRepaint(CustomPainter old) { return false; } } diff --git a/Dashboard/lib/widgets/celluloMap.Dart b/Dashboard/lib/widgets/celluloMap.Dart index 339af1f..5150555 100644 --- a/Dashboard/lib/widgets/celluloMap.Dart +++ b/Dashboard/lib/widgets/celluloMap.Dart @@ -1,160 +1,160 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:Teacher_Dashboard/widgets/linePainter.Dart'; Widget celluloMap( String gridPath, int turn, int acID, bool robotpatternSwitch, List celluloxPositiontopaint, List celluloyPositiontopaint, double mapSizeScreenWidth, double mapSizeScreenHeight, ) { // Activity-Dependent var imagespath = [ [ 'assets/images/Ac7_function1.svg', 'assets/images/Ac7_function2.svg', 'assets/images/Ac7_function3.svg' ], [ 'assets/images/Ac8_function1.svg', 'assets/images/Ac8_function2.svg', 'assets/images/Ac8_function3.svg', // 'assets/images/GridOnlyPositive.svg', ], [ 'assets/images/Ac8_function1.svg', 'assets/images/Ac8_function2.svg', 'assets/images/Ac8_function3.svg', // 'assets/images/GridOnlyPositive.svg', ], [ 'assets/images/Ac8_function1.svg', 'assets/images/Ac8_function2.svg', 'assets/images/Ac8_function3.svg', // 'assets/images/GridOnlyPositive.svg', ], [ 'assets/images/Ac8_function1.svg', 'assets/images/Ac8_function2.svg', 'assets/images/Ac8_function3.svg', // 'assets/images/GridOnlyPositive.svg', ], [ 'assets/images/Ac6_function1.svg', 'assets/images/Ac6_function2.svg', 'assets/images/Ac6_function3.svg', // 'assets/images/GridOnlyPositive.svg', ], [ 'assets/images/Ac7_function1.svg', 'assets/images/Ac7_function2.svg', 'assets/images/Ac7_function3.svg', // 'assets/images/GridOnlyPositive.svg', ], [ 'assets/images/Ac8_function1.svg', 'assets/images/Ac8_function2.svg', 'assets/images/Ac8_function3.svg', // 'assets/images/GridOnlyPositive.svg', ], [ 'assets/images/Ac6_function1.svg', 'assets/images/Ac6_function2.svg', 'assets/images/Ac6_function3.svg', // 'assets/images/GridOnlyPositive.svg', ], [ 'assets/images/Ac7_function1.svg', 'assets/images/Ac7_function2.svg', 'assets/images/Ac7_function3.svg', // 'assets/images/GridOnlyPositive.svg', ], [ 'assets/images/Ac8_function1.svg', 'assets/images/Ac8_function2.svg', 'assets/images/Ac8_function3.svg', // 'assets/images/GridOnlyPositive.svg', ], [ 'assets/images/Ac8_function1.svg', 'assets/images/Ac8_function2.svg', 'assets/images/Ac8_function3.svg', // 'assets/images/GridOnlyPositive.svg', ], ]; // 'assets/images/GridOnlyPositive.svg', final double mapSizeWidth = 860; final double mapSizeHeight = 860; List normalizecellulopath(List path) { List pathnorm = new List(); for (int i = 0; i < path.length; i++) { pathnorm.add(path[i] * mapSizeScreenWidth / mapSizeWidth); } return pathnorm; } return Stack(children: [ SvgPicture.asset(imagespath[acID][turn - 1]), SvgPicture.asset(gridPath), robotpatternSwitch ? CustomPaint( size: Size(mapSizeScreenWidth, mapSizeScreenHeight), painter: LinePainter2(normalizecellulopath(celluloxPositiontopaint), normalizecellulopath(celluloyPositiontopaint)), ) : Text(''), ]); } Widget celluloMap2( int turn, int acID, bool robotpatternSwitch, List cellulovxPositiontopaint, List cellulovyPositiontopaint, List celluloxxPositiontopaint, List celluloxyPositiontopaint, List celluloyxPositiontopaint, List celluloyyPositiontopaint, double mapSizeScreenWidth, double mapSizeScreenHeight) { // Activity-Dependent // 'assets/images/GridOnlyPositive.svg', final double mapSizeWidth = 860; final double mapSizeHeight = 860; List normalizecellulopath(List path) { List pathnorm = new List(); print(path); for (int i = 0; i < path.length; i++) { pathnorm.add(path[i] * mapSizeScreenWidth / mapSizeWidth); } return pathnorm; } return Stack(children: [ CustomPaint( size: Size(mapSizeScreenWidth, mapSizeScreenHeight), painter: LinePainter3(normalizecellulopath(cellulovxPositiontopaint), - normalizecellulopath(cellulovyPositiontopaint), [100, 100, 100]), + normalizecellulopath(cellulovyPositiontopaint), [100, 00, 100]), ), CustomPaint( size: Size(mapSizeScreenWidth, mapSizeScreenHeight), painter: LinePainter3(normalizecellulopath(celluloxxPositiontopaint), - normalizecellulopath(celluloxyPositiontopaint), [0, 200, 100]), + normalizecellulopath(celluloxyPositiontopaint), [200, 0, 100]), ), CustomPaint( size: Size(mapSizeScreenWidth, mapSizeScreenHeight), painter: LinePainter3(normalizecellulopath(celluloyxPositiontopaint), - normalizecellulopath(celluloyyPositiontopaint), [200, 0, 100]), + normalizecellulopath(celluloyyPositiontopaint), [20, 0, 200]), ), ]); } diff --git a/Dashboard/lib/widgets/mapShapeMaker.dart b/Dashboard/lib/widgets/mapShapeMaker.dart index d44dcb9..1d46f1d 100644 --- a/Dashboard/lib/widgets/mapShapeMaker.dart +++ b/Dashboard/lib/widgets/mapShapeMaker.dart @@ -1,291 +1,294 @@ import 'package:flutter/material.dart'; import 'dart:math' as math; class MapShapeMaker extends CustomPainter { Paint _paint; Paint _paintStartEnd; int numCircles; List originCircles; List radiuosCircles; int numRectangles; List originRectangles; List widthRectangles; List heightRectangles; int numPolygons; List sidesofPolygon; List radiusPolygon; List centerPolygon; List colorHexagon; Offset startCenter; Offset endCenter; double radiuosStart = 45; var mapHitColor = { - 'Circles': [0, 0, 0, 0, 0, 0, 0], - 'Rectangles': [0, 0, 0, 0, 0, 0], - 'Polygons': [0, 0, 0, 0, 0, 0, 0], + 'Circles': [0, 0, 0, 0, 0, 0, 0, 0], + 'Rectangles': [0, 0, 0, 0, 0, 0, 0, 0], + 'Polygons': [0, 0, 0, 0, 0, 0, 0, 0, 0], }; var pointOrder = ['A', 'B', 'C', 'D']; List pointPosition = [ Offset(80.0, 80.0), Offset(760.0, 80.0), Offset(80.0, 760.0), Offset(760.0, 760.0) ]; List pointPositionM = [ Offset(80.0, 80.0), Offset(760.0, 80.0), Offset(80.0, 760.0), Offset(760.0, 760.0) ]; List originCirclesM; List radiuosCirclesM; List originRectanglesM; List widthRectanglesM; List heightRectanglesM; List radiusPolygonM; List centerPolygonM; Offset startCenterM; Offset endCenterM; double radiuosStartM = 45; final _textPainter = TextPainter(textDirection: TextDirection.ltr); final _textPainter2 = TextPainter(textDirection: TextDirection.ltr); final _textPainter3 = TextPainter(textDirection: TextDirection.ltr); final _textPainter4 = TextPainter(textDirection: TextDirection.ltr); double coeffScreenMapHeight; double coeffScreenMapWidth; MapShapeMaker( coeffScreenMapWidth, this.coeffScreenMapHeight, this.numRectangles, this.originRectangles, this.widthRectangles, this.heightRectangles, this.numCircles, this.originCircles, this.radiuosCircles, this.numPolygons, this.sidesofPolygon, this.radiusPolygon, this.centerPolygon, this.startCenter, this.endCenter, this.mapHitColor) { _paint = Paint() ..color = Colors.blue ..strokeWidth = 10.0 ..style = PaintingStyle.fill; _paintStartEnd = Paint() ..color = Colors.green ..strokeWidth = 10.0 ..style = PaintingStyle.fill; // print(originRectangles[0].dx); // print('coeff' + coeffScreenMapWidth.toString()); originCirclesM = new List(numCircles); radiuosCirclesM = new List(numCircles); for (int i = 0; i < numCircles; i++) { originCirclesM[i] = Offset(originCircles[i].dx * coeffScreenMapWidth, originCircles[i].dy * coeffScreenMapHeight); radiuosCirclesM[i] = radiuosCircles[i] * coeffScreenMapWidth; } + radiuosStartM = radiuosStart * coeffScreenMapWidth; + originRectanglesM = new List(numRectangles); widthRectanglesM = new List(numRectangles); heightRectanglesM = new List(numRectangles); for (int i = 0; i < numRectangles; i++) { + print(numRectangles); originRectanglesM[i] = Offset( originRectangles[i].dx * coeffScreenMapWidth, originRectangles[i].dy * coeffScreenMapHeight); widthRectanglesM[i] = widthRectangles[i] * coeffScreenMapWidth; heightRectanglesM[i] = heightRectangles[i] * coeffScreenMapHeight; } centerPolygonM = new List(numPolygons); radiusPolygonM = new List(numPolygons); startCenterM = Offset(startCenter.dx * coeffScreenMapWidth, startCenter.dy * coeffScreenMapHeight); endCenterM = Offset(endCenter.dx * coeffScreenMapWidth, endCenter.dy * coeffScreenMapHeight); for (int i = 0; i < numPolygons; i++) { centerPolygonM[i] = Offset(centerPolygon[i].dx * coeffScreenMapWidth, centerPolygon[i].dy * coeffScreenMapHeight); radiusPolygonM[i] = radiusPolygon[i] * coeffScreenMapWidth; } for (int i = 0; i < 4; i++) { pointPositionM[i] = Offset(pointPosition[i].dx * coeffScreenMapWidth, pointPosition[i].dy * coeffScreenMapHeight); } } Path createPolygonPath(int i) { final path = Path(); var angle = (math.pi * 2) / sidesofPolygon[i]; Offset firstPoint = Offset( radiusPolygonM[i] * math.cos(0.0), radiusPolygonM[i] * math.sin(0.0)); path.moveTo(firstPoint.dx + centerPolygonM[i].dx, firstPoint.dy + centerPolygonM[i].dy); for (int j = 1; j <= sidesofPolygon[i]; j++) { double x = radiusPolygonM[i] * math.cos(angle * j) + centerPolygonM[i].dx; double y = radiusPolygonM[i] * math.sin(angle * j) + centerPolygonM[i].dy; path.lineTo(x, y); } path.close(); return path; } Path createStartPath(Offset center, double radius) { final path = Path(); var angle = (math.pi * 2) / 6; Offset firstPoint = Offset(radius * math.cos(0.0), radius * math.sin(0.0)); path.moveTo(firstPoint.dx + center.dx, firstPoint.dy + center.dy); for (int j = 1; j <= 6; j++) { double x = radius * math.cos(angle * j) + center.dx; double y = radius * math.sin(angle * j) + center.dy; path.lineTo(x, y); } path.close(); return path; } @override void paint(Canvas canvas, Size size) { for (int i = 0; i < numCircles; i++) { double x = ((originCirclesM[i].dx)); double y = (originCirclesM[i].dy); canvas.drawCircle( Offset(x, y), radiuosCirclesM[i], _paint ..color = Color.fromRGBO(mapHitColor['Circles'][i], 0, 255, 1.0)); } for (int i = 0; i < numRectangles; i++) { // canvas.translate(0, 90); // canvas.rotate(1.3); canvas.drawRect( Rect.fromCenter( center: Offset(originRectanglesM[i].dx, originRectanglesM[i].dy), width: widthRectanglesM[i], height: heightRectanglesM[i]), _paint ..color = Color.fromRGBO(mapHitColor['Rectangles'][i], 0, 255, 1.0)); } for (int i = 0; i < numPolygons; i++) { Path path = createPolygonPath(i); canvas.drawPath( path, _paint ..color = Color.fromRGBO(mapHitColor['Polygons'][i], 0, 255, 1.0)); } canvas.drawPath( createStartPath(pointPositionM[2], radiuosStartM), Paint() ..color = Colors.green ..strokeWidth = 10.0 ..style = PaintingStyle.fill); canvas.drawPath( createStartPath(pointPositionM[2], radiuosStartM - 10), Paint() ..color = Colors.white ..strokeWidth = 10.0 ..style = PaintingStyle.fill); canvas.drawPath( createStartPath(pointPositionM[3], radiuosStartM), Paint() ..color = Colors.green ..strokeWidth = 10.0 ..style = PaintingStyle.fill); canvas.drawPath( createStartPath(pointPositionM[3], radiuosStartM - 10), Paint() ..color = Colors.white ..strokeWidth = 10.0 ..style = PaintingStyle.fill); _textPainter2.text = TextSpan( text: pointOrder[1], style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black)); _textPainter2.layout( minWidth: 0, maxWidth: double.maxFinite, ); _textPainter.text = TextSpan( text: pointOrder[0], style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black)); _textPainter.layout( minWidth: 0, maxWidth: double.maxFinite, ); _textPainter3.text = TextSpan( text: pointOrder[2], style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black)); _textPainter3.layout( minWidth: 0, maxWidth: double.maxFinite, ); _textPainter4.text = TextSpan( text: pointOrder[3], style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black)); _textPainter4.layout( minWidth: 0, maxWidth: double.maxFinite, ); canvas.drawPath( createStartPath(pointPositionM[0], radiuosStartM), Paint() ..color = Colors.green ..strokeWidth = 10.0 ..style = PaintingStyle.fill); canvas.drawPath( createStartPath(pointPositionM[0], radiuosStartM - 10), Paint() ..color = Colors.white ..strokeWidth = 10.0 ..style = PaintingStyle.fill); canvas.drawPath( createStartPath(pointPositionM[1], radiuosStartM), Paint() ..color = Colors.green ..strokeWidth = 10.0 ..style = PaintingStyle.fill); canvas.drawPath( createStartPath(pointPositionM[1], radiuosStartM - 10), Paint() ..color = Colors.white ..strokeWidth = 10.0 ..style = PaintingStyle.fill); _textPainter.paint( canvas, Offset(pointPositionM[0].dx - 6, pointPositionM[0].dy - 5)); _textPainter2.paint( canvas, Offset(pointPositionM[1].dx - 6, pointPositionM[1].dy - 5)); _textPainter3.paint( canvas, Offset(pointPositionM[2].dx - 6, pointPositionM[2].dy - 5)); _textPainter4.paint( canvas, Offset(pointPositionM[3].dx - 6, pointPositionM[3].dy - 5)); } @override bool shouldRepaint(CustomPainter oldDelegate) { return false; } } diff --git a/student/lib/loginpage_names.dart b/student/lib/loginpage_names.dart index 186f1e0..6f9c8b9 100644 --- a/student/lib/loginpage_names.dart +++ b/student/lib/loginpage_names.dart @@ -1,185 +1,185 @@ import 'package:flutter/material.dart'; import 'package:student/loginpage_robots.dart'; import 'dart:convert'; import 'dart:async'; import 'package:firebase_core/firebase_core.dart'; import 'package:student/Database.dart'; import 'package:student/model/Group.dart'; import 'package:student/model/Cellulo.dart'; import 'package:student/Game.dart'; import 'package:student/Database.dart'; import 'package:student/widgets/showAlertDialog.Dart'; import 'package:firebase_database/firebase_database.dart'; class LoginPage extends StatefulWidget { LoginPage({Key key}) : super(key: key); @override _LoginPageState createState() => _LoginPageState(); } class _LoginPageState extends State { TextEditingController controller1 = TextEditingController(); TextEditingController controller2 = TextEditingController(); TextEditingController controller3 = TextEditingController(); TextEditingController controller4 = TextEditingController(); TextEditingController controllersessionID = TextEditingController(); Timer timerEnagagement; final teamname = "1"; @override void initState() { cellulox.setColor(0, 255, 0, 0, 0); celluloy.setColor(0, 0, 255, 0, 0); cellulox.clearrobot(); celluloy.clearrobot(); super.initState(); } @override void dispose() { super.dispose(); } Widget nextButton() { return InkWell( onTap: () { if (controllersessionID.text != null && controller4.text != null && controllersessionID.text != '' && controller4.text != '') { group.sessionID = controllersessionID.text; //print(controller4.text); group.member1name = controller1.text; group.member2name = controller2.text; group.member3name = controller3.text; group.id = controller4.text; - group.currentActivity = 'Ac8'; + group.currentActivity = 'Ac4'; final dbRef = FirebaseDatabase.instance.reference().child(group.sessionID); dbRef.child('groups').child(controller4.text).set(group.toJson()); group.setupDatabse(); group.cellulox = cellulox; group.celluloy = celluloy; cellulox.setup(); //setting up the robots Navigator.push( context, MaterialPageRoute(builder: (context) => Game())); } else showAlertDialogmain(context, 'What is your session ID', 'Fill the session ID and team name'); }, child: Container( width: MediaQuery.of(context).size.width, padding: EdgeInsets.symmetric(vertical: 13), alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(5)), boxShadow: [ BoxShadow( color: Color(0xffdf8e33).withAlpha(100), offset: Offset(2, 4), blurRadius: 8, spreadRadius: 2) ], color: Colors.white), child: Text( 'Lets go', style: TextStyle(fontSize: 20, color: Color(0xfff7892b)), ), ), ); } Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Login'), ), backgroundColor: Colors.white, body: SingleChildScrollView( child: Padding( padding: EdgeInsets.all(30.0), child: Column(children: [ Container( padding: EdgeInsets.all(8.0), decoration: BoxDecoration( border: Border( bottom: BorderSide(color: Colors.grey[100]))), child: TextField( controller: controller1, decoration: InputDecoration( border: InputBorder.none, hintText: "Member 1: Enter your name", hintStyle: TextStyle(color: Colors.grey[400])), ), ), SizedBox( height: 100, ), Container( padding: EdgeInsets.all(8.0), decoration: BoxDecoration( border: Border( bottom: BorderSide(color: Colors.grey[100]))), child: TextField( controller: controller2, decoration: InputDecoration( border: InputBorder.none, hintText: "Member 2: Enter your name", hintStyle: TextStyle(color: Colors.grey[400])), ), ), SizedBox( height: 100, ), Container( padding: EdgeInsets.all(8.0), decoration: BoxDecoration( border: Border( bottom: BorderSide(color: Colors.grey[100]))), child: TextField( controller: controller3, decoration: InputDecoration( border: InputBorder.none, hintText: "Member 3: Enter your name", hintStyle: TextStyle(color: Colors.grey[400])), ), ), SizedBox( height: 100, ), Container( padding: EdgeInsets.all(8.0), decoration: BoxDecoration( border: Border( bottom: BorderSide(color: Colors.grey[100]))), child: TextField( controller: controller4, decoration: InputDecoration( border: InputBorder.none, hintText: "Enter your group name", hintStyle: TextStyle(color: Colors.grey[400])), ), ), SizedBox( height: 50, ), Container( padding: EdgeInsets.all(8.0), decoration: BoxDecoration( border: Border( bottom: BorderSide(color: Colors.grey[100]))), child: TextField( controller: controllersessionID, decoration: InputDecoration( border: InputBorder.none, hintText: "Enter session ID", hintStyle: TextStyle(color: Colors.grey[400])), ), ), nextButton() ])))); } }