Skip to content

Commit

Permalink
- bacheca
Browse files Browse the repository at this point in the history
- nuovo cosa è successo oggi
- altri fix
  • Loading branch information
peppelg committed Mar 14, 2020
1 parent 1ad85b3 commit 74995f4
Show file tree
Hide file tree
Showing 13 changed files with 455 additions and 319 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"background_fetch","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\background_fetch-0.4.0\\\\","dependencies":[]},{"name":"flutter_local_notifications","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_local_notifications-1.1.1\\\\","dependencies":[]},{"name":"fluttertoast","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\fluttertoast-3.1.3\\\\","dependencies":[]},{"name":"install_plugin","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\install_plugin-2.0.1\\\\","dependencies":[]},{"name":"package_info","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\package_info-0.4.0+13\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.5.1\\\\","dependencies":[]},{"name":"quick_actions","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\quick_actions-0.4.0+1\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-5.4.1\\\\","dependencies":[]}],"android":[{"name":"background_fetch","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\background_fetch-0.4.0\\\\","dependencies":[]},{"name":"flutter_local_notifications","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_local_notifications-1.1.1\\\\","dependencies":[]},{"name":"fluttertoast","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\fluttertoast-3.1.3\\\\","dependencies":[]},{"name":"install_plugin","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\install_plugin-2.0.1\\\\","dependencies":[]},{"name":"package_info","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\package_info-0.4.0+13\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.5.1\\\\","dependencies":[]},{"name":"quick_actions","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\quick_actions-0.4.0+1\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-5.4.1\\\\","dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_macos-0.0.1+2\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"url_launcher_web","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_web-0.1.0+2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"background_fetch","dependencies":[]},{"name":"flutter_local_notifications","dependencies":[]},{"name":"fluttertoast","dependencies":[]},{"name":"install_plugin","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"quick_actions","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-02-26 11:37:52.911499","version":"1.14.6"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"background_fetch","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\background_fetch-0.4.0\\\\","dependencies":[]},{"name":"flutter_local_notifications","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_local_notifications-1.1.1\\\\","dependencies":[]},{"name":"fluttertoast","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\fluttertoast-3.1.3\\\\","dependencies":[]},{"name":"install_plugin","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\install_plugin-2.0.1\\\\","dependencies":[]},{"name":"package_info","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\package_info-0.4.0+13\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.5.1\\\\","dependencies":[]},{"name":"quick_actions","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\quick_actions-0.4.0+1\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-5.4.1\\\\","dependencies":[]}],"android":[{"name":"background_fetch","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\background_fetch-0.4.0\\\\","dependencies":[]},{"name":"flutter_local_notifications","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_local_notifications-1.1.1\\\\","dependencies":[]},{"name":"fluttertoast","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\fluttertoast-3.1.3\\\\","dependencies":[]},{"name":"install_plugin","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\install_plugin-2.0.1\\\\","dependencies":[]},{"name":"package_info","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\package_info-0.4.0+13\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.5.1\\\\","dependencies":[]},{"name":"quick_actions","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\quick_actions-0.4.0+1\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-5.4.1\\\\","dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_macos-0.0.1+2\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"url_launcher_web","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_web-0.1.0+2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"background_fetch","dependencies":[]},{"name":"flutter_local_notifications","dependencies":[]},{"name":"fluttertoast","dependencies":[]},{"name":"install_plugin","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"quick_actions","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-03-14 18:44:26.179631","version":"1.14.6"}
177 changes: 122 additions & 55 deletions lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ Future login(school, username, password) async {
}
}

Future votigiornalieri() async {
var response = await argoRequest(fullHeaders, 'votigiornalieri',
{'page': '1', 'start': '0', 'limit': '25'});
Future votigiornalieri({var response}) async {
if (response == null) {
response = await argoRequest(fullHeaders, 'votigiornalieri',
{'page': '1', 'start': '0', 'limit': '25'});
}
if (response.containsKey('error')) {
Fluttertoast.showToast(msg: 'Errore sconosciuto:\n\n' + response['error']);
return {};
Expand Down Expand Up @@ -169,9 +171,11 @@ Future votigiornalieri() async {
return materieVoti;
}

Future note() async {
var response = await argoRequest(fullHeaders, 'notedisciplinari',
{'page': '1', 'start': '0', 'limit': '25'});
Future note({var response}) async {
if (response == null) {
response = await argoRequest(fullHeaders, 'notedisciplinari',
{'page': '1', 'start': '0', 'limit': '25'});
}
if (response.containsKey('error')) {
Fluttertoast.showToast(msg: 'Errore sconosciuto:\n\n' + response['error']);
return [];
Expand All @@ -187,9 +191,11 @@ Future note() async {
return listaNote;
}

Future assenze() async {
var response = await argoRequest(
fullHeaders, 'assenze', {'page': '1', 'start': '0', 'limit': '25'});
Future assenze({var response}) async {
if (response == null) {
response = await argoRequest(
fullHeaders, 'assenze', {'page': '1', 'start': '0', 'limit': '25'});
}
if (response.containsKey('error')) {
Fluttertoast.showToast(msg: 'Errore sconosciuto:\n\n' + response['error']);
return [];
Expand All @@ -214,11 +220,13 @@ Future assenze() async {
listaAssenze.add({
'assenza': testoAssenza,
'prof': 'Registrata da: ' +
assenza['registrataDa'].replaceAll('(', '').replaceAll(')', '') +
(assenza.containsKey('giustificataDa')
? '\nGiustificata da: ' +
assenza['giustificataDa'].replaceAll('(', '').replaceAll(')', '')
: ''),
assenza['registrataDa'].replaceAll('(', '').replaceAll(')', '') +
(assenza.containsKey('giustificataDa')
? '\nGiustificata da: ' +
assenza['giustificataDa']
.replaceAll('(', '')
.replaceAll(')', '')
: ''),
'giustificata': assenza.containsKey('giustificataDa')
? true
: !assenza['flgDaGiustificare']
Expand All @@ -227,9 +235,11 @@ Future assenze() async {
return listaAssenze;
}

Future compiti() async {
var response = await argoRequest(
fullHeaders, 'compiti', {'page': '1', 'start': '0', 'limit': '25'});
Future compiti({var response}) async {
if (response == null) {
response = await argoRequest(
fullHeaders, 'compiti', {'page': '1', 'start': '0', 'limit': '25'});
}
if (response.containsKey('error')) {
Fluttertoast.showToast(msg: 'Errore sconosciuto:\n\n' + response['error']);
return {};
Expand All @@ -248,9 +258,11 @@ Future compiti() async {
return listaCompiti;
}

Future argomenti() async {
var response = await argoRequest(
fullHeaders, 'argomenti', {'page': '1', 'start': '0', 'limit': '25'});
Future argomenti({var response}) async {
if (response == null) {
response = await argoRequest(
fullHeaders, 'argomenti', {'page': '1', 'start': '0', 'limit': '25'});
}
if (response.containsKey('error')) {
Fluttertoast.showToast(msg: 'Errore sconosciuto:\n\n' + response['error']);
return {};
Expand All @@ -270,9 +282,11 @@ Future argomenti() async {
return listaArgomenti;
}

Future orario() async {
var response = await argoRequest(
fullHeaders, 'orario', {'page': '1', 'start': '0', 'limit': '25'});
Future orario({var response}) async {
if (response == null) {
response = await argoRequest(
fullHeaders, 'orario', {'page': '1', 'start': '0', 'limit': '25'});
}
if (response.containsKey('error')) {
Fluttertoast.showToast(msg: 'Errore sconosciuto:\n\n' + response['error']);
return {};
Expand All @@ -296,59 +310,112 @@ Future orario() async {
return tabellaOrario;
}

Future oggi(data) async {
Future oggi(data, {var response}) async {
data = DateFormat('yyyy-MM-dd')
.format(DateFormat('dd/MM/y').parse(data))
.toString();
var response = await argoRequest(fullHeaders, 'oggi',
{'datGiorno': data, 'page': '1', 'start': '0', 'limit': '25'});
if (response == null) {
response = await argoRequest(fullHeaders, 'oggi',
{'datGiorno': data, 'page': '1', 'start': '0', 'limit': '25'});
}
if (response.containsKey('error')) {
Fluttertoast.showToast(msg: 'Errore sconosciuto:\n\n' + response['error']);
return [];
}
var listaOggi = [];
var listaOggi = {
'Voti': [],
'Compiti': [],
'Argomenti': [],
'Note': [],
'Assenze': [],
'Bacheca': []
};
for (var tipo in response['dati']) {
if (tipo['tipo'] == 'VOT') {
//voto
var voti = await votigiornalieri(response: {
'dati': [tipo['dati']]
});
voti.forEach((k, v) {
for (var voto in v['voti']) {
listaOggi['Voti'].add({'materia': k, 'elemento': voto});
}
});
}
if (tipo['tipo'] == 'COM') {
//compito assegnato
listaOggi.add({
'tipo': 'compito',
'titolo': tipo['dati']['desMateria'] + ' ' + tipo['dati']['docente'],
'descrizione': tipo['dati']['desCompiti']
//compiti assegnati
var elementi = await compiti(response: {
'dati': [tipo['dati']]
});
elementi.forEach((k, v) {
for (var elemento in v) {
listaOggi['Compiti'].add({'materia': k, 'elemento': elemento});
}
});
}
if (tipo['tipo'] == 'ARG') {
//argomento
listaOggi.add({
'tipo': 'argomento',
'titolo': tipo['dati']['desMateria'] + ' ' + tipo['dati']['docente'],
'descrizione': tipo['dati']['desArgomento']
//argomenti lezione
var elementi = await argomenti(response: {
'dati': [tipo['dati']]
});
}
if (tipo['tipo'] == 'VOT') {
//voto
listaOggi.add({
'tipo': 'voto',
'titolo': tipo['dati']['desMateria'] + ' ' + tipo['dati']['docente'],
'voto': tipo['dati']['decValore'].toString(),
'descrizione': 'Voto: ' + tipo['dati']['decValore'].toString()
elementi.forEach((k, v) {
for (var elemento in v) {
listaOggi['Argomenti'].add({'materia': k, 'elemento': elemento});
}
});
}
if (tipo['tipo'] == 'NOT') {
//nota
listaOggi.add({
'tipo': 'nota',
'titolo': tipo['dati']['docente'],
'descrizione': tipo['dati']['desNota']
//note
var elementi = await note(response: {
'dati': [tipo['dati']]
});
for (var elemento in elementi) {
listaOggi['Note'].add({'elemento': elemento});
}
}
if (tipo['tipo'] == 'ASS') {
//assenza
listaOggi.add({
'tipo': 'assenza',
'titolo': tipo['dati']['registrataDa'],
'descrizione': 'Assenza.'
//assenze
var elementi = await assenze(response: {
'dati': [tipo['dati']]
});
for (var elemento in elementi) {
listaOggi['Assenze'].add({'elemento': elemento});
}
}
if (tipo['tipo'] == 'BAC') {
//assenze
var elementi = await bacheca(response: {
'dati': [tipo['dati']]
});
for (var elemento in elementi) {
listaOggi['Bacheca'].add({'elemento': elemento});
}
}
}
return listaOggi;
}

Future bacheca({response}) async {
if (response == null) {
response = await argoRequest(fullHeaders, 'bachecanuova',
{'page': '1', 'start': '0', 'limit': '25'});
}
if (response.containsKey('error')) {
Fluttertoast.showToast(msg: 'Errore sconosciuto:\n\n' + response['error']);
return {};
}
var listaBacheca = [];
for (var elemento in response['dati']) {
listaBacheca.add(bacheca_parse(elemento));
}
return listaBacheca;
}

bacheca_parse(elemento) {
return {
'oggetto': elemento['desOggetto'],
'messaggio': elemento['desMessaggio'],
'link': elemento['desUrl'],
'data': formatDate(elemento['datGiorno'])
};
}
18 changes: 2 additions & 16 deletions lib/assenze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:backdrop/backdrop.dart';
import 'backdropWidgets.dart';
import 'api.dart';
import 'widgets.dart';

class AssenzeRoute extends StatefulWidget {
@override
Expand All @@ -21,22 +22,7 @@ class _AssenzeRouteState extends State<AssenzeRoute> {
for (var assenza in listaAssenze) {
widgetsAssenze.add(Padding(
padding: EdgeInsets.only(left: 5, top: 5),
child: Card(
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
ListTile(
title: Text(assenza['assenza'] +
(assenza['giustificata'] == true
? ''
: ' (da giustificare)')),
subtitle: Text(assenza['prof']),
leading: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon((assenza['giustificata'] == true
? Icons.assignment_turned_in
: Icons.assignment_late))
]))
]))));
child: widgetAssenza(assenza)));
}
return BackdropScaffold(
title: Text('Assenze'),
Expand Down
49 changes: 49 additions & 0 deletions lib/bacheca.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import 'package:backdrop/backdrop.dart';
import 'backdropWidgets.dart';
import 'api.dart';
import 'widgets.dart';

class BachecaRoute extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _BachecaRouteState();
}
}

class _BachecaRouteState extends State<BachecaRoute> {
List listaBacheca = [];
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
new GlobalKey<RefreshIndicatorState>();

@override
Widget build(BuildContext context) {
var widgetsBacheca = <Widget>[];
for (var elemento in listaBacheca) {
widgetsBacheca.add(Padding(
padding: EdgeInsets.only(left: 5, top: 5),
child: widgetBacheca(elemento)));
}
return BackdropScaffold(
title: Text('Bacheca'),
backLayer: getBackdrop(context),
frontLayer: RefreshIndicator(
key: _refreshIndicatorKey,
onRefresh: aggiornaBacheca,
child: ListView(
children: new List.from(<Widget>[])..addAll(widgetsBacheca))));
}

Future aggiornaBacheca() async {
var nuovaBacheca = await bacheca();
setState(() {
listaBacheca = nuovaBacheca;
});
}

void initState() {
super.initState();
WidgetsBinding.instance
.addPostFrameCallback((_) => _refreshIndicatorKey.currentState.show());
}
}
Loading

0 comments on commit 74995f4

Please sign in to comment.