Skip to content

Commit

Permalink
[EventPage] add list of bodies; add event description; still needs wo…
Browse files Browse the repository at this point in the history
…rk on AppBar;
  • Loading branch information
tastelessjolt committed Dec 20, 2018
1 parent b681dd5 commit bf53fe4
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 37 deletions.
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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 {
switch (settings.name) {
case "/": return _buildRoute(settings, LoginPage());
Expand Down
5 changes: 5 additions & 0 deletions lib/src/blocs/ia_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:InstiApp/src/api/model/body.dart';
import 'package:InstiApp/src/api/model/event.dart';
import 'package:InstiApp/src/blocs/training_bloc.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -70,6 +71,10 @@ class InstiAppBloc {
return _events?.firstWhere((event) => event.eventID == uuid);
}

Body getBody(String uuid) {
// return Body();
}

void updateSession(Session sess) {
currSession = sess;
_sessionSubject.add(sess);
Expand Down
178 changes: 141 additions & 37 deletions lib/src/routes/eventpage.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:InstiApp/src/api/model/body.dart';
import 'package:InstiApp/src/api/model/event.dart';
import 'package:InstiApp/src/bloc_provider.dart';
import 'package:InstiApp/src/blocs/ia_bloc.dart';
Expand Down Expand Up @@ -29,12 +30,11 @@ class _EventPageState extends State<EventPage> {
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
leading: Container(
decoration: ShapeDecoration(
shape: BeveledRectangleBorder(
borderRadius:
BorderRadius.only(bottomRight: Radius.circular(15))),
color: theme.accentColor),
leading: Material(
shape: BeveledRectangleBorder(
borderRadius:
BorderRadius.only(bottomRight: Radius.circular(15))),
color: theme.accentColor,
child: IconButton(
icon: Icon(
OMIcons.menu,
Expand All @@ -45,50 +45,153 @@ class _EventPageState extends State<EventPage> {
},
),
),
actions: <Widget>[
Material(
shape: BeveledRectangleBorder(
borderRadius:
BorderRadius.only(bottomLeft: Radius.circular(15))),
color: theme.accentColor,
child: IconButton(
tooltip: "Opens website",
icon: Icon(OMIcons.language),
onPressed: () {},
),
),
Material(
color: theme.accentColor,
child: IconButton(
tooltip: "Navigate to event",
icon: Icon(OMIcons.navigation),
onPressed: () {},
),
),
Material(
color: theme.accentColor,
child: IconButton(
tooltip: "Share",
icon: Icon(OMIcons.share),
onPressed: () {},
),
),
],
expandedHeight: 300,
floating: false,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Container(
width: MediaQuery.of(context).size.width * 0.65,
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
color: Color.fromRGBO(0, 0, 0, 0.2),
child: Text(
widget.event?.eventName,
)),
background: Image.network(
widget.event?.eventImageURL ??
widget.event?.eventBodies[0].imageUrl,
fit: BoxFit.fitWidth),
centerTitle: false,
title: Text(
widget.event?.eventName,
),
// title: Placeholder(),
// title: Container(
// width: MediaQuery.of(context).size.width * 0.65,
// padding:
// const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
// color: Color.fromRGBO(0, 0, 0, 0.2),
// child: Text(
// widget.event?.eventName,
// )),
// title: Row(
// mainAxisAlignment: MainAxisAlignment.start,
// children: <Widget>,
// ),
// background: Image.network(
// widget.event?.eventImageURL ??
// widget.event?.eventBodies[0].imageUrl,
// fit: BoxFit.fitWidth),
background: Stack(
fit: StackFit.expand,
children: <Widget>[
Image.network(
widget.event?.eventImageURL ??
widget.event?.eventBodies[0].imageUrl,
fit: BoxFit.fitWidth),
// This gradient ensures that the toolbar icons are distinct
// against the background image.
const DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment(0.0, -1.0),
end: Alignment(0.0, -0.4),
colors: <Color>[Color(0x60000000), Color(0x00000000)],
),
),
),
],
),
),
),
SliverToBoxAdapter(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ButtonBar(
mainAxisSize: MainAxisSize.max,
alignment: MainAxisAlignment.center,
children: <Widget>[
buildUserStatusButton("Going", 2, theme, bloc),
buildUserStatusButton("Interested", 1, theme, bloc),
],
),
SizedBox(height: 16.0,),

],
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Center(
child: Text(
widget.event?.getSubTitle(),
style: theme.textTheme.title,
),
),
ButtonBar(
mainAxisSize: MainAxisSize.max,
alignment: MainAxisAlignment.center,
children: <Widget>[
buildUserStatusButton("Going", 2, theme, bloc),
buildUserStatusButton("Interested", 1, theme, bloc),
],
),
SizedBox(
height: 16.0,
),
Text(
widget.event?.eventDescription,
style: theme.textTheme.subhead,
),
SizedBox(
height: 16.0,
),
Divider(),
],
),
),
),
SliverList(
delegate: SliverChildListDelegate(
widget.event.eventBodies
.map((b) => _buildBodyTile(b, theme.textTheme))
.toList(),
),
)
),
],
),
);
}

RaisedButton buildUserStatusButton(String name, int id, ThemeData theme, InstiAppBloc bloc) {
Widget _buildBodyTile(Body body, TextTheme theme) {
return ListTile(
title: Text(body.name, style: theme.title),
subtitle: Text(body.shortDescription, style: theme.subtitle),
leading: CircleAvatar(
radius: 24,
backgroundImage: NetworkImage(body.imageUrl),
),
onTap: () {
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("Body page is still in progress"),
));
// TODO: BodyPage
// Navigator.of(context).pushNamed("/body/${body.id}");
},
);
}

RaisedButton buildUserStatusButton(
String name, int id, ThemeData theme, InstiAppBloc bloc) {
return RaisedButton(
color: widget.event?.eventUserUes == id ? theme.accentColor : Colors.white,
color:
widget.event?.eventUserUes == id ? theme.accentColor : Colors.white,
textColor: widget.event?.eventUserUes == id ? Colors.white : null,
shape: RoundedRectangleBorder(
side: BorderSide(
Expand All @@ -101,7 +204,8 @@ class _EventPageState extends State<EventPage> {
SizedBox(
width: 8.0,
),
Text("${id == 1 ? widget.event?.eventInterestedCount : widget.event?.eventGoingCount}"),
Text(
"${id == 1 ? widget.event?.eventInterestedCount : widget.event?.eventGoingCount}"),
];
if (loadingUes == id) {
rowChildren.insertAll(0, [
Expand Down

0 comments on commit bf53fe4

Please sign in to comment.