diff --git a/lib/main.dart b/lib/main.dart index 80a192f0..06565721 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -52,6 +52,9 @@ class MyAppState extends State { 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()); diff --git a/lib/src/blocs/ia_bloc.dart b/lib/src/blocs/ia_bloc.dart index 518c3480..563c2f64 100644 --- a/lib/src/blocs/ia_bloc.dart +++ b/lib/src/blocs/ia_bloc.dart @@ -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'; @@ -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); diff --git a/lib/src/routes/eventpage.dart b/lib/src/routes/eventpage.dart index 02358476..685e1940 100644 --- a/lib/src/routes/eventpage.dart +++ b/lib/src/routes/eventpage.dart @@ -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'; @@ -29,12 +30,11 @@ class _EventPageState extends State { body: CustomScrollView( slivers: [ 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, @@ -45,50 +45,153 @@ class _EventPageState extends State { }, ), ), + actions: [ + 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: , + // ), + // background: Image.network( + // widget.event?.eventImageURL ?? + // widget.event?.eventBodies[0].imageUrl, + // fit: BoxFit.fitWidth), + background: Stack( + fit: StackFit.expand, + children: [ + 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(0x60000000), Color(0x00000000)], + ), + ), + ), + ], + ), ), ), SliverToBoxAdapter( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ButtonBar( - mainAxisSize: MainAxisSize.max, - alignment: MainAxisAlignment.center, - children: [ - 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: [ + Center( + child: Text( + widget.event?.getSubTitle(), + style: theme.textTheme.title, + ), + ), + ButtonBar( + mainAxisSize: MainAxisSize.max, + alignment: MainAxisAlignment.center, + children: [ + 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( @@ -101,7 +204,8 @@ class _EventPageState extends State { 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, [