File tree 5 files changed +14
-16
lines changed
5 files changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ class ContributionBloc {
17
17
Stream <int > _timer = Stream .empty ();
18
18
// BehaviorSubject allows seeding the tabIndex data to pending.
19
19
// Tagname is the name of the tab and modifier for the contributions
20
- BehaviorSubject <int > _tabIndex = BehaviorSubject <int >(seedValue: 0 );
20
+ BehaviorSubject <String > _tabName =
21
+ BehaviorSubject <String >(seedValue: 'unreviewed' );
21
22
// Stream<String> _log = Stream.empty();
22
23
23
24
BehaviorSubject <String > _filter = BehaviorSubject <String >(seedValue: 'all' );
@@ -27,11 +28,11 @@ class ContributionBloc {
27
28
Stream <String > get voteCount => _voteCount;
28
29
Stream <int > get timer => _timer;
29
30
30
- Sink <int > get tabIndex => _tabIndex ;
31
+ Sink <String > get tabName => _tabName ;
31
32
Sink <String > get filter => _filter;
32
33
33
34
ContributionBloc (this .api, this .parseWebsite) {
34
- _results = _tabIndex
35
+ _results = _tabName
35
36
36
37
// Apply the api updateContributions function to tabIndex stream to get results.
37
38
.asyncMap (api.updateContributions)
@@ -50,7 +51,7 @@ class ContributionBloc {
50
51
}
51
52
52
53
void dispose () {
53
- _tabIndex .close ();
54
+ _tabName .close ();
54
55
_filter.close ();
55
56
}
56
57
}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import 'package:utopian_rocks/blocs/contribution_bloc.dart';
9
9
class ListPage extends StatelessWidget {
10
10
final ContributionBloc bloc;
11
11
final String tabName;
12
- final Function (int , ContributionBloc ) callback;
12
+ final Function (String , ContributionBloc ) callback;
13
13
14
14
ListPage (this .tabName, this .bloc, this .callback);
15
15
// Pass in the [tabName] or string which represents the page name.
@@ -19,8 +19,8 @@ class ListPage extends StatelessWidget {
19
19
Widget build (BuildContext context) {
20
20
// get block from [ContributionProvider] to add to [StreamBuilder]
21
21
final parseWebsite = ParseWebsite ();
22
- final tab = DefaultTabController . of (context);
23
- callback (tab.index , bloc);
22
+
23
+ callback (tabName , bloc);
24
24
25
25
parseWebsite.getHtml ();
26
26
Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ class RootApp extends StatelessWidget {
169
169
);
170
170
}
171
171
172
- void initialize (int tabIndex , ContributionBloc bloc) {
173
- bloc.tabIndex .add (tabIndex );
172
+ void initialize (String tabName , ContributionBloc bloc) {
173
+ bloc.tabName .add (tabName );
174
174
}
175
175
}
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import 'dart:async';
2
2
import 'dart:convert' ;
3
3
4
4
import 'package:utopian_rocks/model/model.dart' ;
5
- import 'package:utopian_rocks/utils/utils.dart' ;
6
5
7
6
import 'package:http/http.dart' show Client;
8
7
@@ -12,12 +11,12 @@ class Api {
12
11
static const String _url = 'https://utopian.rocks/api/posts?status={0}' ;
13
12
14
13
// grab the contributions from the endpoint based on the tabname.
15
- Future <List <Contribution >> updateContributions (int tabIndex ) async {
14
+ Future <List <Contribution >> updateContributions (String tabName ) async {
16
15
List <Contribution > items = [];
17
16
await _client
18
17
// add the tabname to the url to change the API endpoint based on the page request
19
18
// Decode the json and then serialize it into [Contribution] objects.
20
- .get (Uri .parse (_url.replaceFirst ("{0}" , statuses[tabIndex] )))
19
+ .get (Uri .parse (_url.replaceFirst ("{0}" , tabName ?? "unreviewed" )))
21
20
.then ((res) => res.body)
22
21
.then (json.decode)
23
22
.then ((json) => json.forEach (
Original file line number Diff line number Diff line change @@ -87,10 +87,8 @@ List<Contribution> applyFilter(
87
87
String filter,
88
88
List <Contribution > contributions,
89
89
) {
90
- var cons = contributions;
91
-
92
90
if (filter != 'all' ) {
93
- return cons .where ((c) => c.category == filter).toList ();
91
+ return contributions .where ((c) => c.category == filter).toList ();
94
92
}
95
- return cons ;
93
+ return contributions ;
96
94
}
You can’t perform that action at this time.
0 commit comments