diff --git a/wrestling_scoreboard_client/lib/ui/overview/league_overview.dart b/wrestling_scoreboard_client/lib/ui/overview/league_overview.dart index 8903ed42..e2c4ef0f 100644 --- a/wrestling_scoreboard_client/lib/ui/overview/league_overview.dart +++ b/wrestling_scoreboard_client/lib/ui/overview/league_overview.dart @@ -8,6 +8,7 @@ import 'package:wrestling_scoreboard_client/ui/edit/league_edit.dart'; import 'package:wrestling_scoreboard_client/ui/edit/league_team_participation_edit.dart'; import 'package:wrestling_scoreboard_client/ui/edit/league_weight_class_edit.dart'; import 'package:wrestling_scoreboard_client/ui/overview/league_weight_class_overview.dart'; +import 'package:wrestling_scoreboard_client/ui/overview/shared/matches_widget.dart'; import 'package:wrestling_scoreboard_client/ui/overview/team_overview.dart'; import 'package:wrestling_scoreboard_client/util/date_time.dart'; import 'package:wrestling_scoreboard_client/util/network/data_provider.dart'; @@ -87,6 +88,7 @@ class LeagueOverview extends StatelessWidget { ); }, ), + MatchesWidget(filterObject: data), ManyConsumer( filterObject: data, builder: (BuildContext context, List leagueWeightClasses) { diff --git a/wrestling_scoreboard_client/lib/ui/overview/shared/matches_widget.dart b/wrestling_scoreboard_client/lib/ui/overview/shared/matches_widget.dart new file mode 100644 index 00000000..14e26814 --- /dev/null +++ b/wrestling_scoreboard_client/lib/ui/overview/shared/matches_widget.dart @@ -0,0 +1,77 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:wrestling_scoreboard_client/ui/components/consumer.dart'; +import 'package:wrestling_scoreboard_client/ui/components/grouped_list.dart'; +import 'package:wrestling_scoreboard_client/ui/edit/team_match_edit.dart'; +import 'package:wrestling_scoreboard_client/ui/match/match_sequence.dart'; +import 'package:wrestling_scoreboard_client/util/date_time.dart'; +import 'package:wrestling_scoreboard_common/common.dart'; + +class MatchesWidget extends StatelessWidget { + final T? filterObject; + + const MatchesWidget({super.key, required this.filterObject}); + + @override + Widget build(BuildContext context) { + final localizations = AppLocalizations.of(context)!; + return ManyConsumer( + filterObject: filterObject, + builder: (BuildContext context, List matches) { + return ListGroup( + header: HeadingItem( + title: localizations.matches, + trailing: IconButton( + icon: const Icon(Icons.add), + onPressed: () => + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + TeamMatchEdit( + initialHomeTeam: filterObject is Team ? filterObject as Team : null, + initialGuestTeam: filterObject is Team ? filterObject as Team : null, + ), + ), + ), + ), + ), + items: matches.map( + (e) => + SingleConsumer( + id: e.id!, + initialData: e, + builder: (context, match) => + ListTile( + title: RichText( + text: TextSpan( + text: '${match!.date.toDateString(context)}, ${match.no ?? 'no ID'}, ', + children: [ + TextSpan( + text: match.home.team.name, + style: match.home.team == filterObject + ? const TextStyle(color: Colors.red, fontWeight: FontWeight.bold) + : null), + const TextSpan(text: ' - '), + TextSpan( + text: match.guest.team.name, + style: match.guest.team == filterObject + ? const TextStyle(color: Colors.blue, fontWeight: FontWeight.bold) + : null), + ], + ), + ), + leading: const Icon(Icons.event), + onTap: () => handleSelectedMatch(match, context), + ), + ), + ), + ); + }, + ); + } + + handleSelectedMatch(TeamMatch match, BuildContext context) async { + Navigator.push(context, MaterialPageRoute(builder: (context) => MatchSequence(match))); + } +} diff --git a/wrestling_scoreboard_client/lib/ui/overview/team_overview.dart b/wrestling_scoreboard_client/lib/ui/overview/team_overview.dart index 2e26236a..dd9dd5e3 100644 --- a/wrestling_scoreboard_client/lib/ui/overview/team_overview.dart +++ b/wrestling_scoreboard_client/lib/ui/overview/team_overview.dart @@ -1,14 +1,12 @@ -import 'package:wrestling_scoreboard_common/common.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:wrestling_scoreboard_client/ui/components/consumer.dart'; import 'package:wrestling_scoreboard_client/ui/components/grouped_list.dart'; import 'package:wrestling_scoreboard_client/ui/components/info.dart'; import 'package:wrestling_scoreboard_client/ui/edit/team_edit.dart'; -import 'package:wrestling_scoreboard_client/ui/edit/team_match_edit.dart'; -import 'package:wrestling_scoreboard_client/ui/match/match_sequence.dart'; -import 'package:wrestling_scoreboard_client/util/date_time.dart'; +import 'package:wrestling_scoreboard_client/ui/overview/shared/matches_widget.dart'; import 'package:wrestling_scoreboard_client/util/network/data_provider.dart'; +import 'package:wrestling_scoreboard_common/common.dart'; class TeamOverview extends StatelessWidget { final Team filterObject; @@ -47,62 +45,9 @@ class TeamOverview extends StatelessWidget { ), body: GroupedList(items: [ description, - ManyConsumer( - filterObject: data, - builder: (BuildContext context, List matches) { - return ListGroup( - header: HeadingItem( - title: localizations.matches, - trailing: IconButton( - icon: const Icon(Icons.add), - onPressed: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => TeamMatchEdit( - initialHomeTeam: data, - initialGuestTeam: data, - ), - ), - ), - ), - ), - items: matches.map( - (e) => SingleConsumer( - id: e.id!, - initialData: e, - builder: (context, match) => ListTile( - title: RichText( - text: TextSpan( - text: '${match!.date.toDateString(context)}, ${match.no ?? 'no ID'}, ', - children: [ - TextSpan( - text: match.home.team.name, - style: match.home.team == data - ? const TextStyle(color: Colors.red, fontWeight: FontWeight.bold) - : null), - const TextSpan(text: ' - '), - TextSpan( - text: match.guest.team.name, - style: match.guest.team == data - ? const TextStyle(color: Colors.blue, fontWeight: FontWeight.bold) - : null), - ], - ), - ), - leading: const Icon(Icons.event), - onTap: () => handleSelectedMatch(match, context), - ), - ), - ), - ); - }, - ), + MatchesWidget(filterObject: data), ]), ); }); } - - handleSelectedMatch(TeamMatch match, BuildContext context) async { - Navigator.push(context, MaterialPageRoute(builder: (context) => MatchSequence(match))); - } } diff --git a/wrestling_scoreboard_client/pubspec.lock b/wrestling_scoreboard_client/pubspec.lock index db1903cc..38b97d6c 100644 --- a/wrestling_scoreboard_client/pubspec.lock +++ b/wrestling_scoreboard_client/pubspec.lock @@ -285,22 +285,6 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.1" - leak_tracker: - dependency: transitive - description: - name: leak_tracker - sha256: "04be76c4a4bb50f14904e64749237e541e7c7bcf7ec0b196907322ab5d2fc739" - url: "https://pub.dev" - source: hosted - version: "9.0.16" - leak_tracker_testing: - dependency: transitive - description: - name: leak_tracker_testing - sha256: b06739349ec2477e943055aea30172c5c7000225f79dad4702e2ec0eda79a6ff - url: "https://pub.dev" - source: hosted - version: "1.0.5" lints: dependency: transitive description: @@ -321,18 +305,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.10.0" nested: dependency: transitive description: @@ -626,22 +610,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 - url: "https://pub.dev" - source: hosted - version: "13.0.0" web: dependency: transitive description: name: web - sha256: edc8a9573dd8c5a83a183dae1af2b6fd4131377404706ca4e5420474784906fa + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 url: "https://pub.dev" source: hosted - version: "0.4.0" + version: "0.3.0" web_socket_channel: dependency: "direct main" description: diff --git a/wrestling_scoreboard_server/lib/controllers/league_controller.dart b/wrestling_scoreboard_server/lib/controllers/league_controller.dart index b20365e4..17ad3257 100644 --- a/wrestling_scoreboard_server/lib/controllers/league_controller.dart +++ b/wrestling_scoreboard_server/lib/controllers/league_controller.dart @@ -3,6 +3,7 @@ import 'package:wrestling_scoreboard_server/controllers/entity_controller.dart'; import 'package:wrestling_scoreboard_server/controllers/league_team_participation_controller.dart'; import 'package:wrestling_scoreboard_server/controllers/league_weight_class_controller.dart'; import 'package:wrestling_scoreboard_server/controllers/team_controller.dart'; +import 'package:wrestling_scoreboard_server/controllers/team_match_controller.dart'; import 'package:wrestling_scoreboard_server/controllers/weight_class_controller.dart'; import 'package:shelf/shelf.dart'; @@ -45,4 +46,9 @@ class LeagueController extends EntityController { return EntityController.handleRequestManyOfController(LeagueTeamParticipationController(), isRaw: isRaw(request), conditions: ['league_id = @id'], substitutionValues: {'id': id}); } + + Future requestTeamMatchs(Request request, String id) async { + return EntityController.handleRequestManyOfController(TeamMatchController(), + isRaw: isRaw(request), conditions: ['league_id = @id'], substitutionValues: {'id': id}); + } } diff --git a/wrestling_scoreboard_server/lib/routes/api_route.dart b/wrestling_scoreboard_server/lib/routes/api_route.dart index 5683307c..04cd8e4d 100644 --- a/wrestling_scoreboard_server/lib/routes/api_route.dart +++ b/wrestling_scoreboard_server/lib/routes/api_route.dart @@ -1,7 +1,7 @@ -import 'package:wrestling_scoreboard_server/controllers/league_team_participation_controller.dart'; -import 'package:wrestling_scoreboard_server/controllers/league_weight_class_controller.dart'; import 'package:shelf/shelf.dart'; import 'package:shelf_router/shelf_router.dart'; +import 'package:wrestling_scoreboard_server/controllers/league_team_participation_controller.dart'; +import 'package:wrestling_scoreboard_server/controllers/league_weight_class_controller.dart'; import '../controllers/bout_config_controller.dart'; import '../controllers/club_controller.dart'; @@ -45,12 +45,12 @@ class ApiRoute { router.get('/fights', fightController.requestMany); router.get('/fight/', fightController.requestSingle); router.get('/fight//fight_actions', fightController.requestFightActions); - + final fightActionController = FightActionController(); router.post('/fight_action', fightActionController.postSingle); router.get('/fight_actions', fightActionController.requestMany); router.get('/fight_action/', fightActionController.requestSingle); - + final leagueController = LeagueController(); router.post('/league', leagueController.postSingle); router.get('/leagues', leagueController.requestMany); @@ -59,6 +59,7 @@ class ApiRoute { router.get('/league//weight_classs', leagueController.requestWeightClasses); router.get('/league//league_weight_classs', leagueController.requestLeagueWeightClasses); router.get('/league//league_team_participations', leagueController.requestLeagueTeamParticipations); + router.get('/league//team_matchs', leagueController.requestTeamMatchs); final leagueWeightClassController = LeagueWeightClassController(); router.post('/league_weight_class', leagueWeightClassController.postSingle); @@ -80,7 +81,7 @@ class ApiRoute { router.post('/membership', membershipController.postSingle); router.get('/memberships', membershipController.requestMany); router.get('/membership/', membershipController.requestSingle); - + final participantStateController = ParticipantStateController(); router.post('/participant_state', participantStateController.postSingle); router.get('/participant_states', participantStateController.requestMany); @@ -101,7 +102,7 @@ class ApiRoute { router.get('/teams', teamController.requestMany); router.get('/team/', teamController.requestSingle); router.get('/team//team_matchs', teamController.requestTeamMatches); - + final matchController = TeamMatchController(); router.post('/team_match', matchController.postSingle); router.get('/team_matchs', matchController.requestMany); @@ -109,7 +110,7 @@ class ApiRoute { router.get('/team_match/', matchController.requestSingle); router.post('/team_match//fights/generate', matchController.generateFights); router.get('/team_match//fights', matchController.requestFights); - + final teamMatchFightController = TeamMatchFightController(); router.post('/team_match_fight', teamMatchFightController.postSingle); router.get('/team_match_fights', teamMatchFightController.requestMany);