-
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
Merged
+2,130
−1,710
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4b371a0
refactor and implement injured player flow
cp-sidhdhi-p a7d52a9
empty view in home screen running match
cp-sidhdhi-p 09d90b9
Fix score board state
cp-sneha-s 1fe4639
pass value instead of state
cp-sidhdhi-p c30b9c5
remove force unwrap
cp-sidhdhi-p File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:khelo/domain/extensions/context_extensions.dart'; | ||
import 'package:style/extensions/context_extensions.dart'; | ||
import 'package:style/text/app_text_style.dart'; | ||
|
||
class WonByMessageText extends StatelessWidget { | ||
final String teamName; | ||
final int difference; | ||
final String trailingText; | ||
|
||
const WonByMessageText({ | ||
super.key, | ||
required this.teamName, | ||
required this.difference, | ||
required this.trailingText, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Text.rich(TextSpan( | ||
text: teamName, | ||
style: | ||
AppTextStyle.header4.copyWith(color: context.colorScheme.primary), | ||
children: [ | ||
TextSpan( | ||
text: context.l10n.score_board_won_by_title, | ||
style: AppTextStyle.subtitle2 | ||
.copyWith(color: context.colorScheme.textSecondary)), | ||
TextSpan( | ||
text: "$difference", | ||
), | ||
TextSpan( | ||
text: trailingText, | ||
), | ||
])); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
khelo/lib/domain/extensions/data_model_extensions/ball_score_model_extension.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:data/api/ball_score/ball_score_model.dart'; | ||
|
||
extension BallScoreModelBoolean on BallScoreModel? { | ||
bool? isLegalDelivery() { | ||
if (this == null) { | ||
return null; | ||
} | ||
return this!.extras_type != ExtrasType.penaltyRun && | ||
this!.extras_type != ExtrasType.noBall && | ||
this!.extras_type != ExtrasType.wide && | ||
this!.wicket_type != WicketType.timedOut && | ||
this!.wicket_type != WicketType.retired && | ||
this!.wicket_type != WicketType.retiredHurt; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
khelo/lib/domain/extensions/data_model_extensions/match_model_extension.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:data/api/match/match_model.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:khelo/domain/extensions/context_extensions.dart'; | ||
|
||
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, | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.