diff --git a/khelo/lib/ui/flow/matches/match_detail/components/commentary_ball_summary.dart b/khelo/lib/ui/flow/matches/match_detail/components/commentary_ball_summary.dart index c54ecbed..f844b9c7 100644 --- a/khelo/lib/ui/flow/matches/match_detail/components/commentary_ball_summary.dart +++ b/khelo/lib/ui/flow/matches/match_detail/components/commentary_ball_summary.dart @@ -22,7 +22,7 @@ class CommentaryBallSummary extends StatelessWidget { @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: Row( children: [ _ballNumberView(context), @@ -42,7 +42,10 @@ class CommentaryBallSummary extends StatelessWidget { .copyWith(color: context.colorScheme.textDisabled) : AppTextStyle.body1 .copyWith(color: context.colorScheme.textDisabled)), - if (showBallScore) ...[BallScoreView(ball: ball, size: 24)] + if (showBallScore) ...[ + const SizedBox(height: 4), + BallScoreView(ball: ball, size: 24) + ] ], ); } diff --git a/khelo/lib/ui/flow/matches/match_detail/components/commentary_over_overview.dart b/khelo/lib/ui/flow/matches/match_detail/components/commentary_over_overview.dart index aadf2f90..5e3db5ba 100644 --- a/khelo/lib/ui/flow/matches/match_detail/components/commentary_over_overview.dart +++ b/khelo/lib/ui/flow/matches/match_detail/components/commentary_over_overview.dart @@ -24,6 +24,7 @@ class CommentaryOverOverview extends StatelessWidget { Widget build(BuildContext context) { return Container( padding: const EdgeInsets.all(16), + margin: const EdgeInsets.symmetric(vertical: 16), color: context.colorScheme.containerLow, child: Column( children: [ diff --git a/khelo/lib/ui/flow/matches/match_detail/components/match_detail_commentary_view.dart b/khelo/lib/ui/flow/matches/match_detail/components/match_detail_commentary_view.dart index 2f3915b7..38412561 100644 --- a/khelo/lib/ui/flow/matches/match_detail/components/match_detail_commentary_view.dart +++ b/khelo/lib/ui/flow/matches/match_detail/components/match_detail_commentary_view.dart @@ -1,8 +1,6 @@ import 'package:data/api/ball_score/ball_score_model.dart'; import 'package:data/api/team/team_model.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:khelo/components/empty_screen.dart'; import 'package:khelo/components/error_screen.dart'; @@ -69,11 +67,13 @@ class MatchDetailCommentaryView extends ConsumerWidget { final nextOverSummary = state.overList.elementAtOrNull(index + 1); if (nextOverSummary != null && nextOverSummary.overNumber != overSummary.overNumber) { - children.add(BowlerSummaryView( - bowlerSummary: nextOverSummary.bowlerStatAtStart, - isForBowlerIntro: true, + children.add(Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: BowlerSummaryView( + bowlerSummary: nextOverSummary.bowlerStatAtStart, + isForBowlerIntro: true, + ), )); - children.add(const SizedBox(height: 24)); } if ((overSummary.balls.lastOrNull?.isLegalDelivery() ?? false) && @@ -81,20 +81,27 @@ class MatchDetailCommentaryView extends ConsumerWidget { nextOverSummary?.inning_id == overSummary.inning_id) { children .add(CommentaryOverOverview(overSummary: overSummary, team: team)); - children.add(const SizedBox(height: 24)); } else if (nextOverSummary != null && nextOverSummary.inning_id != overSummary.inning_id) { - children.add(_inningOverview(context, - teamName: team?.name ?? "", targetRun: overSummary.totalRuns + 1)); + children.addAll([ + _inningOverview(context, + teamName: team?.name ?? "", targetRun: overSummary.totalRuns + 1), + CommentaryOverOverview(overSummary: overSummary, team: team), + ]); } for (final ball in overSummary.balls.reversed) { - children.add(CommentaryBallSummary( - ball: ball, - overSummary: overSummary, - showBallScore: false, - )); - children.add(const SizedBox(height: 8)); + children.addAll([ + CommentaryBallSummary( + ball: ball, + overSummary: overSummary, + showBallScore: + ball.is_four || ball.is_six || ball.wicket_taker_id != null, + ), + if (ball != overSummary.balls.first) ...[ + Divider(color: context.colorScheme.outline), + ], + ]); } } return children; diff --git a/khelo/lib/ui/flow/matches/match_detail/components/match_detail_scorecard_view.dart b/khelo/lib/ui/flow/matches/match_detail/components/match_detail_scorecard_view.dart index c1ab7695..80edad22 100644 --- a/khelo/lib/ui/flow/matches/match_detail/components/match_detail_scorecard_view.dart +++ b/khelo/lib/ui/flow/matches/match_detail/components/match_detail_scorecard_view.dart @@ -54,6 +54,15 @@ class MatchDetailScorecardView extends ConsumerWidget { MatchDetailTabViewNotifier notifier, MatchDetailTabState state, ) { + List> powerPlays = [ + if (state.match?.power_play_overs1.isNotEmpty ?? false) + state.match!.power_play_overs1, + if (state.match?.power_play_overs2.isNotEmpty ?? false) + state.match!.power_play_overs2, + if (state.match?.power_play_overs3.isNotEmpty ?? false) + state.match!.power_play_overs3, + ]; + final groupOversByInnings = groupOversByInning(state.overList); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -65,9 +74,9 @@ class MatchDetailScorecardView extends ConsumerWidget { padding: context.mediaQueryPadding + EdgeInsets.only( top: state.match?.matchResult == null ? 16 : 0, bottom: 16), - itemCount: groupOversByInning(state.overList).length, + itemCount: groupOversByInnings.length, itemBuilder: (context, index) { - final inningOvers = groupOversByInning(state.overList)[index]; + final inningOvers = groupOversByInnings[index]; final overs = inningOvers.lastOrNull; final batsmen = _getBatsmen(inningOvers); final bowler = _getBowlers(inningOvers); @@ -78,20 +87,11 @@ class MatchDetailScorecardView extends ConsumerWidget { ?.squad .toList(); - List> powerPlays = [ - if (state.match?.power_play_overs1.isNotEmpty ?? false) - state.match!.power_play_overs1, - if (state.match?.power_play_overs2.isNotEmpty ?? false) - state.match!.power_play_overs2, - if (state.match?.power_play_overs3.isNotEmpty ?? false) - state.match!.power_play_overs3, - ]; - return _teamTitleView(context, teamName: _getTeamNameByTeamId(state, overs?.team_id ?? ""), over: overs ?? const OverSummary(), initiallyExpanded: state.expandedTeamScorecard - .contains(overs?.team_id ?? ""), + .contains(inningOvers.first.team_id), children: [ _dataTable(context, batsmen: batsmen), ..._buildMatchTotalView(context, diff --git a/khelo/lib/ui/flow/matches/match_detail/components/match_detail_squad_view.dart b/khelo/lib/ui/flow/matches/match_detail/components/match_detail_squad_view.dart index 935cacce..230a99b8 100644 --- a/khelo/lib/ui/flow/matches/match_detail/components/match_detail_squad_view.dart +++ b/khelo/lib/ui/flow/matches/match_detail/components/match_detail_squad_view.dart @@ -139,17 +139,19 @@ class MatchDetailSquadView extends ConsumerWidget { color: context.colorScheme.outline, ), )); - children.add(Row( - children: [ - Expanded( - child: _playerProfileView(context, - user: firstTeamPlayer, captainId: firstTeamCaptainId)), - Expanded( - child: _playerProfileView(context, - user: secondTeamPlayer, - isFirstCell: false, - captainId: secondTeamCaptainId)) - ], + children.add(IntrinsicHeight( + child: Row( + children: [ + _playerProfileView(context, + user: firstTeamPlayer, captainId: firstTeamCaptainId), + VerticalDivider(color: context.colorScheme.outline), + _playerProfileView(context, + user: secondTeamPlayer, + isFirstCell: false, + isSecondTeam: true, + captainId: secondTeamCaptainId) + ], + ), )); } return children; @@ -178,56 +180,68 @@ class MatchDetailSquadView extends ConsumerWidget { BuildContext context, { UserModel? user, bool isFirstCell = true, + bool isSecondTeam = false, String? captainId, }) { if (user == null) { - return const SizedBox( - height: 0, + return const Expanded( + child: SizedBox( + height: 0, + ), ); } bool isCaptain = user.id == captainId; - return IntrinsicHeight( - child: Container( - padding: const EdgeInsets.only(left: 16, top: 16, bottom: 16), - decoration: BoxDecoration( - border: BorderDirectional( - end: BorderSide( - color: isFirstCell - ? context.colorScheme.outline - : Colors.transparent))), - child: OnTapScale( - onTap: () => UserDetailSheet.show(context, user), + return Expanded( + child: OnTapScale( + onTap: () => UserDetailSheet.show(context, user), + child: Padding( + padding: const EdgeInsets.all(16), child: Row( children: [ - ImageAvatar( - initial: user.nameInitial, - imageUrl: user.profile_img_url, - size: 40, - ), - const SizedBox(width: 8), + if (!isSecondTeam) ...[ + ImageAvatar( + initial: user.nameInitial, + imageUrl: user.profile_img_url, + size: 40, + ), + const SizedBox(width: 8), + ], Expanded( - child: Padding( - padding: const EdgeInsets.only(right: 8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - user.name == null - ? context.l10n.common_anonymous_title - : "${user.name}${isCaptain ? context.l10n.match_info_captain_short_title : ""}", - style: AppTextStyle.subtitle2 - .copyWith(color: context.colorScheme.textPrimary), - ), - Text( - user.player_role != null - ? user.player_role!.getString(context) - : context.l10n.common_not_specified_title, - style: AppTextStyle.caption.copyWith( - color: context.colorScheme.textDisabled)), - ], - ), + child: Column( + crossAxisAlignment: isSecondTeam + ? CrossAxisAlignment.end + : CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + user.name == null + ? context.l10n.common_anonymous_title + : "${user.name}${isCaptain ? context.l10n.match_info_captain_short_title : ""}", + style: AppTextStyle.subtitle2 + .copyWith(color: context.colorScheme.textPrimary), + maxLines: 2, + overflow: TextOverflow.ellipsis, + textAlign: isSecondTeam ? TextAlign.end : null, + ), + Text( + user.player_role != null + ? user.player_role!.getString(context) + : context.l10n.common_not_specified_title, + style: AppTextStyle.caption + .copyWith(color: context.colorScheme.textDisabled), + textAlign: isSecondTeam ? TextAlign.end : null, + ), + ], ), ), + if (isSecondTeam) ...[ + const SizedBox(width: 8), + ImageAvatar( + initial: user.nameInitial, + imageUrl: user.profile_img_url, + size: 40, + ), + ], ], ), ), diff --git a/khelo/lib/ui/flow/matches/match_detail/match_detail_tab_view_model.dart b/khelo/lib/ui/flow/matches/match_detail/match_detail_tab_view_model.dart index 1ed8c53d..e0d764cc 100644 --- a/khelo/lib/ui/flow/matches/match_detail/match_detail_tab_view_model.dart +++ b/khelo/lib/ui/flow/matches/match_detail/match_detail_tab_view_model.dart @@ -79,7 +79,7 @@ class MatchDetailTabViewNotifier extends StateNotifier { .firstOrNull; onScorecardExpansionChange( - match.matchResult?.teamId ?? match.teams.firstOrNull?.team.id ?? "", + match.matchResult?.teamId ?? match.current_playing_team_id?? "", true, ); state = state.copyWith( @@ -417,7 +417,7 @@ class MatchDetailTabState with _$MatchDetailTabState { String? highlightTeamId, DateTime? showTeamSelectionSheet, DateTime? showHighlightOptionSelectionSheet, - @Default(0) int selectedTab, + @Default(1) int selectedTab, @Default([]) List overList, @Default([]) List filteredHighlight, @Default([]) List expandedTeamScorecard, @@ -429,23 +429,23 @@ class MatchDetailTabState with _$MatchDetailTabState { } enum MatchDetailTab { + matchInfo, commentary, scorecard, overs, squad, - matchInfo, highlight; String getString(BuildContext context) { switch (this) { + case MatchDetailTab.matchInfo: + return context.l10n.match_detail_match_info_tab_title; case MatchDetailTab.commentary: return context.l10n.match_detail_commentary_tab_title; case MatchDetailTab.scorecard: return context.l10n.match_detail_scorecard_tab_title; case MatchDetailTab.squad: return context.l10n.match_detail_squad_tab_title; - case MatchDetailTab.matchInfo: - return context.l10n.match_detail_match_info_tab_title; case MatchDetailTab.highlight: return context.l10n.match_detail_highlight_tab_title; case MatchDetailTab.overs: @@ -455,14 +455,14 @@ enum MatchDetailTab { Widget getTabScreen() { switch (this) { + case MatchDetailTab.matchInfo: + return const MatchDetailInfoView(); case MatchDetailTab.commentary: return const MatchDetailCommentaryView(); case MatchDetailTab.scorecard: return const MatchDetailScorecardView(); case MatchDetailTab.squad: return const MatchDetailSquadView(); - case MatchDetailTab.matchInfo: - return const MatchDetailInfoView(); case MatchDetailTab.highlight: return const MatchDetailHighlightView(); case MatchDetailTab.overs: diff --git a/khelo/lib/ui/flow/matches/match_detail/match_detail_tab_view_model.freezed.dart b/khelo/lib/ui/flow/matches/match_detail/match_detail_tab_view_model.freezed.dart index cae6b9f6..ab6fba05 100644 --- a/khelo/lib/ui/flow/matches/match_detail/match_detail_tab_view_model.freezed.dart +++ b/khelo/lib/ui/flow/matches/match_detail/match_detail_tab_view_model.freezed.dart @@ -316,7 +316,7 @@ class _$MatchDetailTabStateImpl implements _MatchDetailTabState { this.highlightTeamId, this.showTeamSelectionSheet, this.showHighlightOptionSelectionSheet, - this.selectedTab = 0, + this.selectedTab = 1, final List overList = const [], final List filteredHighlight = const [], final List expandedTeamScorecard = const [],