@@ -4,9 +4,8 @@ import 'package:utopian_rocks/utils/utils.dart';
44import 'package:timeago/timeago.dart' as timeago;
55import 'package:url_launcher/url_launcher.dart' ;
66
7- import 'package:intl/intl.dart' ;
8-
97import 'package:utopian_rocks/model/htmlParser.dart' ;
8+ import 'package:utopian_rocks/providers/information_provider.dart' ;
109
1110class ListPage extends StatelessWidget {
1211 final String tabname;
@@ -18,6 +17,7 @@ class ListPage extends StatelessWidget {
1817 // get block from [ContributionProvider] to add to [StreamBuilder]
1918 final bloc = ContributionProvider .of (context);
2019 final parseWebsite = ParseWebsite ();
20+ final infoBloc = InformationProvider .of (context);
2121 // Pass in the [tabname] or string which represents the page name.
2222 // Based on the string passed in, the stream will get different contributions.
2323 bloc.tabname.add (tabname);
@@ -35,31 +35,33 @@ class ListPage extends StatelessWidget {
3535 );
3636 }
3737
38- bloc.voteCount.listen ((vc) => showBottomSheet (
39- context: context,
40- builder: (context) {
41- return Container (
42- color: Color (0xff26A69A ),
43- child: Row (
44- children: [
45- StreamBuilder (
46- stream: bloc.timer,
47- builder: (context, timerSnapshot) {
48- return Text (
49- '~ Next Vote Cycle: ${DateFormat .Hms ().format (DateTime (0 , 0 , 0 , 0 , 0 , timerSnapshot .data ?? 0 ))} ' ,
50- style: TextStyle (fontWeight: FontWeight .w700),
51- );
52- }),
53- Text (
54- 'Vote Power: ${double .parse (vc .replaceAll ('\n ' , '' )).toStringAsPrecision (4 )}' ,
55- style: TextStyle (fontWeight: FontWeight .w700),
56- ),
57- ],
58- mainAxisAlignment: MainAxisAlignment .spaceEvenly,
59- crossAxisAlignment: CrossAxisAlignment .center,
60- ),
61- );
62- }));
38+ infoBloc.releases.listen ((releases) {
39+ infoBloc.infoStream.listen ((pkInfo) {
40+ print (pkInfo.version);
41+ print (releases.tagName);
42+ if (pkInfo.version.toString () != releases.tagName) {
43+ showDialog (
44+ context: context,
45+ builder: (BuildContext context) => AlertDialog (
46+ title: Text ('${pkInfo .appName }' ),
47+ content: Container (
48+ child: Text (
49+ 'A new version of this application is available to download. The current version is ${pkInfo .version } and the new version is ${releases .tagName }' ),
50+ ),
51+ actions: < Widget > [
52+ FlatButton (
53+ child: Text ('Download' ),
54+ onPressed: () => _launchUrl (releases.htmlUrl),
55+ ),
56+ FlatButton (
57+ child: Text ('Close' ),
58+ onPressed: () => Navigator .of (context).pop (),
59+ )
60+ ],
61+ ));
62+ }
63+ });
64+ });
6365
6466 // Generate [ListView] using the [AsyncSnapshot] from the [StreamBuilder]
6567 // [ListView] provides lazy loading and programmatically generates the Page.
0 commit comments