Add Backend Project and add Tournament Detail Page
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:frontend_splatournament_manager/state_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class TournamentDetailPage extends StatelessWidget {
|
||||
const TournamentDetailPage({super.key});
|
||||
final int tournamentId;
|
||||
const TournamentDetailPage({super.key, required this.tournamentId});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text("Tournament"),),
|
||||
body: Center(child: Text("Detail"),)
|
||||
body: Consumer<StateProvider>(builder: (BuildContext context, StateProvider value, Widget? child) {
|
||||
var tournament = value.availableTournaments.where((x) => x.id == tournamentId).firstOrNull;
|
||||
if(tournament == null){
|
||||
return Center(child: Text("Tournament not found!"));
|
||||
}
|
||||
return Text("${tournament.maxTeamAmount}");
|
||||
},)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,5 +30,5 @@ class StateProvider extends ChangeNotifier {
|
||||
}
|
||||
return[];
|
||||
}
|
||||
List<Tournament> get user => _availableTournaments ?? [];
|
||||
List<Tournament> get availableTournaments => _availableTournaments ?? [];
|
||||
}
|
||||
@@ -23,15 +23,16 @@ class AvailableTournamentList extends StatelessWidget {
|
||||
return ListView.builder(
|
||||
itemCount: list.length,
|
||||
itemBuilder: (context, index) {
|
||||
var tournament = list[index];
|
||||
return ListTile(
|
||||
leading: Icon(Icons.abc),
|
||||
title: Text(list[index].name),
|
||||
subtitle: Text(list[index].description),
|
||||
title: Text(tournament.name),
|
||||
subtitle: Text(tournament.description),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TournamentDetailPage(),
|
||||
builder: (context) => TournamentDetailPage(tournamentId: tournament.id,),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user