-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor score board #7
Conversation
WalkthroughThe recent updates have brought significant improvements to the cricket match management application, focusing on enhancing analytics, refining team operations, and enriching user engagement. These changes introduce new features like the Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (4)
Files skipped from review as they are similar to previous changes (3)
Additional comments not posted (8)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
extension MatchModelString on MatchModel { | ||
({String teamName, int difference, String wonByText})? getWinnerSummary( | ||
BuildContext context) { | ||
if (match_status != MatchStatus.finish) { | ||
return null; | ||
} | ||
|
||
final firstTeam = toss_decision == TossDecision.bat | ||
? teams.firstWhere((element) => element.team.id == toss_winner_id) | ||
: teams.firstWhere((element) => element.team.id != toss_winner_id); | ||
final secondTeam = | ||
teams.firstWhere((element) => element.team.id != firstTeam.team.id); | ||
|
||
if (firstTeam.run! > secondTeam.run!) { | ||
// first batting team won | ||
final teamName = firstTeam.team.name; | ||
|
||
final runDifference = firstTeam.run! - secondTeam.run!; | ||
|
||
return ( | ||
teamName: teamName, | ||
difference: runDifference, | ||
wonByText: context.l10n.common_runs_dot_title, | ||
); | ||
} else { | ||
// second batting team won | ||
final teamName = secondTeam.team.name; | ||
|
||
final wicketDifference = | ||
secondTeam.squad.length - (firstTeam.wicket ?? 0); | ||
|
||
return ( | ||
teamName: teamName, | ||
difference: wicketDifference, | ||
wonByText: context.l10n.common_wickets_dot_title, | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor to improve readability and reduce complexity.
The getWinnerSummary
method could be refactored to improve readability and reduce complexity. Consider breaking down the logic into smaller, more focused methods (e.g., calculateRunDifference
, calculateWicketDifference
). This will make the code easier to understand and maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
void _observePushTossDetailScreen( | ||
BuildContext context, | ||
WidgetRef ref, | ||
String? matchId, | ||
) { | ||
ref.listen( | ||
addMatchViewStateProvider.select((value) => value.pushTossDetailScreen), | ||
(previous, next) { | ||
if (next == true) { | ||
AppRoute.addTossDetail( | ||
matchId: ref.read(addMatchViewStateProvider.notifier).matchId ?? | ||
"INVALID ID") | ||
AppRoute.addTossDetail(matchId: matchId ?? "INVALID ID") | ||
.pushReplacement(context); | ||
} else if (next == false) { | ||
AppRoute.scoreBoard( | ||
matchId: ref.read(addMatchViewStateProvider.notifier).matchId ?? | ||
"INVALID ID") | ||
AppRoute.scoreBoard(matchId: matchId ?? "INVALID ID") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider handling the potential null matchId
more robustly instead of defaulting to "INVALID ID". This could lead to unintended behavior or errors in routing.
add non-striker-id and use in undo ball
modualize scoreboard screen
empty view for home screen running matches
continue with injured player option
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Style
Chores