Skip to content

Commit 1e1848c

Browse files
authored
Fix connectivity issue & empty list placeholder (#29)
* Increase connect timeout for slow responses * Add placeholder for no selected favorites
1 parent 9ebe0df commit 1e1848c

2 files changed

Lines changed: 32 additions & 23 deletions

File tree

lib/DataFetcher.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DataFetcher {
2323

2424
static Dio dio = new Dio(new BaseOptions(
2525
baseUrl: "http://snf-872013.vm.okeanos.grnet.gr:3000/",
26-
connectTimeout: 5000,
26+
connectTimeout: 10000,
2727
receiveTimeout: 3000,
2828
));
2929

lib/pages/user_profile/UserProfile.dart

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class UserProfile extends AbstractPage {
3131
}
3232

3333
class _UserProfileState extends PageState<UserProfile> {
34+
List<Container> _none = [Container(child: Text("None."))];
35+
3436
@override
3537
Widget body(GlobalKey<ScaffoldState> scfKey) {
3638
return Column(
@@ -98,37 +100,44 @@ class _UserProfileState extends PageState<UserProfile> {
98100
}
99101

100102
Container _buildFavSubjects() {
103+
var subjects = widget.userData.favSubjects.isEmpty
104+
? _none
105+
: widget.userData.favSubjects
106+
.map((String subj) => Container(
107+
child: StyledText(subj),
108+
padding: EdgeInsets.all(5),
109+
margin: EdgeInsets.all(5),
110+
decoration: BoxDecoration(
111+
border: Border.all(color: Colors.blue),
112+
borderRadius: BorderRadius.all(Radius.circular(5)),
113+
),
114+
))
115+
.toList();
116+
101117
return ItemContainer(
102118
title: "Favorite Subjects",
103119
color: Colors.lightBlue.withOpacity(0.1),
104-
items: widget.userData.favSubjects
105-
.map((String subj) => Container(
106-
child: StyledText(subj),
107-
padding: EdgeInsets.all(5),
108-
margin: EdgeInsets.all(5),
109-
decoration: BoxDecoration(
110-
border: Border.all(color: Colors.blue),
111-
borderRadius: BorderRadius.all(Radius.circular(5)),
112-
),
113-
))
114-
.toList(),
120+
items: subjects,
115121
);
116122
}
117123

118124
Container _buildFavTeachers() {
125+
var teachers = widget.userData.favTeachers.isEmpty
126+
? _none
127+
: widget.userData.favTeachers
128+
.map((String subj) => Container(
129+
child: StyledText(subj),
130+
padding: EdgeInsets.all(5),
131+
margin: EdgeInsets.all(5),
132+
decoration: BoxDecoration(
133+
border: Border.all(color: Colors.grey),
134+
borderRadius: BorderRadius.all(Radius.circular(5)),
135+
),
136+
))
137+
.toList();
119138
return ItemContainer(
120139
title: "Favorite Teachers",
121-
items: widget.userData.favTeachers
122-
.map((String subj) => Container(
123-
child: StyledText(subj),
124-
padding: EdgeInsets.all(5),
125-
margin: EdgeInsets.all(5),
126-
decoration: BoxDecoration(
127-
border: Border.all(color: Colors.grey),
128-
borderRadius: BorderRadius.all(Radius.circular(5)),
129-
),
130-
))
131-
.toList(),
140+
items: teachers,
132141
);
133142
}
134143

0 commit comments

Comments
 (0)