Skip to content
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

Merged
merged 5 commits into from
Apr 10, 2024
Merged

Refactor score board #7

merged 5 commits into from
Apr 10, 2024

Conversation

cp-sidhdhi-p
Copy link
Collaborator

@cp-sidhdhi-p cp-sidhdhi-p commented Apr 9, 2024

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

    • Introduced a new field to track non-striker details in cricket match scoring.
    • Added new localization keys for match status and descriptions, improving user interaction.
    • Implemented a widget to display winning messages in games or competitions.
    • Enhanced match and ball score models with methods for legal delivery checks and summarizing match winners.
    • Updated the home screen to conditionally render based on the presence of matches.
    • Added power play details in match addition view.
    • Improved user interface in scoreboards with conditional undo buttons and updated player selection logic.
    • Enhanced profile editing, team addition, and member management with new fields and validation.
    • Optimized team detail presentation with list views and adjusted text sizes for better readability.
  • Bug Fixes

    • Corrected team ID handling in team update and member addition flows.
    • Fixed error message links in various models for clearer guidance.
  • Refactor

    • Streamlined data model extensions for cricket match scoring.
    • Refined view models and state management across features for better performance and user experience.
    • Adjusted UI components for consistent and user-friendly navigation and display.
  • Style

    • Updated UI components with new imports and method signatures for a more intuitive user interface.
    • Enhanced dialog and screen layouts for clarity and usability.
  • Chores

    • Updated error handling and state management in sign-in flows and team search functionality.

Copy link

coderabbitai bot commented Apr 9, 2024

Walkthrough

The 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 non_striker_id in the ball score model for detailed match insights, optimized team update methods, enhanced localization for better user interaction, new widgets for match outcome details, and UI refinements for improved navigation and interactivity.

Changes

Files Change Summary
data/lib/api/ball_score/... Added non_striker_id to BallScoreModel for enhanced match analytics.
data/lib/service/team/team_service.dart Optimized team update methods by refining document reference setting.
khelo/assets/locales/app_en.arb Enhanced localization with new keys for match status and UI messages.
khelo/lib/components/won_by_message_text.dart, .../extensions/data_model_extensions/... Introduced new widgets and extensions for better match outcome insights.
khelo/lib/ui/flow/... (Various UI files) UI and navigation enhancements across screens, dialogs, and view models.

🐰✨
In the realm of cricket, where scores are tallied,
And matches unfold, with moments rallied.
A rabbit hopped in, code in its trail,
Enhancing the app, without fail.
With updates aplenty, the experience grows,
For fans and players, the excitement overflows.
🌟🏏


Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1fe4639 and c30b9c5.
Files selected for processing (4)
  • khelo/lib/domain/extensions/data_model_extensions/match_model_extension.dart (1 hunks)
  • khelo/lib/ui/flow/matches/add_match/add_match_screen.dart (4 hunks)
  • khelo/lib/ui/flow/matches/match_list_screen.dart (6 hunks)
  • khelo/lib/ui/flow/score_board/components/select_player_sheet.dart (8 hunks)
Files skipped from review as they are similar to previous changes (3)
  • khelo/lib/domain/extensions/data_model_extensions/match_model_extension.dart
  • khelo/lib/ui/flow/matches/add_match/add_match_screen.dart
  • khelo/lib/ui/flow/matches/match_list_screen.dart
Additional comments not posted (8)
khelo/lib/ui/flow/score_board/components/select_player_sheet.dart (8)

2-2: Added import for inning_model.dart. Ensure that this import is necessary for the changes made in this file.


20-20: Renamed parameter to continueWithInjPlayer to better reflect its purpose. Ensure all calls to this method are updated to use the new parameter name.


31-32: Updated constructor parameters to match the new method signature. Verify that these changes are propagated wherever this constructor is used.


38-45: Constructor parameters updated to include continueWithInjPlayer. This change aligns with the new functionality to handle injured players. Ensure that all instantiations of this class are updated accordingly.


55-61: Initialization of isEnabled based on continueWithInjPlayer. This logic correctly sets the initial state based on whether the injured player option is continued. Good use of widget properties to manage state.


77-136: Refactored _body method to handle different player types and conditions based on player status. This change improves the modularity and readability of the method. Ensure that the logic correctly handles all player types and statuses as intended.


189-250: Added logic to enable or disable player selection based on the injury status. This is a crucial feature for handling game scenarios with injured players. Verify that the disabling logic works as expected in all scenarios.


346-476: Adjusted button behavior to reflect the new logic for handling injured players. This change ensures that the UI responds correctly to the game state. Verify that the button behavior aligns with the expected user interactions.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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

Comment on lines 5 to 42
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,
);
}
}
Copy link

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.

Copy link

@coderabbitai coderabbitai bot left a 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

Comment on lines 35 to 47
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")
Copy link

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.

@cp-sidhdhi-p cp-sidhdhi-p merged commit 98fa046 into main Apr 10, 2024
2 checks passed
@cp-sidhdhi-p cp-sidhdhi-p deleted the sidhdhi/refactor-score-board branch April 10, 2024 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants