1
1
import 'package:flutter/material.dart' ;
2
2
import 'package:provider/provider.dart' ;
3
+ import 'package:underdog/data/models/stats.dart' ;
3
4
import 'package:underdog/underdog_theme.dart' ;
4
5
import 'package:underdog/viewmodels/home_model.dart' ;
5
6
@@ -8,16 +9,15 @@ class StatsOverview extends StatelessWidget {
8
9
9
10
@override
10
11
Widget build (BuildContext context) {
11
- final TextStyle countStyle = TextStyle (
12
- // fontWeight: FontWeight.bold,
13
- fontSize: 28 ,
14
- color: Theme .of (context).accentColor);
12
+ final TextStyle countStyle =
13
+ TextStyle (fontSize: 28 , color: Theme .of (context).accentColor);
15
14
final TextStyle labelStyle =
16
15
TextStyle (fontWeight: FontWeight .bold, color: UnderdogTheme .darkTeal);
17
16
18
- return Consumer <HomeModel >(
19
- builder: (BuildContext context, HomeModel model, Widget child) {
20
- if (model.stats == null ) {
17
+ return StreamBuilder <Stats >(
18
+ stream: Provider .of <HomeModel >(context).watchStats (),
19
+ builder: (BuildContext context, AsyncSnapshot <Stats > snapshot) {
20
+ if (! snapshot.hasData) {
21
21
return const Padding (
22
22
padding: EdgeInsets .all (16.0 ),
23
23
child: Center (
@@ -45,7 +45,7 @@ class StatsOverview extends StatelessWidget {
45
45
Column (
46
46
children: < Widget > [
47
47
Text (
48
- '${model . stats .reportCount }' ,
48
+ '${snapshot . data .reportCount }' ,
49
49
style: countStyle,
50
50
),
51
51
Text (
@@ -57,7 +57,7 @@ class StatsOverview extends StatelessWidget {
57
57
Column (
58
58
children: < Widget > [
59
59
Text (
60
- '${model . stats .rescueCount }' ,
60
+ '${snapshot . data .rescueCount }' ,
61
61
style: countStyle,
62
62
),
63
63
Text ('Rescues' , style: labelStyle)
@@ -72,6 +72,64 @@ class StatsOverview extends StatelessWidget {
72
72
}
73
73
},
74
74
);
75
+
76
+ // return Consumer<HomeModel>(
77
+ // builder: (BuildContext context, HomeModel model, Widget child) {
78
+ // if (model.stats == null) {
79
+ // return const Padding(
80
+ // padding: EdgeInsets.all(16.0),
81
+ // child: Center(
82
+ // child: CircularProgressIndicator(),
83
+ // ),
84
+ // );
85
+ // } else {
86
+ // return Padding(
87
+ // padding: const EdgeInsets.all(8.0),
88
+ // child: Column(
89
+ // mainAxisAlignment: MainAxisAlignment.center,
90
+ // children: <Widget>[
91
+ // Text(
92
+ // '${_createGreetingString()}',
93
+ // style: TextStyle(fontSize: 24, color: UnderdogTheme.teal),
94
+ // ),
95
+ // Text(
96
+ // 'as of the moment, there are',
97
+ // style: TextStyle(fontSize: 14, color: UnderdogTheme.darkTeal),
98
+ // ),
99
+ // const SizedBox(height: 8),
100
+ // Row(
101
+ // mainAxisAlignment: MainAxisAlignment.spaceEvenly,
102
+ // children: <Widget>[
103
+ // Column(
104
+ // children: <Widget>[
105
+ // Text(
106
+ // '${model.stats.reportCount}',
107
+ // style: countStyle,
108
+ // ),
109
+ // Text(
110
+ // 'Reports',
111
+ // style: labelStyle,
112
+ // )
113
+ // ],
114
+ // ),
115
+ // Column(
116
+ // children: <Widget>[
117
+ // Text(
118
+ // '${model.stats.rescueCount}',
119
+ // style: countStyle,
120
+ // ),
121
+ // Text('Rescues', style: labelStyle)
122
+ // ],
123
+ // ),
124
+ // ],
125
+ // ),
126
+ // const SizedBox(height: 8),
127
+ // ],
128
+ // ),
129
+ // );
130
+ // }
131
+ // },
132
+ // );
75
133
}
76
134
77
135
String _createGreetingString () {
0 commit comments