Skip to content

Commit

Permalink
show partial result
Browse files Browse the repository at this point in the history
fix loading for empty group
  • Loading branch information
Alessandro Liparoti committed Mar 31, 2022
1 parent 6fa0a49 commit 87c9458
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
47 changes: 27 additions & 20 deletions lib/screens/AvailableMatches.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ class AvailableMatches extends StatelessWidget {
if (state.getMatches() == null) {
return null;
}
if (state.getMatches().where((m) => loadOnceState.getSportCenter(m.sportCenterId) == null).isNotEmpty)
return null;
if (state
.getMatches()
.where((m) => loadOnceState.getSportCenter(m.sportCenterId) == null)
.isNotEmpty) return null;

if (!userState.isLoggedIn()) {
return getEmptyStateWidget(context, false);
Expand Down Expand Up @@ -78,8 +80,10 @@ class AvailableMatches extends StatelessWidget {
if (state.getMatches() == null) {
return null;
}
if (state.getMatches().where((m) => loadOnceState.getSportCenter(m.sportCenterId) == null).isNotEmpty)
return null;
if (state
.getMatches()
.where((m) => loadOnceState.getSportCenter(m.sportCenterId) == null)
.isNotEmpty) return null;

if (!userState.isLoggedIn()) {
return getEmptyStateWidget(context);
Expand Down Expand Up @@ -119,8 +123,10 @@ class AvailableMatches extends StatelessWidget {
if (state.getMatches() == null) {
return null;
}
if (state.getMatches().where((m) => loadOnceState.getSportCenter(m.sportCenterId) == null).isNotEmpty)
return null;
if (state
.getMatches()
.where((m) => loadOnceState.getSportCenter(m.sportCenterId) == null)
.isNotEmpty) return null;

var matches = state
.getMatchesInFuture()
Expand All @@ -139,28 +145,29 @@ class AvailableMatches extends StatelessWidget {

List<int> sortedWeeks = grouped.keys.toList()..sort();

List<Widget> result = [];

var groupedByWeeksIntervals = Map<String, List<Match>> ();
groupedByWeeksIntervals["THIS WEEK"] = grouped[0];
groupedByWeeksIntervals["NEXT WEEK"] = grouped[0];
var groupedByWeeksIntervals = Map<String, List<Match>>();
if (grouped.containsKey(0))
groupedByWeeksIntervals["THIS WEEK"] = grouped[0];
if (grouped.containsKey(1))
groupedByWeeksIntervals["NEXT WEEK"] = grouped[1];
groupedByWeeksIntervals["IN MORE THAN TWO WEEKS"] = List<Match>.from([]);
sortedWeeks.forEach((w) {
if (w > 1) {
groupedByWeeksIntervals["IN MORE THAN TWO WEEKS"].addAll(grouped[w]);
}
});

List<Widget> result = [];
groupedByWeeksIntervals.entries.forEach((e) {
var widgets =
e.value.sortedBy((e) => e.dateTime).mapIndexed((index, match) {
if (index == 0) {
return GenericMatchInfo.first(
match.documentId, onTap, refreshController);
}
return GenericMatchInfo(match.documentId, onTap, refreshController);
});
if (widgets.isNotEmpty) {
if (e.value != null && e.value.isNotEmpty) {
var widgets =
e.value.sortedBy((e) => e.dateTime).mapIndexed((index, match) {
if (index == 0) {
return GenericMatchInfo.first(
match.documentId, onTap, refreshController);
}
return GenericMatchInfo(match.documentId, onTap, refreshController);
});
result.add(Section(
topSpace: 16,
title: e.key,
Expand Down
6 changes: 4 additions & 2 deletions lib/screens/MatchDetails.dart
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,10 @@ class Stats extends StatelessWidget {
@override
Widget build(BuildContext context) {
var child;
var showingPartial = matchStatusForUser == MatchStatusForUser.no_more_to_rate && extended;

if (matchStatusForUser == MatchStatusForUser.no_more_to_rate) {
// in extended mode, we show also partial results
if (matchStatusForUser == MatchStatusForUser.no_more_to_rate && !extended) {
child = Container(
width: double.infinity,
child: Column(
Expand Down Expand Up @@ -851,7 +853,7 @@ class Stats extends StatelessWidget {

return Container(
child: Section(
title: "MATCH STATS",
title: "MATCH STATS " + (showingPartial ? " (partial)" : ""),
body: InfoContainer(child: child),
),
);
Expand Down

0 comments on commit 87c9458

Please sign in to comment.