From 97c10c8d12855e3b51f996d1ce0fd4db0e9868c4 Mon Sep 17 00:00:00 2001 From: kejaro Date: Sun, 27 Sep 2026 20:41:18 +0100 Subject: [PATCH] Updates --- mobile_app/lib/data/icons/green-card.svg | 8 + mobile_app/lib/data/icons/red-card.svg | 7 + mobile_app/lib/data/icons/yellow-card.svg | 9 + mobile_app/lib/data/results.json | 2 +- .../dashboard/views/match_results_view.dart | 170 +++++++- mobile_app/pubspec.lock | 375 +++++++++++++++++- mobile_app/pubspec.yaml | 4 + 7 files changed, 559 insertions(+), 16 deletions(-) create mode 100644 mobile_app/lib/data/icons/green-card.svg create mode 100644 mobile_app/lib/data/icons/red-card.svg create mode 100644 mobile_app/lib/data/icons/yellow-card.svg diff --git a/mobile_app/lib/data/icons/green-card.svg b/mobile_app/lib/data/icons/green-card.svg new file mode 100644 index 0000000..db0c21f --- /dev/null +++ b/mobile_app/lib/data/icons/green-card.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/mobile_app/lib/data/icons/red-card.svg b/mobile_app/lib/data/icons/red-card.svg new file mode 100644 index 0000000..3639ea1 --- /dev/null +++ b/mobile_app/lib/data/icons/red-card.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/mobile_app/lib/data/icons/yellow-card.svg b/mobile_app/lib/data/icons/yellow-card.svg new file mode 100644 index 0000000..88bd43d --- /dev/null +++ b/mobile_app/lib/data/icons/yellow-card.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/mobile_app/lib/data/results.json b/mobile_app/lib/data/results.json index fe9a726..db6dc6a 100644 --- a/mobile_app/lib/data/results.json +++ b/mobile_app/lib/data/results.json @@ -13,7 +13,7 @@ "team": 1 }, { - "card_type": 1, + "card_type": 2, "datetime": "2023-10-01T12:35:00Z", "duration": 120, "player": 8, diff --git a/mobile_app/lib/ui/features/dashboard/views/match_results_view.dart b/mobile_app/lib/ui/features/dashboard/views/match_results_view.dart index e3a3164..197191b 100644 --- a/mobile_app/lib/ui/features/dashboard/views/match_results_view.dart +++ b/mobile_app/lib/ui/features/dashboard/views/match_results_view.dart @@ -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'; +} diff --git a/mobile_app/pubspec.lock b/mobile_app/pubspec.lock index 442c55a..a9dbcc9 100644 --- a/mobile_app/pubspec.lock +++ b/mobile_app/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" async: dependency: transitive description: @@ -33,6 +41,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.3" + code_assets: + dependency: transitive + description: + name: code_assets + sha256: bf394f466ba9205f1812a0433b392d6af280f155f56651eda7c18cc32ed493b8 + url: "https://pub.dev" + source: hosted + version: "1.2.1" collection: dependency: transitive description: @@ -41,6 +57,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.19.1" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: f141ea4f277af142a0356955707f6556f37b03947d39d55585981a06ca437bd6 + url: "https://pub.dev" + source: hosted + version: "0.3.5+5" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.dev" + source: hosted + version: "3.0.7" cupertino_icons: dependency: "direct main" description: @@ -57,6 +89,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" flutter: dependency: "direct main" description: flutter @@ -70,11 +126,72 @@ packages: url: "https://pub.dev" source: hosted version: "6.0.0" + flutter_svg: + dependency: "direct main" + description: + name: flutter_svg + sha256: "35882981abcbfb8c15b286f0cd690ff25bac12d95eff3e25ee207f37d4c42e7f" + url: "https://pub.dev" + source: hosted + version: "2.3.0" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + hooks: + dependency: transitive + description: + name: hooks + sha256: "9a62a50b50b769a737bc0a8ff381f333529df3ab746b2f6b02e83760231455ba" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + http: + dependency: transitive + description: + name: http + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" + url: "https://pub.dev" + source: hosted + version: "1.6.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + jni: + dependency: transitive + description: + name: jni + sha256: f038e58b4dc2c9037f50e233175086337e0b305e356d28211bf55f21c504cbd3 + url: "https://pub.dev" + source: hosted + version: "1.0.3" + jni_flutter: + dependency: transitive + description: + name: jni_flutter + sha256: b2310cdd4c18c65c081ab141a41efa94aa26c65431803703ece51996f174f351 + url: "https://pub.dev" + source: hosted + version: "1.0.3" + jni_util: + dependency: transitive + description: + name: jni_util + sha256: "1ba86da04a5f2bf18fde2edb235587e70c5b0fc5bd4ba955f46b00942c3fc35f" + url: "https://pub.dev" + source: hosted + version: "1.0.0" leak_tracker: dependency: transitive description: @@ -107,6 +224,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.0" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" matcher: dependency: transitive description: @@ -131,6 +256,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.3" + mime: + dependency: transitive + description: + name: mime + sha256: bd47de35f07e27267e69c8c8b22edf9473bfee170a60d60fcc93730c5144b7f6 + url: "https://pub.dev" + source: hosted + version: "2.1.0" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: b7fb95a6d9a4f009edd63dc5ac69f07420b23a16161c6dd8660290b59c602e8e + url: "https://pub.dev" + source: hosted + version: "9.5.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: ffcf4cf3d6c0b74ac43708d9f56625506e8a68aa935abe9d267a7330f320eb5d + url: "https://pub.dev" + source: hosted + version: "3.0.0" path: dependency: transitive description: @@ -139,6 +288,118 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" + path_parsing: + dependency: transitive + description: + name: path_parsing + sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: a7f4874f987173da295a61c181b8ee71dab59b332a486b391babf26a1b884825 + url: "https://pub.dev" + source: hosted + version: "2.1.6" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699" + url: "https://pub.dev" + source: hosted + version: "2.6.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: "58c2005f147315b11e9b4a7bc889cd5203e250cba8e3f012dae259b4972b5c16" + url: "https://pub.dev" + source: hosted + version: "2.2.2" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "484838772624c3a4b94f1e44a3e19897fee738f2d5c4ce448443b0417f7c9dda" + url: "https://pub.dev" + source: hosted + version: "2.1.3" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675" + url: "https://pub.dev" + source: hosted + version: "7.0.2" + platform: + dependency: transitive + description: + name: platform + sha256: a36d119c13416516a7b5913fbe8af8531e11633d784c550b2125f76c758524ec + url: "https://pub.dev" + source: hosted + version: "3.2.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "261236774e8b1d69cfc6b9eabbc96c40f25e7a2d6b171f3385d4f65d5734fb24" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + record_use: + dependency: transitive + description: + name: record_use + sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + share_plus: + dependency: "direct main" + description: + name: share_plus + sha256: d7dc0630a923883c6328ca31b89aa682bacbf2f8304162d29f7c6aaff03a27a1 + url: "https://pub.dev" + source: hosted + version: "11.1.0" + share_plus_platform_interface: + dependency: transitive + description: + name: share_plus_platform_interface + sha256: "88023e53a13429bd65d8e85e11a9b484f49d4c190abbd96c7932b74d6927cc9a" + url: "https://pub.dev" + source: hosted + version: "6.1.0" sky_engine: dependency: transitive description: flutter @@ -192,6 +453,78 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.12" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "10f86fef4c2c43563fa6c211ff9cf757adf4d3ab762c56bd430664a947d70cd0" + url: "https://pub.dev" + source: hosted + version: "3.2.3" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "85c81589622fbc87c1c683aaea164d3604a7777495a79d91e39ffcdec39ddb34" + url: "https://pub.dev" + source: hosted + version: "2.4.3" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "6c5ad3f22cd4c38e089b81963b3cd7bb83b111b2df5dce008bb066162f42e429" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + uuid: + dependency: transitive + description: + name: uuid + sha256: "9b129329f58692f6e6578329498a8fe9fbe98f090beb764ffbb8ee2eadd01dcd" + url: "https://pub.dev" + source: hosted + version: "4.6.0" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: "9d0e3b9cb16542ad660daee871e726a10d13a93b7b5391677c3160e8f5e83935" + url: "https://pub.dev" + source: hosted + version: "1.2.3" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146" + url: "https://pub.dev" + source: hosted + version: "1.1.13" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: "4dca4feb77dc3ec7f6e27e49c53241eb8217f55e4f9b12599a27f8903bca5682" + url: "https://pub.dev" + source: hosted + version: "1.3.0" vector_math: dependency: transitive description: @@ -208,6 +541,46 @@ packages: url: "https://pub.dev" source: hosted version: "15.3.0" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + win32: + dependency: transitive + description: + name: win32 + sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e + url: "https://pub.dev" + source: hosted + version: "5.15.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + xml: + dependency: transitive + description: + name: xml + sha256: "67f0aff7be013d107995e9b75bf4e7f2c3ef2dfdb2c8e68024bba0a7fd5756a4" + url: "https://pub.dev" + source: hosted + version: "7.0.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: f67cdd8e07d3c6329146aaef1ba043542b3134c12489f553ca9a7435d1068aea + url: "https://pub.dev" + source: hosted + version: "3.1.4" sdks: dart: ">=3.13.3 <4.0.0" - flutter: ">=3.18.0-18.0.pre.54" + flutter: ">=3.38.4" diff --git a/mobile_app/pubspec.yaml b/mobile_app/pubspec.yaml index fb1975f..39bc8fd 100644 --- a/mobile_app/pubspec.yaml +++ b/mobile_app/pubspec.yaml @@ -31,6 +31,9 @@ dependencies: flutter: sdk: flutter + flutter_svg: ^2.1.0 + share_plus: ^11.0.0 + # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 @@ -59,6 +62,7 @@ flutter: assets: - lib/data/results.json + - lib/data/icons/ # To add assets to your application, add an assets section, like this: # assets: