Events screen now shows the events linked to the user

This commit is contained in:
Mariano Uvalle 2019-04-26 21:14:52 -05:00
parent 2b1ac6d48c
commit dfe52b77ef
4 changed files with 47 additions and 43 deletions

View file

@ -304,7 +304,7 @@
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
"${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (

View file

@ -22,6 +22,9 @@ class EventsBloc {
/// An observable of the current logged in user.
Observable<FirebaseUser> get userStream => _auth.userStream;
/// An observable of the events linked to the current user.
Observable<List<EventModel>> get events => _events.stream;
/// Initiates the fetching process of events linked to the current user.
Future<void> fetchEvents() async {
final userModel = await _auth.getCurrentUserModel();

View file

@ -4,6 +4,7 @@ import '../blocs/events_bloc.dart';
import '../models/event_model.dart';
import '../widgets/app_bar.dart';
import '../widgets/event_list_tile.dart';
import '../widgets/loading_indicator.dart';
import '../widgets/populated_drawer.dart';
class EventsScreen extends StatefulWidget {
@ -15,6 +16,11 @@ class _EventsScreenState extends State<EventsScreen> {
/// An instance of the bloc for this screen.
final EventsBloc bloc = EventsBloc();
initState() {
super.initState();
bloc.fetchEvents();
}
Widget build(BuildContext context) {
return StreamBuilder(
stream: bloc.userStream,
@ -38,28 +44,28 @@ class _EventsScreenState extends State<EventsScreen> {
title: 'My Events',
hasDrawer: true,
),
body: ListView(
body: StreamBuilder(
stream: bloc.events,
builder: (context, AsyncSnapshot<List<EventModel>> eventsSnap) {
if (!eventsSnap.hasData) {
return Center(
child: LoadingIndicator(),
);
}
return ListView(
padding: EdgeInsets.only(top: 15),
children: <Widget>[
EventListTile(
event: EventModel(
id: '1',
name: 'Math',
pendigTasks: 3,
media: <String>[],
when: <bool>[
true,
true,
false,
false,
true,
],
highPriority: 2,
mediumPriority: 1,
lowPriority: 0,
children: eventsSnap.data
.map(
(event) => Padding(
padding: EdgeInsets.only(bottom: 15),
child: EventListTile(
event: event,
),
),
)
],
.toList(),
);
},
),
);
},

View file

@ -36,29 +36,10 @@ class EventListTile extends StatelessWidget with Tile {
_OcurranceIdicator(ocurrance: event.when),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Row(
children: <Widget>[
SizedBox(
width: 80,
),
ActionButton(
color: Colors.white,
textColor: Colors.black,
text: 'Resources',
leadingIconData: FontAwesomeIcons.listAlt,
onPressed: () => Navigator.of(context)
.pushNamed('event/${event.name}'),
),
],
),
],
),
],
),
),
getResourcesButton(context),
getPriorityIndicator(),
getTasksIndicator(),
],
@ -68,6 +49,20 @@ class EventListTile extends StatelessWidget with Tile {
);
}
Widget getResourcesButton(BuildContext context) {
return Positioned(
bottom: 8,
right: 23,
child: ActionButton(
color: Colors.white,
textColor: Colors.black,
text: 'Resources',
leadingIconData: FontAwesomeIcons.listAlt,
onPressed: () => Navigator.of(context).pushNamed('event/${event.name}'),
),
);
}
Widget getPriorityIndicator() {
final color = getColorFromEvent(event);
return Row(