Skip to content

Commit

Permalink
Merge pull request #131 from canopas/Mayank/tournament-minor-improvments
Browse files Browse the repository at this point in the history
Tournament minor improvements
  • Loading branch information
cp-mayank authored Nov 8, 2024
2 parents 29a3043 + 6c0390c commit e885497
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 96 deletions.
1 change: 1 addition & 0 deletions khelo/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
"tournament_detail_key_stat_most_fours_title": "Most Fours",
"tournament_detail_key_stat_most_sixes_title": "Most Sixes",

"key_stat_all": "All",
"key_stat_filter_runs": "Runs",
"key_stat_filter_wickets": "Wickets",
"key_stat_filter_fours": "Fours",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,26 @@ import 'package:style/text/app_text_style.dart';

import '../../../../../components/image_avatar.dart';

class TournamentDetailOverviewTab extends ConsumerStatefulWidget {
class TournamentDetailOverviewTab extends ConsumerWidget {
final TournamentModel tournament;
final PageController controller;

const TournamentDetailOverviewTab({
super.key,
required this.tournament,
required this.controller,
});

@override
ConsumerState<TournamentDetailOverviewTab> createState() =>
_TournamentDetailOverviewTabState();
}

class _TournamentDetailOverviewTabState
extends ConsumerState<TournamentDetailOverviewTab> {
@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
return ListView(
padding: context.mediaQueryPadding.copyWith(top: 0) +
EdgeInsets.symmetric(horizontal: 16).copyWith(bottom: 40),
children: [
_featuredMatchesView(context, widget.tournament.matches),
_keyStatsView(context, widget.tournament.keyStats),
_teamsSquadsView(context, widget.tournament.teams),
_infoView(context, widget.tournament),
_featuredMatchesView(context, tournament.matches),
_keyStatsView(context, tournament.keyStats),
_teamsSquadsView(context, tournament.teams),
_infoView(context, tournament),
],
);
}
Expand All @@ -56,7 +51,7 @@ class _TournamentDetailOverviewTabState
title:
context.l10n.tournament_detail_overview_featured_matches_title,
showViewAll: matches.length > 3,
onViewAll: () {},
onViewAll: () => controller.jumpToPage(2),
),
...List.generate(
matches.take(3).length,
Expand All @@ -68,48 +63,56 @@ class _TournamentDetailOverviewTabState
}

Widget _matchCellView(BuildContext context, MatchModel match) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 24),
margin: EdgeInsets.symmetric(vertical: 8),
decoration: BoxDecoration(
color: context.colorScheme.surface,
borderRadius: BorderRadius.circular(16),
),
child: Row(
children: [
_buildTeamInfo(team: match.teams.first.team),
const Spacer(),
if (match.matchResult != null) ...[
WonByMessageText(
isTournament: true,
matchResult: match.matchResult,
),
] else ...[
Column(
children: [
Text(
match.start_at?.format(context, DateFormatType.time) ??
DateTime.now().format(context, DateFormatType.time),
style: AppTextStyle.caption
.copyWith(color: context.colorScheme.textDisabled),
),
Text(
match.start_at?.relativeTime(context) ??
DateTime.now().relativeTime(context),
style: AppTextStyle.subtitle2
.copyWith(color: context.colorScheme.textPrimary),
),
],
return OnTapScale(
onTap: () => AppRoute.matchDetailTab(matchId: match.id).push(context),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 24),
margin: EdgeInsets.symmetric(vertical: 8),
decoration: BoxDecoration(
color: context.colorScheme.surface,
borderRadius: BorderRadius.circular(16),
),
child: Row(
children: [
_buildTeamInfo(context, team: match.teams.first.team),
const Spacer(),
if (match.matchResult != null) ...[
WonByMessageText(
isTournament: true,
matchResult: match.matchResult,
),
] else ...[
Column(
children: [
Text(
match.start_at?.format(context, DateFormatType.time) ??
DateTime.now().format(context, DateFormatType.time),
style: AppTextStyle.caption
.copyWith(color: context.colorScheme.textDisabled),
),
Text(
match.start_at?.relativeTime(context) ??
DateTime.now().relativeTime(context),
style: AppTextStyle.subtitle2
.copyWith(color: context.colorScheme.textPrimary),
),
],
),
],
const Spacer(),
_buildTeamInfo(
context,
team: match.teams.last.team,
isSecond: true,
),
],
const Spacer(),
_buildTeamInfo(team: match.teams.last.team, isSecond: true),
],
),
),
);
}

Widget _buildTeamInfo({
Widget _buildTeamInfo(
BuildContext context, {
required TeamModel team,
bool isSecond = false,
}) {
Expand Down Expand Up @@ -162,7 +165,7 @@ class _TournamentDetailOverviewTabState
context,
showViewAll: keyStatsList.length > 4,
title: context.l10n.tournament_detail_overview_key_stats_title,
onViewAll: () {},
onViewAll: () => controller.jumpToPage(4),
),
const SizedBox(height: 8),
GridView.builder(
Expand Down Expand Up @@ -261,7 +264,7 @@ class _TournamentDetailOverviewTabState
context,
showViewAll: teams.length > 3,
title: context.l10n.tournament_detail_overview_teams_squads_title,
onViewAll: () {},
onViewAll: () => controller.jumpToPage(1),
),
const SizedBox(height: 8),
SizedBox(
Expand Down
55 changes: 45 additions & 10 deletions khelo/lib/ui/flow/tournament/detail/tournament_detail_screen.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:data/api/team/team_model.dart';
import 'package:data/api/tournament/tournament_model.dart';
Expand All @@ -17,11 +19,13 @@ import 'package:khelo/ui/flow/tournament/detail/tabs/tournament_detail_points_ta
import 'package:khelo/ui/flow/tournament/detail/tabs/tournament_detail_stats_tab.dart';
import 'package:khelo/ui/flow/tournament/detail/tabs/tournament_detail_teams_tab.dart';
import 'package:khelo/ui/flow/tournament/detail/tournament_detail_view_model.dart';
import 'package:style/button/action_button.dart';
import 'package:style/button/more_option_button.dart';
import 'package:style/button/tab_button.dart';
import 'package:style/extensions/context_extensions.dart';
import 'package:style/indicator/progress_indicator.dart';
import 'package:style/text/app_text_style.dart';
import 'package:style/theme/colors.dart';

import '../../../../components/action_bottom_sheet.dart';
import '../../../../components/app_page.dart';
Expand Down Expand Up @@ -111,13 +115,18 @@ class _TournamentDetailScreenState
pinned: true,
expandedHeight: 300,
backgroundColor: context.colorScheme.surface,
leading: _backButton(context),
flexibleSpace: _flexibleTitle(context, state.tournament!),
actions: state.tournament!.created_by == state.currentUserId ||
state.tournament!.members
.any((element) => element.id == state.currentUserId)
? [
moreOptionButton(
context,
size: 20,
backgroundColor: context
.colorScheme.containerHighOnSurface
.withOpacity(0.4),
onPressed: () => _moreActionButton(context, state),
),
]
Expand Down Expand Up @@ -145,6 +154,7 @@ class _TournamentDetailScreenState
children: [
TournamentDetailOverviewTab(
tournament: state.tournament!,
controller: _controller,
),
TournamentDetailTeamsTab(
onSelected: notifier.onTeamsSelected,
Expand Down Expand Up @@ -243,6 +253,19 @@ class _TournamentDetailScreenState
)
: null,
),
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.transparent,
surfaceDarkColor.withOpacity(0.2),
surfaceDarkColor.withOpacity(0.8),
],
),
),
),
Positioned(
left: 16,
bottom: 24,
Expand All @@ -267,7 +290,7 @@ class _TournamentDetailScreenState
size: 80,
imageUrl: tournament.profile_img_url,
border: Border.all(
color: Colors.white,
color: surfaceLightColor,
width: 1.5,
),
backgroundColor: context.colorScheme.primary,
Expand All @@ -278,9 +301,7 @@ class _TournamentDetailScreenState
child: Text(
tournament.name,
style: AppTextStyle.header1.copyWith(
color: tournament.banner_img_url != null
? Colors.white
: context.colorScheme.textPrimary,
color: surfaceLightColor,
),
overflow: TextOverflow.ellipsis,
textScaler: TextScaler.noScaling,
Expand All @@ -295,9 +316,7 @@ class _TournamentDetailScreenState
height: 24,
width: 24,
colorFilter: ColorFilter.mode(
tournament.banner_img_url != null
? Colors.white
: context.colorScheme.textPrimary,
surfaceLightColor,
BlendMode.srcIn,
),
),
Expand All @@ -307,9 +326,7 @@ class _TournamentDetailScreenState
.start_date
.format(context, DateFormatType.dayMonth)),
style: AppTextStyle.body1.copyWith(
color: tournament.banner_img_url != null
? Colors.white
: context.colorScheme.textPrimary,
color: surfaceLightColor,
),
),
],
Expand Down Expand Up @@ -359,4 +376,22 @@ class _TournamentDetailScreenState
),
]);
}

Widget _backButton(BuildContext context) {
return actionButton(context,
onPressed: context.pop,
icon: Container(
height: 28,
width: 28,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: context.colorScheme.containerHighOnSurface.withOpacity(0.4),
),
child: Icon(
Platform.isIOS ? Icons.arrow_back_ios : Icons.arrow_back,
size: 20,
color: context.colorScheme.textPrimary,
),
));
}
}
Loading

0 comments on commit e885497

Please sign in to comment.