Skip to content

Commit

Permalink
Redesign match list screen (#23)
Browse files Browse the repository at this point in the history
* redesign match list

* change padding
  • Loading branch information
cp-sidhdhi-p authored May 28, 2024
1 parent 5545e2e commit 08cff24
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 425 deletions.
4 changes: 2 additions & 2 deletions khelo/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@
"match_list_start_match_text": "Start a Match?",
"match_list_start_title": "Start",
"match_list_no_match_yet_title": "No Matches Yet",
"match_list_overs_title": "{overs} Overs",
"match_list_overs_title": "{overs, plural, =0{{overs} overs} =1{{overs} over} other{{overs} overs}}",
"@match_list_overs_title": {
"description": "{overs} Overs",
"description": "overs, plural, =0{{overs} overs} =1{{overs} over} other{{overs} overs}}",
"placeholders": {
"overs": {
"type": "int"
Expand Down
175 changes: 175 additions & 0 deletions khelo/lib/components/match_detail_cell.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import 'package:data/api/match/match_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:khelo/components/image_avatar.dart';
import 'package:khelo/components/match_status_tag.dart';
import 'package:khelo/components/won_by_message_text.dart';
import 'package:khelo/domain/extensions/context_extensions.dart';
import 'package:khelo/domain/extensions/data_model_extensions/match_model_extension.dart';
import 'package:khelo/domain/extensions/enum_extensions.dart';
import 'package:khelo/domain/formatter/date_formatter.dart';
import 'package:khelo/gen/assets.gen.dart';
import 'package:style/animations/on_tap_scale.dart';
import 'package:style/extensions/context_extensions.dart';
import 'package:style/text/app_text_style.dart';

class MatchDetailCell extends StatelessWidget {
final MatchModel match;
final Function() onTap;
final bool showStatusTag;
final bool showActionButtons;
final Function()? onActionTap;

const MatchDetailCell({
super.key,
required this.match,
required this.onTap,
this.showStatusTag = true,
this.showActionButtons = false,
this.onActionTap,
});

@override
Widget build(BuildContext context) {
return OnTapScale(
onTap: onTap,
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
border: Border.all(color: context.colorScheme.secondary),
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_matchTimeAndGroundView(context),
const SizedBox(height: 16),
...match.teams.map(
(team) => _teamView(context, team),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Divider(
color: context.colorScheme.outline,
height: 1,
),
),
Row(
children: [
Expanded(child: _winnerMessageText(context)),
if (showStatusTag) ...[
MatchStatusTag(
status: match.match_status,
onTap: showActionButtons &&
match.match_status != MatchStatus.finish
? onActionTap
: null,
)
],
],
)
],
),
),
);
}

Widget _matchTimeAndGroundView(BuildContext context) {
return Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Flexible(
flex: 2,
child: Text(
match.start_time.format(context, DateFormatType.dateAndTime),
style: AppTextStyle.caption
.copyWith(color: context.colorScheme.textDisabled)),
),
Flexible(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
SvgPicture.asset(
Assets.images.icLocation,
height: 20,
width: 20,
colorFilter: ColorFilter.mode(
context.colorScheme.textSecondary,
BlendMode.srcATop,
),
),
const SizedBox(width: 4),
Flexible(
child: Text(
match.ground,
style: AppTextStyle.caption
.copyWith(color: context.colorScheme.textDisabled),
overflow: TextOverflow.ellipsis,
),
),
],
),
),
]);
}

Widget _teamView(BuildContext context, MatchTeamModel matchTeam) {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Row(
children: [
ImageAvatar(
initial: matchTeam.team.name[0].toUpperCase(),
imageUrl: matchTeam.team.profile_img_url,
size: 32,
),
const SizedBox(width: 8),
Expanded(
child: Text(matchTeam.team.name,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: AppTextStyle.subtitle3
.copyWith(color: context.colorScheme.textPrimary)),
),
if (!(matchTeam.run == 0 &&
matchTeam.wicket == 0 &&
matchTeam.over == 0)) ...[
Text.rich(TextSpan(
text: "${matchTeam.run}-${matchTeam.wicket}",
style: AppTextStyle.subtitle2
.copyWith(color: context.colorScheme.textPrimary),
children: [
TextSpan(
text: " ${matchTeam.over}",
style: AppTextStyle.body2
.copyWith(color: context.colorScheme.textSecondary),
)
]))
],
],
),
);
}

Widget _winnerMessageText(BuildContext context) {
final winSummary = match.getWinnerSummary(context);
if (match.match_status == MatchStatus.finish && winSummary != null) {
if (winSummary.teamName.isEmpty) {
return Text(
context.l10n.score_board_match_tied_text,
style: AppTextStyle.subtitle1
.copyWith(color: context.colorScheme.textPrimary),
);
}
return WonByMessageText(
teamName: winSummary.teamName,
difference: winSummary.difference,
trailingText: winSummary.wonByText,
);
} else {
return Text(
"${match.match_type.getString(context)} ${context.l10n.match_list_overs_title(match.number_of_over)}",
style: AppTextStyle.body2
.copyWith(color: context.colorScheme.textDisabled),
);
}
}
}
50 changes: 40 additions & 10 deletions khelo/lib/components/match_status_tag.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,58 @@
import 'package:data/api/match/match_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:khelo/domain/extensions/enum_extensions.dart';
import 'package:khelo/gen/assets.gen.dart';
import 'package:style/animations/on_tap_scale.dart';
import 'package:style/extensions/context_extensions.dart';
import 'package:style/text/app_text_style.dart';

class MatchStatusTag extends StatelessWidget {
final MatchStatus status;
final Function()? onTap;

const MatchStatusTag({
super.key,
this.onTap,
required this.status,
});

@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 2),
decoration: BoxDecoration(
color: status.getColor(context).withOpacity(0.5),
borderRadius: BorderRadius.circular(16),
),
child: Text(
status.getString(context),
style:
AppTextStyle.body2.copyWith(color: context.colorScheme.textPrimary),
return OnTapScale(
onTap: onTap,
enabled: onTap != null,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: status.getColor(context),
borderRadius: BorderRadius.circular(30),
),
child: Row(
children: [
if (onTap != null) ...[
status == MatchStatus.yetToStart
? Icon(
CupertinoIcons.play,
size: 16,
color: context.colorScheme.onPrimary,
)
: SvgPicture.asset(
Assets.images.icEdit,
height: 16,
width: 16,
colorFilter: ColorFilter.mode(
context.colorScheme.onPrimary, BlendMode.srcIn),
),
const SizedBox(width: 2)
],
Text(
status.getString(context),
style: AppTextStyle.caption
.copyWith(color: context.colorScheme.onPrimary),
),
],
),
),
);
}
Expand Down
Loading

0 comments on commit 08cff24

Please sign in to comment.