Skip to content

Commit

Permalink
Fix connectivity issue & empty list placeholder (#29)
Browse files Browse the repository at this point in the history
* Increase connect timeout for slow responses

* Add placeholder for no selected favorites
  • Loading branch information
din0s authored May 8, 2020
1 parent 9ebe0df commit 1e1848c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib/DataFetcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DataFetcher {

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

Expand Down
53 changes: 31 additions & 22 deletions lib/pages/user_profile/UserProfile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class UserProfile extends AbstractPage {
}

class _UserProfileState extends PageState<UserProfile> {
List<Container> _none = [Container(child: Text("None."))];

@override
Widget body(GlobalKey<ScaffoldState> scfKey) {
return Column(
Expand Down Expand Up @@ -98,37 +100,44 @@ class _UserProfileState extends PageState<UserProfile> {
}

Container _buildFavSubjects() {
var subjects = widget.userData.favSubjects.isEmpty
? _none
: widget.userData.favSubjects
.map((String subj) => Container(
child: StyledText(subj),
padding: EdgeInsets.all(5),
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
border: Border.all(color: Colors.blue),
borderRadius: BorderRadius.all(Radius.circular(5)),
),
))
.toList();

return ItemContainer(
title: "Favorite Subjects",
color: Colors.lightBlue.withOpacity(0.1),
items: widget.userData.favSubjects
.map((String subj) => Container(
child: StyledText(subj),
padding: EdgeInsets.all(5),
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
border: Border.all(color: Colors.blue),
borderRadius: BorderRadius.all(Radius.circular(5)),
),
))
.toList(),
items: subjects,
);
}

Container _buildFavTeachers() {
var teachers = widget.userData.favTeachers.isEmpty
? _none
: widget.userData.favTeachers
.map((String subj) => Container(
child: StyledText(subj),
padding: EdgeInsets.all(5),
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.all(Radius.circular(5)),
),
))
.toList();
return ItemContainer(
title: "Favorite Teachers",
items: widget.userData.favTeachers
.map((String subj) => Container(
child: StyledText(subj),
padding: EdgeInsets.all(5),
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.all(Radius.circular(5)),
),
))
.toList(),
items: teachers,
);
}

Expand Down

0 comments on commit 1e1848c

Please sign in to comment.