Improve Detail View
This commit is contained in:
@@ -4,6 +4,8 @@ class Tournament {
|
|||||||
final String description;
|
final String description;
|
||||||
final int maxTeamAmount;
|
final int maxTeamAmount;
|
||||||
final int currentTeamAmount;
|
final int currentTeamAmount;
|
||||||
|
final String registrationStartDate;
|
||||||
|
final String registrationEndDate;
|
||||||
|
|
||||||
Tournament({
|
Tournament({
|
||||||
required this.id,
|
required this.id,
|
||||||
@@ -11,6 +13,8 @@ class Tournament {
|
|||||||
required this.description,
|
required this.description,
|
||||||
required this.maxTeamAmount,
|
required this.maxTeamAmount,
|
||||||
required this.currentTeamAmount,
|
required this.currentTeamAmount,
|
||||||
|
required this.registrationStartDate,
|
||||||
|
required this.registrationEndDate,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Tournament.fromJson(dynamic json) {
|
factory Tournament.fromJson(dynamic json) {
|
||||||
@@ -20,6 +24,27 @@ class Tournament {
|
|||||||
description: json['description'],
|
description: json['description'],
|
||||||
maxTeamAmount: json['maxTeamAmount'],
|
maxTeamAmount: json['maxTeamAmount'],
|
||||||
currentTeamAmount: json['currentTeamAmount'],
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,20 +44,112 @@ class _TournamentDetailPageState extends State<TournamentDetailPage> {
|
|||||||
),
|
),
|
||||||
Builder(
|
Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
// Demo Content
|
|
||||||
if (isShowingTeams) {
|
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(
|
image: DecorationImage(
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
// Currently a demo image
|
//TODO: Replace with proper image
|
||||||
image: NetworkImage(
|
image: NetworkImage(
|
||||||
"https://flutter.dev/assets/image_1.w635.f71cbb614cd16a40bfb87e128278227c.png",
|
"https://flutter.dev/assets/image_1.w635.f71cbb614cd16a40bfb87e128278227c.png",
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user