Skip to content

Commit a1e938d

Browse files
author
Netfloex
committed
Overal herladen waar nodig, meer EmptyPages
1 parent 7bfbe53 commit a1e938d

File tree

10 files changed

+193
-266
lines changed

10 files changed

+193
-266
lines changed

lib/src/ui/CustomWidgets.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,8 @@ Widget buildLiveList(list, loaded) {
634634
return LiveList.options(
635635
itemCount: list.length,
636636
options: options,
637+
shrinkWrap: true,
638+
physics: ScrollPhysics(),
637639
itemBuilder: (
638640
BuildContext context,
639641
int index,
@@ -670,8 +672,8 @@ class EmptyPage extends StatelessWidget {
670672
@override
671673
Widget build(BuildContext context) {
672674
return Container(
675+
width: double.infinity,
673676
height: bodyHeight(context),
674-
width: MediaQuery.of(context).size.width,
675677
child: Column(
676678
mainAxisAlignment: MainAxisAlignment.center,
677679
crossAxisAlignment: CrossAxisAlignment.center,

lib/src/ui/tabs/Afwezigheid.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ class _Afwezigheid extends State<Afwezigheid> with AfterLayoutMixin<Afwezigheid>
5757
),
5858
],
5959
body: RefreshIndicator(
60-
child: ValueListenableBuilder(
60+
child: SingleChildScrollView(
61+
physics: AlwaysScrollableScrollPhysics(),
62+
child: ValueListenableBuilder(
6163
valueListenable: updateNotifier,
6264
builder: (BuildContext context, _, _a) {
6365
if (account.afwezigheid.isEmpty)
@@ -136,7 +138,9 @@ class _Afwezigheid extends State<Afwezigheid> with AfterLayoutMixin<Afwezigheid>
136138
lastDay = afw.dag;
137139
}
138140
return buildLiveList(absenties, 10);
139-
}),
141+
},
142+
),
143+
),
140144
onRefresh: () async {
141145
await handleError(account.magister.afwezigheid.refresh, "Fout tijdens verversen van afwezigheid", context);
142146
},

lib/src/ui/tabs/Berichten.dart

Lines changed: 88 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -34,89 +34,92 @@ class _Berichten extends State<Berichten> with AfterLayoutMixin<Berichten> {
3434
),
3535
],
3636
body: RefreshIndicator(
37-
child: ValueListenableBuilder(
38-
valueListenable: updateNotifier,
39-
builder: (BuildContext context, box, Widget child) {
40-
List<Widget> berichten = [];
41-
String lastDay;
42-
if (account.berichten.isEmpty) {
43-
return EmptyPage(
44-
text: "Geen berichten",
45-
icon: Icons.email_outlined,
46-
);
47-
}
48-
for (int i = 0; i < account.berichten.length; i++) {
49-
ValueNotifier<Bericht> ber = ValueNotifier(account.berichten[i]);
50-
if (lastDay != ber.value.dag) {
51-
berichten.add(
52-
ContentHeader(ber.value.dag),
37+
child: SingleChildScrollView(
38+
physics: AlwaysScrollableScrollPhysics(),
39+
child: ValueListenableBuilder(
40+
valueListenable: updateNotifier,
41+
builder: (BuildContext context, box, Widget child) {
42+
List<Widget> berichten = [];
43+
String lastDay;
44+
if (account.berichten.isEmpty) {
45+
return EmptyPage(
46+
text: "Geen berichten",
47+
icon: Icons.email_outlined,
5348
);
5449
}
55-
berichten.add(
56-
SeeCard(
57-
border: account.berichten.length - 1 == i || account.berichten[i + 1].dag != ber.value.dag
58-
? null
59-
: Border(
60-
bottom: greyBorderSide(),
61-
),
62-
child: Stack(
63-
children: [
64-
ValueListenableBuilder(
65-
valueListenable: ber,
66-
builder: (c, ber, _) {
67-
if (ber.read)
68-
return Container();
69-
else
70-
return Padding(
71-
child: Align(
72-
alignment: Alignment.topRight,
73-
child: Container(
74-
width: 10,
75-
height: 10,
76-
decoration: BoxDecoration(
77-
shape: BoxShape.circle,
78-
color: userdata.get("accentColor"),
50+
for (int i = 0; i < account.berichten.length; i++) {
51+
ValueNotifier<Bericht> ber = ValueNotifier(account.berichten[i]);
52+
if (lastDay != ber.value.dag) {
53+
berichten.add(
54+
ContentHeader(ber.value.dag),
55+
);
56+
}
57+
berichten.add(
58+
SeeCard(
59+
border: account.berichten.length - 1 == i || account.berichten[i + 1].dag != ber.value.dag
60+
? null
61+
: Border(
62+
bottom: greyBorderSide(),
63+
),
64+
child: Stack(
65+
children: [
66+
ValueListenableBuilder(
67+
valueListenable: ber,
68+
builder: (c, ber, _) {
69+
if (ber.read)
70+
return Container();
71+
else
72+
return Padding(
73+
child: Align(
74+
alignment: Alignment.topRight,
75+
child: Container(
76+
width: 10,
77+
height: 10,
78+
decoration: BoxDecoration(
79+
shape: BoxShape.circle,
80+
color: userdata.get("accentColor"),
81+
),
7982
),
8083
),
81-
),
82-
padding: EdgeInsets.all(
83-
10,
84+
padding: EdgeInsets.all(
85+
10,
86+
),
87+
);
88+
},
89+
),
90+
ListTile(
91+
trailing: Padding(
92+
child: ber.value.prioriteit ? Icon(Icons.error, color: Colors.redAccent) : null,
93+
padding: EdgeInsets.only(
94+
top: 7,
95+
left: 7,
96+
),
97+
),
98+
subtitle: Text(
99+
ber.value.afzender,
100+
),
101+
title: Text(
102+
ber.value.onderwerp,
103+
overflow: TextOverflow.ellipsis,
104+
maxLines: 1,
105+
),
106+
onTap: () {
107+
Navigator.of(context).push(
108+
MaterialPageRoute(
109+
builder: (context) => BerichtPagina(ber),
84110
),
85111
);
86-
},
87-
),
88-
ListTile(
89-
trailing: Padding(
90-
child: ber.value.prioriteit ? Icon(Icons.error, color: Colors.redAccent) : null,
91-
padding: EdgeInsets.only(
92-
top: 7,
93-
left: 7,
94-
),
95-
),
96-
subtitle: Text(
97-
ber.value.afzender,
98-
),
99-
title: Text(
100-
ber.value.onderwerp,
101-
overflow: TextOverflow.ellipsis,
102-
maxLines: 1,
112+
},
103113
),
104-
onTap: () {
105-
Navigator.of(context).push(
106-
MaterialPageRoute(
107-
builder: (context) => BerichtPagina(ber),
108-
),
109-
);
110-
},
111-
),
112-
],
114+
],
115+
),
113116
),
114-
),
115-
);
116-
lastDay = ber.value.dag;
117-
}
118-
return buildLiveList(berichten, 10);
119-
},
117+
);
118+
lastDay = ber.value.dag;
119+
}
120+
return buildLiveList(berichten, 10);
121+
},
122+
),
120123
),
121124
onRefresh: () async {
122125
await handleError(account.magister.berichten.refresh, "Kon berichten niet verversen", context);
@@ -176,30 +179,17 @@ class BerichtPagina extends StatelessWidget {
176179
onError: (error, retry) {
177180
if (!(error is DioError)) throw (error);
178181
},
179-
errorBuilder: (context, error, retry) {
180-
if (!(error is DioError))
181-
return Text("Dit zou je nooit moeten zien, error: \n\n $error");
182-
else
183-
return RefreshIndicator(
184-
onRefresh: () async => retry(),
185-
child: SingleChildScrollView(
186-
physics: AlwaysScrollableScrollPhysics(),
187-
child: Center(
188-
child: Container(
189-
width: MediaQuery.of(context).size.width - 50,
190-
height: bodyHeight(context),
191-
child: Text(
192-
"Kon geen verbinding maken met Magister:\n${(error as dynamic).error.toString()}",
193-
style: TextStyle(
194-
color: Colors.grey,
195-
fontSize: 20,
196-
),
197-
textAlign: TextAlign.center,
198-
),
199-
),
200-
),
182+
errorBuilder: (context, dynamic error, retry) {
183+
return RefreshIndicator(
184+
onRefresh: () async => retry(),
185+
child: SingleChildScrollView(
186+
physics: AlwaysScrollableScrollPhysics(),
187+
child: EmptyPage(
188+
icon: Icons.wifi_off_outlined,
189+
text: error?.error ?? error?.toString() ?? error.message ?? error,
201190
),
202-
);
191+
),
192+
);
203193
},
204194
dataBuilder: (context, data) {
205195
Bericht ber = data[0];

lib/src/ui/tabs/Bronnen.dart

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -107,46 +107,27 @@ class _Bronnen extends State<Bronnen> with AfterLayoutMixin<Bronnen> {
107107
: null,
108108
onTap: () async {
109109
if (bron.isFolder) {
110-
breadcrumbs.add(
111-
bron.naam,
112-
);
113-
bronnenView.add(
114-
bron.children,
115-
);
116-
setState(
117-
() {},
118-
);
110+
breadcrumbs.add(bron.naam);
111+
bronnenView.add(bron.children);
112+
setState(() {});
119113
if (bron.children == null) {
120114
await handleError(
121115
() async => await account.magister.bronnen.loadChildren(bron),
122116
"Kon ${bron.naam} niet laden.",
123117
context,
124118
() {
125-
setState(
126-
() {},
127-
);
128-
bronnenView = bronnenView
129-
.where(
130-
(list) => list != null,
131-
)
132-
.toList();
133-
bronnenView.add(
134-
bron.children,
135-
);
119+
setState(() {});
120+
bronnenView = bronnenView.where((list) => list != null).toList();
121+
bronnenView.add(bron.children);
136122
},
137123
);
138124
}
139125
} else {
140-
account.magister.bronnen.downloadFile(
141-
bron,
142-
(count, total) {
143-
setState(
144-
() {
145-
bron.downloadCount = count;
146-
},
147-
);
148-
},
149-
);
126+
account.magister.bronnen.downloadFile(bron, (count, total) {
127+
setState(() {
128+
bron.downloadCount = count;
129+
});
130+
});
150131
}
151132
},
152133
),

lib/src/ui/tabs/Cijfers.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ class _Cijfers extends State<Cijfers> {
7474
),
7575
body: TabBarView(
7676
children: [
77-
if (jaar == 0) // Recenst
77+
if (jaar == 0) // Recente Cijfers
7878
RefreshIndicator(
7979
onRefresh: () async {
80-
await handleError(account.magister.cijfers.refresh, "Kon cijfers niet verversen", context);
80+
await handleError(account.magister.cijfers.recentCijfers, "Kon cijfers niet verversen", context);
8181
},
8282
child: SingleChildScrollView(
8383
physics: AlwaysScrollableScrollPhysics(),
@@ -103,9 +103,7 @@ class _Cijfers extends State<Cijfers> {
103103
),
104104
for (Periode periode in perioden)
105105
RefreshIndicator(
106-
onRefresh: () async {
107-
await handleError(account.magister.cijfers.refresh, "Kon cijfers niet verversen", context);
108-
},
106+
onRefresh: () async => await handleError(account.magister.cijfers.refresh, "Kon cijfers niet verversen", context),
109107
child: SingleChildScrollView(
110108
child: SeeCard(
111109
column: () {

0 commit comments

Comments
 (0)