This commit is contained in:
kejaro committed 2026-09-27 20:41:18 +01:00
1 parent 02ab7f390d
commit 97c10c8d12
7 files changed
+559 -16

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="800px" height="800px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#33d912" stroke-width="0.00016">
<g id="SVGRepo_bgCarrier" stroke-width="0"/>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
<g id="SVGRepo_iconCarrier">
<path fill="#4ee119" d="M 8 1.25 C 7.273 1.251 6.598 1.627 6.215 2.246 L 6.213 2.25 L 0.538 11.623 L 0.532 11.633 C -0.047 12.622 0.29 13.893 1.283 14.465 C 1.597 14.648 1.953 14.746 2.317 14.75 L 13.683 14.75 C 14.422 14.741 15.102 14.344 15.474 13.705 C 15.844 13.063 15.842 12.273 15.468 11.633 L 9.788 2.25 L 9.785 2.246 C 9.405 1.625 8.728 1.247 8 1.25 Z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 720 B

+7
View File
@@ -0,0 +1,7 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
␍<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
␍<g id="SVGRepo_bgCarrier" stroke-width="0"/>
␍<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
␍<g id="SVGRepo_iconCarrier"> <circle cx="8" cy="8" r="8" fill="#f70202"/> </g>
␍</svg>

After

Width:  |  Height:  |  Size: 501 B

@@ -0,0 +1,9 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
␍<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="none">
␍<g id="SVGRepo_bgCarrier" stroke-width="0"/>
␍<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
␍<g id="SVGRepo_iconCarrier">
␍<path fill="#f5c000" d="M3.25 1A2.25 2.25 0 001 3.25v9.5A2.25 2.25 0 003.25 15h9.5A2.25 2.25 0 0015 12.75v-9.5A2.25 2.25 0 0012.75 1h-9.5z"/>
␍</g>
␍</svg>

After

Width:  |  Height:  |  Size: 600 B

+1 -1
View File
@@ -13,7 +13,7 @@
"team": 1
},
{
"card_type": 1,
"card_type": 2,
"datetime": "2023-10-01T12:35:00Z",
"duration": 120,
"player": 8,
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:share_plus/share_plus.dart';
import '../../../../domain/models/hockey_game.dart'
show CardType, GoalType, Match, Team;
@@ -35,13 +37,21 @@ class MatchResultsView extends StatelessWidget {
}
}
class _MatchCard extends StatelessWidget {
class _MatchCard extends StatefulWidget {
const _MatchCard({required this.match});
final Match match;
@override
State<_MatchCard> createState() => _MatchCardState();
}
class _MatchCardState extends State<_MatchCard> {
bool _isExpanded = false;
@override
Widget build(BuildContext context) {
final match = widget.match;
final colors = Theme.of(context).colorScheme;
final textTheme = Theme.of(context).textTheme;
final date = DateTime.tryParse(match.datetime)?.toLocal();
@@ -54,6 +64,16 @@ class _MatchCard extends StatelessWidget {
child: ExpansionTile(
shape: const Border(),
collapsedShape: const Border(),
onExpansionChanged: (expanded) => setState(() => _isExpanded = expanded),
trailing: _isExpanded
? IconButton(
tooltip: 'Share match',
icon: const Icon(Icons.share_outlined),
onPressed: () => SharePlus.instance.share(
ShareParams(text: _matchShareText(match)),
),
)
: const SizedBox.shrink(),
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -79,17 +99,23 @@ class _MatchCard extends StatelessWidget {
children: [
...match.goals.map(
(goal) => _EventLine(
icon: Icons.sports_hockey,
label:
'${_goalTypeName(goal.goalType)} · ${_teamName(goal.team)} · #${goal.player}',
leading: Icon(
Icons.sports_hockey,
size: 18,
color: Theme.of(context).colorScheme.secondary,
),
team: _teamName(goal.team),
playerNumber: goal.player,
eventType: _goalTypeName(goal.goalType),
seconds: goal.seconds,
),
),
...match.cards.map(
(card) => _EventLine(
icon: Icons.style_outlined,
label:
'${_cardName(card.cardType)} card · ${_teamName(card.team)} · #${card.player} · ${card.duration}s',
leading: _CardMarker(cardType: card.cardType),
team: _teamName(card.team),
playerNumber: card.player,
eventType: '${_cardName(card.cardType)} card · ${_cardDurationLabel(card.duration)}',
seconds: card.seconds,
),
),
@@ -109,26 +135,75 @@ class _MatchCard extends StatelessWidget {
class _EventLine extends StatelessWidget {
const _EventLine({
required this.icon,
required this.label,
required this.leading,
required this.team,
required this.playerNumber,
required this.eventType,
required this.seconds,
});
final IconData icon;
final String label;
final Widget leading;
final String team;
final int playerNumber;
final String eventType;
final int seconds;
@override
Widget build(BuildContext context) {
final minute = seconds ~/ 60;
final second = (seconds % 60).toString().padLeft(2, '0');
final playerLabel = '#${playerNumber.toString().padLeft(2, '0')}';
return Padding(
padding: const EdgeInsets.only(bottom: 8),
padding: const EdgeInsets.only(bottom: 4),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(icon, size: 18, color: Theme.of(context).colorScheme.secondary),
SizedBox(
width: 18,
height: 18,
child: Center(child: leading),
),
const SizedBox(width: 8),
Expanded(child: Text(label)),
SizedBox(
width: 40,
child: Align(
alignment: Alignment.centerLeft,
child: Text(team),
),
),
SizedBox(
width: 12,
child: Align(
alignment: Alignment.center,
child: const Text('·', textAlign: TextAlign.center),
),
),
SizedBox(
width: 42,
child: Align(
alignment: Alignment.centerLeft,
child: Text(playerLabel),
),
),
SizedBox(
width: 12,
child: Align(
alignment: Alignment.center,
child: const Text('·', textAlign: TextAlign.center),
),
),
Expanded(
child: Align(
alignment: Alignment.centerLeft,
child: Text(
eventType,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
const SizedBox(width: 4),
Text(
'$minute:$second',
style: Theme.of(context).textTheme.labelMedium,
@@ -139,8 +214,69 @@ class _EventLine extends StatelessWidget {
}
}
class _CardMarker extends StatelessWidget {
const _CardMarker({required this.cardType});
final CardType cardType;
@override
Widget build(BuildContext context) {
final svgPath = switch (cardType) {
CardType.green => 'lib/data/icons/green-card.svg',
CardType.yellow => 'lib/data/icons/yellow-card.svg',
CardType.red => 'lib/data/icons/red-card.svg',
};
return SizedBox(
width: 18,
height: 18,
child: SvgPicture.asset(
svgPath,
width: 18,
height: 18,
fit: BoxFit.contain,
),
);
}
}
String _teamName(Team team) => team == Team.home ? 'Home' : 'Away';
String _matchShareText(Match match) {
final buffer = StringBuffer()
..writeln('Match result')
..writeln(match.datetime)
..writeln('Home ${match.homeScore} - ${match.awayScore} Away');
if (match.goals.isNotEmpty) {
buffer.writeln();
buffer.writeln('Goals:');
for (final goal in match.goals) {
buffer.writeln(
'- ${_teamName(goal.team)} · #${goal.player.toString().padLeft(2, '0')} · ${_goalTypeName(goal.goalType)} · ${_formatTime(goal.seconds)}',
);
}
}
if (match.cards.isNotEmpty) {
buffer.writeln();
buffer.writeln('Cards:');
for (final card in match.cards) {
buffer.writeln(
'- ${_teamName(card.team)} · #${card.player.toString().padLeft(2, '0')} · ${_cardName(card.cardType)} card · ${_cardDurationLabel(card.duration)} · ${_formatTime(card.seconds)}',
);
}
}
return buffer.toString();
}
String _formatTime(int seconds) {
final minute = seconds ~/ 60;
final second = (seconds % 60).toString().padLeft(2, '0');
return '$minute:$second';
}
String _goalTypeName(GoalType type) => switch (type) {
GoalType.fieldGoal => 'Field goal',
GoalType.shortCorner => 'Short corner',
@@ -152,3 +288,9 @@ String _cardName(CardType type) => switch (type) {
CardType.yellow => 'Yellow',
CardType.green => 'Green',
};
String _cardDurationLabel(int durationSeconds) {
final minutes = durationSeconds ~/ 60;
final seconds = (durationSeconds % 60).toString().padLeft(2, '0');
return '$minutes:$seconds';
}