Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

Commit 5f90c82

Browse files
Fixed annoying bug : grades weren't loaded
1 parent 6c1fdc7 commit 5f90c82

File tree

4 files changed

+68
-57
lines changed

4 files changed

+68
-57
lines changed

lib/UI/components/giffy_dialog/src/base_dialog.dart

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,26 @@ class _BaseGiffyDialogState extends State<BaseGiffyDialog> with TickerProviderSt
137137
),
138138
),
139139
Expanded(
140-
child: SingleChildScrollView(
141-
child: Column(
142-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
143-
children: <Widget>[
144-
Padding(
145-
padding: const EdgeInsets.only(top: 16.0),
146-
child: widget.title,
147-
),
148-
Container(
149-
height:120,
150-
child: Padding(
151-
padding: const EdgeInsets.only(top:8.0,left:8.0,right:8.0,),
152-
child: CupertinoScrollbar(child: SingleChildScrollView(child: widget.description)),
140+
child: CupertinoScrollbar(
141+
child: SingleChildScrollView(
142+
child: Column(
143+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
144+
children: <Widget>[
145+
Padding(
146+
padding: const EdgeInsets.only(top: 16.0),
147+
child: widget.title,
153148
),
154-
),
155-
_buildButtonsBar(context)
156-
],
157-
),
149+
Container(
150+
height:120,
151+
child: Padding(
152+
padding: const EdgeInsets.only(top:8.0,left:8.0,right:8.0,),
153+
child: CupertinoScrollbar(child: SingleChildScrollView(child: widget.description)),
154+
),
155+
),
156+
_buildButtonsBar(context)
157+
],
158+
),
159+
),
158160
),
159161
),
160162
],
@@ -195,39 +197,43 @@ class _BaseGiffyDialogState extends State<BaseGiffyDialog> with TickerProviderSt
195197
}
196198

197199
Widget _buildButtonsBar(BuildContext context) {
198-
return Padding(
199-
padding: const EdgeInsets.only(top:8.0,left:8.0,right:8.0,),
200-
child: Row(
201-
mainAxisAlignment:
202-
!widget.onlyOkButton ? MainAxisAlignment.spaceEvenly : MainAxisAlignment.center,
203-
children: <Widget>[
204-
if (!widget.onlyOkButton) ...[
205-
RaisedButton(
206-
color: widget.buttonCancelColor,
207-
shape:
208-
RoundedRectangleBorder(borderRadius: BorderRadius.circular(widget.buttonRadius)),
209-
onPressed: widget.onCancelButtonPressed ?? () => Navigator.of(context).pop(),
210-
child: widget.buttonCancelText ??
211-
Text(
212-
'Cancel',
213-
style: TextStyle(color: Colors.white),
214-
),
215-
)
216-
],
217-
if (!widget.onlyCancelButton) ...[
218-
RaisedButton(
219-
color: widget.buttonOkColor,
220-
shape:
221-
RoundedRectangleBorder(borderRadius: BorderRadius.circular(widget.buttonRadius)),
222-
onPressed: widget.onOkButtonPressed,
223-
child: widget.buttonOkText ??
224-
Text(
225-
'OK',
226-
style: TextStyle(color: Colors.white),
227-
),
228-
),
200+
return FittedBox(
201+
child: Padding(
202+
padding: const EdgeInsets.only(top:8.0,left:8.0,right:8.0,),
203+
child: Row(
204+
mainAxisAlignment:
205+
MainAxisAlignment.center,
206+
children: <Widget>[
207+
if (!widget.onlyOkButton) ...[
208+
RaisedButton(
209+
color: widget.buttonCancelColor,
210+
shape:
211+
RoundedRectangleBorder(borderRadius: BorderRadius.circular(widget.buttonRadius)),
212+
onPressed: widget.onCancelButtonPressed ?? () => Navigator.of(context).pop(),
213+
child: widget.buttonCancelText ??
214+
Text(
215+
'Cancel',
216+
style: TextStyle(color: Colors.white),
217+
),
218+
)
219+
],
220+
if(!widget.onlyOkButton)
221+
SizedBox(width: 15,),
222+
if (!widget.onlyCancelButton) ...[
223+
RaisedButton(
224+
color: widget.buttonOkColor,
225+
shape:
226+
RoundedRectangleBorder(borderRadius: BorderRadius.circular(widget.buttonRadius)),
227+
onPressed: widget.onOkButtonPressed,
228+
child: widget.buttonOkText ??
229+
Text(
230+
'OK',
231+
style: TextStyle(color: Colors.white),
232+
),
233+
),
234+
],
229235
],
230-
],
236+
),
231237
),
232238
);
233239
}

lib/offline.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import 'package:ynotes/UI/utils/fileUtils.dart';
66

77
class Offline {
88
//Return disciplines + grades
9-
List<Discipline> disciplinesData= List();
9+
List<Discipline> disciplinesData;
1010
//Return homework
11-
List<Homework> homeworkData= List();
11+
List<Homework> homeworkData;
1212

1313
Box _offlineBox;
1414
Box _homeworkDoneBox;
@@ -33,6 +33,7 @@ class Offline {
3333
_offlineBox = await Hive.openBox("offlineData");
3434
}
3535
//Get data and cast it
36+
3637
disciplinesData = _offlineBox.get("disciplines").cast<Discipline>();
3738
homeworkData = _offlineBox.get("homework").cast<Homework>();
3839

@@ -149,12 +150,10 @@ class Offline {
149150
Future<List<Homework>> homework() async {
150151
try {
151152
if (homeworkData != null) {
152-
153153
return homeworkData;
154154
} else {
155-
156155
await refreshData();
157-
156+
158157
return homeworkData;
159158
}
160159
} catch (e) {

lib/parsers/Pronote.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ class APIPronote extends API {
5454
} else {
5555
print("Loading grades inline.");
5656
var toReturn = await getGradesFromInternet();
57+
if (toReturn == null) {
58+
toReturn = await offline.disciplines();
59+
}
5760
await refreshDisciplinesListColors(toReturn);
5861
return toReturn;
5962
}
@@ -104,7 +107,7 @@ class APIPronote extends API {
104107
z++;
105108
});
106109
}
107-
this.gradesList =null;
110+
this.gradesList = null;
108111
listDisciplines.forEach((element) {
109112
element.gradesList
110113
.addAll(grades.where((grade) => grade.libelleMatiere == element.nomDiscipline));
@@ -190,11 +193,14 @@ class APIPronote extends API {
190193
forceReload == null) &&
191194
offlineHomework != null) {
192195
print("Loading homework from offline storage.");
193-
196+
194197
return offlineHomework;
195198
} else {
196199
print("Loading homework inline.");
197200
var toReturn = await getNextHomeworkFromInternet();
201+
if (toReturn == null) {
202+
toReturn = await offline.homework();
203+
}
198204
return toReturn;
199205
}
200206
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ description: yNotes application de gestion de vie scolaire
1212
# Read more about iOS versioning at
1313
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.
1414

15-
version: 0.8.8+3
15+
version: 0.8.8+4
1616

1717
environment:
1818
sdk: ">=2.2.2 <3.0.0"

0 commit comments

Comments
 (0)