Improve Detail View
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user