cpd_David_und_Yusuf/lib/screens/settings.dart

139 lines
4.3 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:werwolf/screens/flippingcards.dart';
2024-05-10 23:21:21 +02:00
import '../models/game.dart';
import '../models/role.dart';
class GameSettings extends StatefulWidget {
final List<String> playernames;
const GameSettings({required this.playernames, super.key});
@override
State<GameSettings> createState() => _GameSettingsState();
}
class _GameSettingsState extends State<GameSettings> {
late Game game;
@override
void initState() {
game = Game(playernames: widget.playernames);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"Werwolf",
style: Theme.of(context).textTheme.titleLarge, // Apply text theme
),
centerTitle: true,
leading: IconButton(
icon: const Icon(FontAwesomeIcons.xmark),
onPressed: () {
Navigator.popUntil(context, ModalRoute.withName('/'));
},
),
),
body: Padding(
padding: const EdgeInsets.fromLTRB(30.0, 40.0, 30.0, 0.0),
child: Column(
children: [
Text(
"Anzahl der Spieler ${widget.playernames.length}",
style: Theme.of(context).textTheme.titleLarge, // Apply text theme
),
const Divider(
height: 60,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"Anzahl der Werwölfe ${game.getWolves()}",
style:
Theme.of(context).textTheme.bodyLarge, // Apply text theme
),
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,
),
Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 20),
child: Text(
"Spezielle Rollen",
style:
Theme.of(context).textTheme.titleLarge, // Apply text theme
),
),
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: Theme.of(context)
.textTheme
.bodyLarge, // Apply text theme
),
trailing: Switch(
value: game.specialRoles[role],
onChanged: (bool value) {
setState(() {
game.specialRoles[role] = value;
});
},
),
);
}
return Container();
},
),
),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
FlipingCard(players: game.getAllPlayers()),
),
);
},
child: Text(
'Spiel starten!',
),
),
const Padding(padding: EdgeInsets.all(30)),
],
),
),
);
}
}