From 6c0390c1b3958df7efc98f7d6bca1843d6faffb5 Mon Sep 17 00:00:00 2001 From: Mayank Variya Date: Fri, 8 Nov 2024 14:23:25 +0530 Subject: [PATCH] Minor changes --- .../detail/tournament_detail_view_model.dart | 52 +++++++++---------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/khelo/lib/ui/flow/tournament/detail/tournament_detail_view_model.dart b/khelo/lib/ui/flow/tournament/detail/tournament_detail_view_model.dart index f8bd4fb4..ec7da851 100644 --- a/khelo/lib/ui/flow/tournament/detail/tournament_detail_view_model.dart +++ b/khelo/lib/ui/flow/tournament/detail/tournament_detail_view_model.dart @@ -148,38 +148,34 @@ class TournamentDetailStateViewNotifier } }).toList(); - if (tag == KeyStatFilterTag.mostHundreds || - tag == KeyStatFilterTag.mostFifties || - tag == KeyStatFilterTag.boundaries) { - filteredStats.sort((a, b) { - int compareByTag(PlayerKeyStat x, PlayerKeyStat y) { - switch (tag) { - case KeyStatFilterTag.mostHundreds: - return (y.stats.battingStat?.hundreds ?? 0) - .compareTo(x.stats.battingStat?.hundreds ?? 0); - case KeyStatFilterTag.mostFifties: - return (y.stats.battingStat?.fifties ?? 0) - .compareTo(x.stats.battingStat?.fifties ?? 0); - case KeyStatFilterTag.boundaries: - return ((y.stats.battingStat?.fours ?? 0) + - (y.stats.battingStat?.sixes ?? 0)) - .compareTo((x.stats.battingStat?.fours ?? 0) + - (x.stats.battingStat?.sixes ?? 0)); - default: - return 0; - } + filteredStats.sort((a, b) { + int compareByTag(PlayerKeyStat x, PlayerKeyStat y) { + switch (tag) { + case KeyStatFilterTag.mostHundreds: + return (y.stats.battingStat?.hundreds ?? 0) + .compareTo(x.stats.battingStat?.hundreds ?? 0); + case KeyStatFilterTag.mostFifties: + return (y.stats.battingStat?.fifties ?? 0) + .compareTo(x.stats.battingStat?.fifties ?? 0); + case KeyStatFilterTag.boundaries: + return ((y.stats.battingStat?.fours ?? 0) + + (y.stats.battingStat?.sixes ?? 0)) + .compareTo((x.stats.battingStat?.fours ?? 0) + + (x.stats.battingStat?.sixes ?? 0)); + default: + return (b.stats.battingStat?.runScored ?? 0) + .compareTo(a.stats.battingStat?.runScored ?? 0); } + } - return compareByTag(a, b); - }); - } + return compareByTag(a, b); + }); + + filteredStats.sort((a, b) => (b.stats.battingStat?.runScored ?? 0) + .compareTo(a.stats.battingStat?.runScored ?? 0)); state = state.copyWith( - filteredStats: filteredStats - ..sort( - (a, b) => (b.stats.battingStat?.runScored ?? 0) - .compareTo(a.stats.battingStat?.runScored ?? 0), - ), + filteredStats: filteredStats, selectedFilterTag: tag, ); }