Made the populated drawer in the events screen use the data from the firebase user object

This commit is contained in:
Mariano Uvalle 2019-04-24 15:48:33 -05:00
parent 57ffb7dd5c
commit 118bb26713

View file

@ -1,12 +1,34 @@
import 'package:flutter/material.dart' hide AppBar;
import '../blocs/events_bloc.dart';
import '../widgets/app_bar.dart';
import '../widgets/populated_drawer.dart';
class EventsScreen extends StatelessWidget {
class EventsScreen extends StatefulWidget {
@override
_EventsScreenState createState() => _EventsScreenState();
}
class _EventsScreenState extends State<EventsScreen> {
/// An instance of the bloc for this screen.
final EventsBloc bloc = EventsBloc();
Widget build(BuildContext context) {
return StreamBuilder(
stream: bloc.userStream,
builder: (context, AsyncSnapshot<FirebaseUser> userSnap) {
String userAvatarUrl, userDisplayName = '', userEmail = '';
if (userSnap.hasData) {
userAvatarUrl = userSnap.data.photoUrl;
userDisplayName = userSnap.data.displayName;
userEmail = userSnap.data.email;
}
return Scaffold(
drawer: PopulatedDrawer(
userAvatarUrl: userAvatarUrl,
userDisplayName: userDisplayName,
userEmail: userEmail,
selectedScreen: Screen.events,
),
appBar: AppBar(
@ -14,5 +36,7 @@ class EventsScreen extends StatelessWidget {
hasDrawer: true,
),
);
},
);
}
}