Page MenuHomec4science

Ac6_1.dart
No OneTemporary

File Metadata

Created
Wed, Nov 13, 09:05

Ac6_1.dart

import 'package:flutter/material.dart';
import 'package:flutter/foundation.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';
import 'package:video_player/video_player.dart';
import 'dart:math' as math;
class Ac61 extends StatefulWidget {
final int acID;
Ac61({Key key, this.acID}) : super(key: key);
@override
_Ac61State createState() => _Ac61State();
}
class _Ac61State extends State<Ac61>
with SingleTickerProviderStateMixin, WidgetsBindingObserver {
// Timers
Timer timerCelluloPosition;
Timer timerslopedetection;
Timer timercleartracking;
Timer timerCelluloPositionPaint;
Timer timerInactivityDetector;
Timer timerCelluloPositionPainttoserver;
int acID = 6;
final maxLiitCellulo = 800;
// UI parameters
bool celluloxSwitch1 = true;
bool celluloySwitch1 = false;
bool celluloxSwitch2 = true;
bool celluloySwitch2 = false;
var onStop = false;
bool mode = false;
int wrongcounts = 0;
double _progress = 0.0;
final celluloSize = 60;
final ScrollController _scrollController = ScrollController();
final functionFormulas = ['X ⟼ Y', 'X+1 ⟼ Y', 'X+2 ⟼ Y', '2*X ⟼ Y', '-X ⟼ Y'];
Offset beginpath = Offset(0, 0);
Offset endpath = Offset(10, 100);
AnimationController controllerTrial;
AnimationController controllerTurn;
Animation<double> animation;
Animation<double> animationNextTurn;
TextEditingController controllerinitialX = TextEditingController();
TextEditingController controllerinitialY = TextEditingController();
TextEditingController controllerXslope = TextEditingController();
TextEditingController controllerYslope = TextEditingController();
var counterfunctionImage = 0;
//Activity Dependent
var linesPath = [
'assets/images/Ac61_function1.svg',
'assets/images/Ac61_function2.svg',
'assets/images/Ac61_function3.svg',
'assets/images/Grid_Ac61_Screen.svg',
];
var lineallow = [false, false, false];
var linesSlope = [1, 2, -1];
var initialPoint = [0, 0, 6];
// map-related
final double mapSizeWidth = 860;
final double mapSizeHeight = 860;
final double screenSizeWidth = 500;
final double screenSizeHeight = 500;
final String mapPath = 'assets/images/Grid_Ac61_Screen.svg';
final String celluloxpath = 'assets/images/celluloRed.svg';
final String celluloypath = 'assets/images/celluloBlue.svg';
var onTap = [false, false, false, false, false];
// var onTap=[false,false,false,false,false];
final names = [group.member1name, group.member2name, group.member3name];
var currentTurn = 1;
var currentTap = 0;
var tapCounter = 0;
int simulationVelCoeff = 1;
// Learning
List<int> progress = [0, -2, -2];
// zero: undergoing, -1: not accomplished, 1: accomplished
bool waitforanimation = false;
List<int> mistakesSlope = [0, 0, 0];
List<int> mistakesIntrepet = [0, 0, 0];
List<int> mistakesInitialPosition = [0, 0, 0];
List<int> progressElpasedTime = [0, 0, 0];
List<String> videoPaths = ['assets/images/IMG_0095.mp4'];
List<String> introString = [
'in this game, you try to reach the goal without hitting the obstacles.',
'in this game, you try to reach the goal without hitting the obstacles together. ',
'in this game, you try to reach the goal without hitting the obstacles together.',
'in this game, you try to follow the curve from start point to end point together. ',
'in this game, two of you try to follow the curve.',
'in this game, you try to follow the line, taking both robots in your hands. ',
'in this game, you try to guess the parameters that your robot follow the line. ',
'in this game, you try to guess the equation of the orange line. In the list,',
];
List<String> instructionString = [
' The obstacles are only shown on the tablet. In each turn, two of you play with the two robots and one person looks at the tablet and can guide two persons with robots',
' The obstacles are only shown on the tablet. In each turn, two of you play with the two robots and one person looks at the tablet and can guide two persons with robots',
' The obstacles are only shown on the tablet. In each turn, two of you play with the two robots and one person looks at the tablet and can guide two persons with robots',
' The curve is only shown on the tablet. In each turn, two of you play with the two robots and one person looks at the tablet.',
' The curve and start and end points are only shown on the tablet. In each turn, two of you play with the two robots, as shown in the video',
' The line is only shown on the tablet. In each turn, one of you play with the two robots and then another group member takes the turn by pressing starting again. ',
' The line is only shown on the tablet. In each turn, all of you play fill the parametrs on tablet.',
' In the list, when you click on an equation, the simulation of virtual robots shows your guess. In each turn, two of you play with the two robots and one person looks at the tablet and can guide two persons with robots. ',
];
List<String> mapNumber = ['1', '1', '1', '1', '2', '3', '4'];
List<List<double>> celluloxPositiontopaint =
new List.generate(3, (int index) => [0.0, 0.0], growable: true);
List<List<double>> celluloyPositiontopaint =
new List.generate(3, (int index) => [0.0, 0.0], growable: true);
var xlabelposition = [1.0, 1.0];
var ylabelposition = [-0.6, -1.0];
var prevcelluloxPosition = [0.0, 0.0];
var prevcelluloyPosition = [0.0, 0.0];
List<String> acList = [
'Ac1',
'Ac2',
'Ac3',
'Ac4',
'Ac5',
'Ac6',
'Ac7',
'Ac8'
];
// screen-related
VideoPlayerController _controller;
Future<void> _initializeVideoPlayerFuture;
@override
void initState() {
if (widget.acID != null) acID = widget.acID;
cellulox.clearrobot();
celluloy.clearrobot();
WidgetsBinding.instance.addObserver(this);
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
//dbRef.child('groups').child(group.id).child('currentActivity').set("Ac61");
print(acID);
super.initState();
// cellulox.resetrobot();
// celluloy.resetrobot();
acID = acList.indexOf(group.prevActivity);
///
/// Ask to be notified when messages related to the game
/// are sent by the server
///
_controller = VideoPlayerController.asset(videoPaths[0]);
_initializeVideoPlayerFuture = _controller.initialize();
_controller.play();
}
@override
void dispose() {
cellulox.clearrobot();
celluloy.clearrobot();
//controllerTrial.dispose();
super.dispose();
}
AppLifecycleState _notification;
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
} else {
dbRef.child('groups').child(group.id).child('tabletStatus').set("NO");
}
setState(() {
_notification = state;
});
}
void nextPLayer() {
setState(() {
currentTurn = currentTurn + 1;
// celluloyPositiontopaint = [0.0, 0.0];
// celluloxPositiontopaint = [0.0, 0.0];
});
}
void animationRunner(progress) {}
@override
Widget build(BuildContext context) {
var args = ModalRoute.of(context).settings.arguments;
return Scaffold(
appBar: AppBar(
title: const Text('Tutorial'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(children: <Widget>[
Container(
// margin: const EdgeInsets.all(15.0),
padding: const EdgeInsets.all(5.0),
decoration: BoxDecoration(),
height: 250.0,
child: Column(children: <Widget>[
Card(
color: Colors.blue,
child: ListTile(
title: Text(
introString[acID],
style: new TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
),
SizedBox(
height: 10,
),
Card(
color: Colors.blue,
child: ListTile(
title: Text(
instructionString[acID],
style: new TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
),
SizedBox(
height: 10,
),
Row(
//mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(100)),
color: Colors.blue),
child: IconButton(
icon: Icon(Icons.skip_previous),
onPressed: () => {
setState(() {
// If the video is playing, pause it.
_controller.pause();
// _controller.dispose();
print(acID);
group.currentActivity = group.prevActivity;
group.navigatorKeygame.currentState
.pushReplacementNamed(
group.currentActivity);
}),
},
)),
Container(
width: 450,
child: Card(
color: Colors.blue,
child: ListTile(
title: Text(
'When you are ready you can go back to the game',
style: new TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
)),
SizedBox(width: 25),
Container(
width: 170,
child: Card(
color: Colors.blue,
child: ListTile(
title: Text(
'Map number:' + mapNumber[acID].toString(),
style: new TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
)),
]),
])),
SizedBox(
height: 70,
),
Container(
height: 500,
child: FutureBuilder(
future: _initializeVideoPlayerFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
// If the VideoPlayerController has finished initialization, use
// the data it provides to limit the aspect ratio of the VideoPlayer.
return AspectRatio(
aspectRatio: _controller.value.aspectRatio,
// Use the VideoPlayer widget to display the video.
child: VideoPlayer(_controller),
);
} else {
// If the VideoPlayerController is still initializing, show a
// loading spinner.
return Center(child: CircularProgressIndicator());
}
},
)),
SizedBox(
height: 25,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(100)),
color: Colors.blue),
child: IconButton(
icon: Icon(Icons.play_circle_outline),
onPressed: () => {
setState(() {
// If the video is playing, pause it.
if (_controller.value.isPlaying) {
_controller.pause();
} else {
// If the video is paused, play it.
_controller.play();
}
}),
},
)),
])));
}
}

Event Timeline