Page MenuHomec4science

templateAc.Dart
No OneTemporary

File Metadata

Created
Wed, Jul 31, 23:16

templateAc.Dart

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:student/widgets/onlineRobotMap.Dart';
import 'package:student/widgets/celluloMap.Dart';
import 'dart:async';
import 'dart:convert';
import 'package:student/Database.dart';
import 'package:student/model/Group.dart';
import 'package:student/model/Cellulo.dart';
import 'package:student/widgets/showAlertDialog.Dart';
import 'package:student/widgets/membersBar.Dart';
import 'package:student/widgets/inactivityDetector.Dart';
import 'package:flutter_appavailability/flutter_appavailability.dart';
class TempAc extends StatefulWidget {
TempAc({Key key}) : super(key: key);
@override
_TempAcState createState() => _TempAcState();
}
class _TempAcState extends State<TempAc> {
// Activity_Independent
var elapseTimer = new Stopwatch();
Timer timerCelluloPosition;
int currentTurn = 1;
int tapCounter = 0;
List<int> progress = [0, -2, -2];
List<int> progressElpasedTime = [0, 0, 0];
// Celulo
var celluloxPosition = [0.0, 0.0];
var celluloyPosition = [0.0, 0.0];
var xlabelposition = [0, 1];
var ylabelposition = [-1, 0];
List<List<double>> celluloxPositiontopaint =
new List.generate(3, (int index) => List(2), growable: true);
List<List<double>> celluloyPositiontopaint =
new List.generate(3, (int index) => List(2), growable: true);
bool addtoprint;
var lineallow = [false, false, false];
// Learning
List<int> mistakesSlope = [0, 0, 0];
List<int> mistakesIntrepet = [0, 0, 0];
List<int> mistakesInitialPosition = [0, 0, 0];
//Activity Dependent
String activityTitle = 'Activity 6';
var linesPath = [
'assets/images/Ac7_function1.svg',
'assets/images/Ac7_function2.svg',
'assets/images/Ac7_function3.svg',
'assets/images/GridOnlyPositive.svg',
];
// map-related
final double mapSizeWidth = 860;
final double mapSizeHeight = 860;
final String mapPath = 'assets/images/GridOnlyPositive.svg';
final String celluloxpath = 'assets/images/cellulox.svg';
final String celluloypath = 'assets/images/celluloy.svg';
@override
void initState() {
super.initState();
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
dbRef.child('groups').child(group.id).child('currentActivity').set("Ac6");
elapseTimer.start();
timerCelluloPosition =
new Timer.periodic(new Duration(milliseconds: 500), (time) {
if (totalRobots() > 1) {
print(cellulox.getrobotKidnapped().toString());
print(celluloy.getrobotKidnapped().toString());
cellulox.getrobotx().then((val) => setState(() {
if (val != null) {
celluloxPosition[0] = val;
// if (addtoprint == true)
// celluloxPositiontopaint.add(val * 500 / 860);
}
// print(addtoprint.toString());
}));
cellulox.getroboty().then((val) => setState(() {
if (val != null) {
celluloxPosition[1] = val;
}
}));
celluloy.getrobotx().then((val) => setState(() {
if (val != null) {
celluloyPosition[0] = val;
}
}));
celluloy.getroboty().then((val) => setState(() {
if (val != null) {
celluloyPosition[1] = val;
// if (addtoprint == true)
// celluloyPositiontopaint.add(val * 500 / 860);
}
}));
if (celluloxPosition[0] > 800 || celluloyPosition[1] > 800) {
cellulox.setVelocity(0, 0);
celluloy.setVelocity(0, 0);
}
}
});
}
void onDataSend() {
dbRef.child('attempts').push().set(json.encode({
"numAttempts": tapCounter,
"groupID": group.id,
"acID": "Ac3",
"elpasedTime": elapseTimer.elapsedMilliseconds -
progressElpasedTime[currentTurn - 1],
"progress": {
"turn1": progress[0],
"turn2": progress[1],
"turn3": progress[2]
},
"progressElpasedTime": {
"turn1": progressElpasedTime[0],
"turn2": progressElpasedTime[1],
"turn3": progressElpasedTime[2],
},
"currentTurn": currentTurn,
// "inactivity": inactivity,
"mistakes": {
"turn1": {
"slope": mistakesSlope[0],
"initialPoint": mistakesInitialPosition[0]
},
"turn2": {
"slope": mistakesSlope[1],
"initialPoint": mistakesInitialPosition[1]
},
"turn3": {
"slope": mistakesSlope[2],
"initialPoint": mistakesInitialPosition[2]
},
}
}));
}
@override
void dispose() {
timerCelluloPosition.cancel();
elapseTimer.stop();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Activity 7: Semi-Mathematical Control'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(children: <Widget>[
celluloMap(
context,
celluloxPositiontopaint,
celluloyPositiontopaint,
celluloxPosition,
celluloyPosition,
mapPath,
celluloxpath,
celluloypath,
linesPath[currentTurn - 1],
mapSizeWidth,
mapSizeHeight,
'X',
'Y',
xlabelposition,
ylabelposition,
lineallow),
SizedBox(
height: 15,
),
MembersBar(),
])));
}
}

Event Timeline