From 89e6d6cd8342bbbb4d653e83f07994a6db091146 Mon Sep 17 00:00:00 2001 From: Tim Kainz Date: Fri, 6 Mar 2026 23:48:48 +0100 Subject: [PATCH] Improve Detail View --- .../lib/models/tournament.dart | 25 ++++ .../lib/pages/tournament_detail_page.dart | 110 ++++++++++++++++-- 2 files changed, 126 insertions(+), 9 deletions(-) diff --git a/frontend_splatournament_manager/lib/models/tournament.dart b/frontend_splatournament_manager/lib/models/tournament.dart index 5157c10..323577d 100644 --- a/frontend_splatournament_manager/lib/models/tournament.dart +++ b/frontend_splatournament_manager/lib/models/tournament.dart @@ -4,6 +4,8 @@ class Tournament { final String description; final int maxTeamAmount; final int currentTeamAmount; + final String registrationStartDate; + final String registrationEndDate; Tournament({ required this.id, @@ -11,6 +13,8 @@ class Tournament { required this.description, required this.maxTeamAmount, required this.currentTeamAmount, + required this.registrationStartDate, + required this.registrationEndDate, }); factory Tournament.fromJson(dynamic json) { @@ -20,6 +24,27 @@ class Tournament { description: json['description'], maxTeamAmount: json['maxTeamAmount'], currentTeamAmount: json['currentTeamAmount'], + registrationStartDate: json['registrationStartDate'], + registrationEndDate: json['registrationEndDate'], ); } + + bool get isRegistrationOpen { + final now = DateTime.now(); + final startDate = DateTime.parse(registrationStartDate); + final endDate = DateTime.parse(registrationEndDate); + return now.isAfter(startDate) && now.isBefore(endDate); + } + + bool get isRegistrationPast { + final now = DateTime.now(); + final endDate = DateTime.parse(registrationEndDate); + return now.isAfter(endDate); + } + + bool get isRegistrationFuture { + final now = DateTime.now(); + final startDate = DateTime.parse(registrationStartDate); + return now.isBefore(startDate); + } } diff --git a/frontend_splatournament_manager/lib/pages/tournament_detail_page.dart b/frontend_splatournament_manager/lib/pages/tournament_detail_page.dart index 2e8a72c..d381d68 100644 --- a/frontend_splatournament_manager/lib/pages/tournament_detail_page.dart +++ b/frontend_splatournament_manager/lib/pages/tournament_detail_page.dart @@ -44,20 +44,112 @@ class _TournamentDetailPageState extends State { ), Builder( builder: (context) { - // Demo Content if (isShowingTeams) { - return Text("Teams"); + return TournamentTeamsWidget(tournament: widget.tournament); } - return Text("Not Teams"); + return TournamentContentWidget(tournament: widget.tournament); }, ), + SizedBox( + width: double.infinity, + child: Padding( + padding: const EdgeInsets.fromLTRB(12, 0, 12, 24), + child: ElevatedButton( + child: Text("Enter"), + onPressed: () { + //TODO: Backend Call + ScaffoldMessenger.of(context).clearSnackBars(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text("tournament entered")), + ); + }, + ), + ), + ), ], ), - floatingActionButton: FloatingActionButton( - child: Icon(Icons.dashboard_customize_rounded), - onPressed: () { - print("Tournament entered"); - }, + ); + } +} + +class TournamentTeamsWidget extends StatelessWidget{ + const TournamentTeamsWidget({super.key, required Tournament tournament}); + @override + Widget build(BuildContext context) { + return Expanded( + child: Column( children: [ + //TODO: Show participating Teams + Text("Teams"), + ],), + ); + } + +} + +class TournamentContentWidget extends StatelessWidget { + final Tournament tournament; + + const TournamentContentWidget({super.key, required this.tournament}); + + @override + Widget build(BuildContext context) { + return Expanded( + child: Column( + children: [ + SizedBox(height: 12), + Center( + child: Text(tournament.description, style: TextStyle(fontSize: 17)), + ), + SizedBox(height: 12), + Card.filled( + child: SizedBox( + width: double.infinity, + height: 225, + child: Padding( + padding: const EdgeInsets.fromLTRB(14, 18, 14, 14), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Registration Period", + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 17, + ), + ), + Text( + "${tournament.registrationStartDate} - ${tournament.registrationEndDate}", + ), + SizedBox(height: 24), + Text( + "Format", + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 17, + ), + ), + //TODO: Should show the format instead + Text(tournament.description), + Spacer(), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () { + //TODO: Redirect to Ongoing View + ScaffoldMessenger.of(context).clearSnackBars(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text("ongoing clicked")), + ); + }, + child: Text("View ongoing"), + ), + ), + ], + ), + ), + ), + ), + ], ), ); } @@ -85,7 +177,7 @@ class DetailHeader extends StatelessWidget { ), image: DecorationImage( fit: BoxFit.cover, - // Currently a demo image + //TODO: Replace with proper image image: NetworkImage( "https://flutter.dev/assets/image_1.w635.f71cbb614cd16a40bfb87e128278227c.png", ),