import 'package:flutter/material.dart'; import 'package:werwolf/screens/flippingcards.dart'; import '../models/games.dart'; import '../models/role.dart'; class GameSettings extends StatefulWidget { final List playernames; const GameSettings({required this.playernames, super.key}); @override State createState() => _GameSettingsState(); } class _GameSettingsState extends State { late Game game; @override void initState() { game = Game(playernames: widget.playernames); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Werwolf"), centerTitle: true, ), body: Padding( padding: const EdgeInsets.fromLTRB(30.0, 40.0, 30.0, 0.0), child: Column( children: [ Text( "Anzahl der Spieler ${widget.playernames.length}", // hier muss noch die anzahl der spieler hin style: const TextStyle(color: Colors.white, fontSize: 18), ), const Divider( height: 60, color: Colors.grey, ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( "Anzahl der Werwölfe ${game.getWolves()}", style: const TextStyle(color: Colors.white, fontSize: 18), ), IconButton( onPressed: () { setState(() { game.decrementWolves(); }); }, icon: const Icon(Icons.remove, color: Colors.white)), IconButton( onPressed: () { setState(() { game.incrementWolves(); }); }, icon: const Icon(Icons.add, color: Colors.white)), ], ), const Divider( height: 60, color: Colors.grey, ), const Text( "Spezielle Rollen", style: TextStyle(color: Colors.white, fontSize: 18), ), Expanded( child: ListView.builder( itemCount: Role.values.length, itemBuilder: (context, index) { if (Role.values[index] != Role.dorfbewohner && Role.values[index] != Role.werwolf) { Role role = Role.values[index]; return ListTile( title: Text( role.stringValue, style: const TextStyle(color: Colors.white, fontSize: 16), ), trailing: Switch( value: game.specialRoles[role], trackColor: const MaterialStatePropertyAll( Color.fromARGB(255, 189, 189, 189)), thumbColor: const MaterialStatePropertyAll( Colors.black), onChanged: (bool value) { setState(() { game.specialRoles[role] = value; }); }), ); } return Container(); }, ), ), ElevatedButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => FlipingCard(players: game.getAllPlayers()), )); }, child: const Text('Spiel starten!'), ), ], ), ), ); } }