-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor and implement injured player flow
- Loading branch information
1 parent
2358ba6
commit 4b371a0
Showing
42 changed files
with
1,935 additions
and
1,627 deletions.
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, | ||
); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.