@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
33import 'package:package_info/package_info.dart' ;
44import 'package:intl/intl.dart' ;
55
6+ import 'package:rxdart/rxdart.dart' ;
7+
68import 'package:utopian_rocks/components/list_page.dart' ;
79import 'package:utopian_rocks/components/drawer.dart' ;
810
@@ -14,6 +16,7 @@ import 'package:utopian_rocks/blocs/information_bloc.dart';
1416import 'package:utopian_rocks/providers/information_provider.dart' ;
1517import 'package:utopian_rocks/model/htmlParser.dart' ;
1618import 'package:utopian_rocks/model/githubApi.dart' ;
19+ import 'package:utopian_rocks/utils/utils.dart' ;
1720
1821void main () => runApp (MyApp ());
1922
@@ -43,6 +46,7 @@ class RootApp extends StatelessWidget {
4346 @override
4447 Widget build (BuildContext context) {
4548 final informationBloc = InformationProvider .of (context);
49+ final contributionBloc = ContributionProvider .of (context);
4650 return MaterialApp (
4751 // Remove Debug flag to allow app to be production ready.
4852 debugShowCheckedModeBanner: false ,
@@ -78,6 +82,7 @@ class RootApp extends StatelessWidget {
7882 ),
7983 ],
8084 ),
85+
8186 // Add [TabBar] to the [AppBar] to allow the user to navigate from one page to the next.
8287 bottom: TabBar (
8388 tabs: < Widget > [
@@ -98,39 +103,67 @@ class RootApp extends StatelessWidget {
98103 ListPage ('pending' ),
99104 ],
100105 ),
101- bottomNavigationBar: _buildBottonSheet (context),
106+ bottomNavigationBar:
107+ _buildBottonSheet (context, contributionBloc),
102108 endDrawer: InformationDrawer (snapshot),
103109 ),
104110 ),
105111 ),
106112 );
107113 }
108114
109- Widget _buildBottonSheet (BuildContext context) {
110- final contributionBloc = ContributionProvider .of (context);
111-
115+ Widget _buildBottonSheet (
116+ BuildContext context,
117+ ContributionBloc contributionBloc,
118+ ) {
112119 return StreamBuilder (
113120 stream: contributionBloc.voteCount,
114121 builder: (context, votecountSnapshot) => BottomAppBar (
115- color: Color (0xff26A69A ),
116- child: Row (
117- children: [
118- StreamBuilder (
119- stream: contributionBloc.timer,
120- builder: (context, timerSnapshot) {
121- return Text (
122- 'Next Vote Cycle: ${DateFormat .Hms ().format (DateTime (0 , 0 , 0 , 0 , 0 , timerSnapshot .data ?? 0 ))} ' ,
123- style: TextStyle (fontWeight: FontWeight .w700),
124- );
125- }),
126- Text (
127- 'Vote Power: ${double .parse (votecountSnapshot .data ?? '0.0' ).toStringAsPrecision (4 )}' ,
128- style: TextStyle (fontWeight: FontWeight .w700),
122+ color: Color (0xff26A69A ),
123+ child: Row (
124+ children: [
125+ StreamBuilder (
126+ stream: contributionBloc.timer,
127+ builder: (context, timerSnapshot) {
128+ return Text (
129+ 'Next Vote Cycle: ${DateFormat .Hms ().format (DateTime (0 , 0 , 0 , 0 , 0 , timerSnapshot .data ?? 0 ))} ' ,
130+ style: TextStyle (fontWeight: FontWeight .w700),
131+ );
132+ }),
133+ Text (
134+ 'Vote Power: ${double .parse (votecountSnapshot .data ?? '0.0' ).toStringAsPrecision (4 )}' ,
135+ style: TextStyle (fontWeight: FontWeight .w700),
136+ ),
137+ _generateMenu (categories, contributionBloc),
138+ ],
139+ mainAxisAlignment: MainAxisAlignment .spaceEvenly,
140+ crossAxisAlignment: CrossAxisAlignment .center,
141+ )));
142+ }
143+
144+ Widget _generateMenu (
145+ List <String > categories,
146+ ContributionBloc bloc,
147+ ) {
148+ return PopupMenuButton <String >(
149+ tooltip: 'Filter Contribution Categories' ,
150+ onSelected: (category) => bloc.filter.add (category),
151+ itemBuilder: (context) => categories
152+ .map ((cate) => PopupMenuItem (
153+ height: 40.0 ,
154+ value: cate,
155+ child: ListTile (
156+ leading: Icon (
157+ IconData (
158+ icons[cate],
159+ fontFamily: 'Utopicons' ,
160+ ),
161+ color: colors[cate],
129162 ),
130- ] ,
131- mainAxisAlignment : MainAxisAlignment .spaceEvenly ,
132- crossAxisAlignment : CrossAxisAlignment .center,
133- ),
134- ) );
163+ title : Text (cate) ,
164+ ) ,
165+ ))
166+ . toList ( ),
167+ );
135168 }
136169}
0 commit comments