Improve Detail View

This commit is contained in:
2026-03-06 23:48:48 +01:00
parent f1a72e9817
commit 89e6d6cd83
2 changed files with 126 additions and 9 deletions

View File

@@ -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);
}
}