Skip to content

Commit

Permalink
[App] add BodyPage; [EventPage, BodyPage] now takes Future and shows …
Browse files Browse the repository at this point in the history
…appropriate message;
  • Loading branch information
tastelessjolt committed Dec 24, 2018
1 parent 0d03829 commit cba37f8
Show file tree
Hide file tree
Showing 9 changed files with 414 additions and 136 deletions.
7 changes: 4 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:InstiApp/src/routes/bodypage.dart';
import 'package:InstiApp/src/routes/eventpage.dart';
import 'package:InstiApp/src/routes/feedpage.dart';
import 'package:InstiApp/src/routes/trainingblogpage.dart';
Expand Down Expand Up @@ -52,9 +53,9 @@ class MyAppState extends State<MyApp> {
if (settings.name.startsWith("/event/") ) {
return _buildRoute(settings, EventPage(_bloc.getEvent(settings.name.split("/event/")[1])));
}
// else if (settings.name.startsWith("/body/")) {
// return _buildRoute(settings, BodyPage(_bloc.getBody(settings.name.split("/body/")[1])));
// }
else if (settings.name.startsWith("/body/")) {
return _buildRoute(settings, BodyPage(_bloc.getBody(settings.name.split("/body/")[1])));
}
else {
switch (settings.name) {
case "/": return _buildRoute(settings, LoginPage());
Expand Down
49 changes: 37 additions & 12 deletions lib/src/api/model/body.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
import 'package:InstiApp/src/api/model/event.dart';
import 'package:InstiApp/src/api/model/role.dart';
import 'package:jaguar_serializer/jaguar_serializer.dart';

part 'body.jser.dart';

class Body {
String id;
@Alias("id")
String bodyID;

@Alias('str_id')
String strId;
@Alias("str_id")
String bodyStrID;

String name;
@Alias("name")
String bodyName;

@Alias('short_description')
String shortDescription;
@Alias("short_description")
String bodyShortDescription;

@Alias('website_url')
String websiteUrl;
@Alias("description")
String bodyDescription;

@Alias('image_url')
String imageUrl;
@Alias("image_url")
String bodyImageURL;

@Alias('cover_url')
String coverUrl;
@Alias("children")
List<Body> bodyChildren;

@Alias("parents")
List<Body> bodyParents;

@Alias("events")
List<Event> bodyEvents;

@Alias("followers_count")
int bodyFollowersCount;

@Alias("website_url")
String bodyWebsiteURL;

@Alias("blog_url")
String bodyBlogURL;

@Alias("user_follows")
bool bodyUserFollows;

@Alias("roles")
List<Role> bodyRoles;
}

@GenSerializer()
Expand Down
71 changes: 57 additions & 14 deletions lib/src/api/model/body.jser.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions lib/src/blocs/ia_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ class InstiAppBloc {
_eventsSubject.add(UnmodifiableListView(_events));
}

Event getEvent(String uuid) {
return _events?.firstWhere((event) => event.eventID == uuid);
Future<Event> getEvent(String uuid) async {
return _events?.firstWhere((event) => event.eventID == uuid) ?? client.getEvent(getSessionIdHeader(), uuid);
// return client.getEvent(getSessionIdHeader(), uuid);
}

Body getBody(String uuid) {
// return Body();
Future<Body> getBody(String uuid) async {
return client.getBody(getSessionIdHeader(), uuid);
}

void updateSession(Session sess) {
Expand Down
29 changes: 23 additions & 6 deletions lib/src/routes/blogpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,29 @@ class _BlogPageState extends State<BlogPage> {
},
);
} else {
return Center(
child: Text(
"You must be logged in to view ${widget.title}",
style: theme.textTheme.title,
textAlign: TextAlign.center,
),
return ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(28.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.title,
style: theme.textTheme.display2.copyWith(
color: Colors.black, fontFamily: "Bitter"),
),
],
),
),
Center(
child: Text(
"You must be logged in to view ${widget.title}",
style: theme.textTheme.title,
textAlign: TextAlign.center,
),
),
],
);
}
},
Expand Down
Loading

0 comments on commit cba37f8

Please sign in to comment.