5 Commits

Author SHA1 Message Date
b5234c765c Changed create game button size
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m6s
Pull Request Pipeline / lint (pull_request) Successful in 2m8s
2025-11-26 12:40:06 +01:00
919c9f57ac Fixed button state 2025-11-26 12:35:34 +01:00
27424694ce Removed unnecessary prints 2025-11-26 12:31:33 +01:00
84338f8f66 Changed title 2025-11-26 12:28:11 +01:00
733df2dcb5 Changed highlight color 2025-11-26 12:27:07 +01:00
5 changed files with 25 additions and 22 deletions

View File

@@ -16,9 +16,9 @@ class CustomTheme {
static BoxDecoration highlightedBoxDecoration = BoxDecoration( static BoxDecoration highlightedBoxDecoration = BoxDecoration(
color: boxColor, color: boxColor,
border: Border.all(color: Colors.blue), border: Border.all(color: primaryColor),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
boxShadow: [BoxShadow(color: Colors.blue.withAlpha(120), blurRadius: 12)], boxShadow: [BoxShadow(color: primaryColor.withAlpha(120), blurRadius: 12)],
); );
static AppBarTheme appBarTheme = AppBarTheme( static AppBarTheme appBarTheme = AppBarTheme(

View File

@@ -36,7 +36,7 @@ class _ChooseRulesetViewState extends State<ChooseRulesetView> {
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
scrolledUnderElevation: 0, scrolledUnderElevation: 0,
title: const Text( title: const Text(
'Choose Gametype', 'Choose Ruleset',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
), ),
centerTitle: true, centerTitle: true,

View File

@@ -52,6 +52,9 @@ class _CreateGameViewState extends State<CreateGameView> {
/// the [ChooseRulesetView] /// the [ChooseRulesetView]
int selectedRulesetIndex = -1; int selectedRulesetIndex = -1;
/// The currently selected players
List<Player>? selectedPlayers;
/// List of available rulesets with their display names and descriptions /// List of available rulesets with their display names and descriptions
/// as tuples of (Ruleset, String, String) /// as tuples of (Ruleset, String, String)
List<(Ruleset, String, String)> rulesets = [ List<(Ruleset, String, String)> rulesets = [
@@ -174,14 +177,6 @@ class _CreateGameViewState extends State<CreateGameView> {
selectedGroupIndex = groupsList.indexWhere( selectedGroupIndex = groupsList.indexWhere(
(g) => g.id == selectedGroup?.id, (g) => g.id == selectedGroup?.id,
); );
print('selectedGroup: $selectedGroup');
print(
playerList
.where(
(p) => !selectedGroup!.members.any((m) => m.id == p.id),
)
.toList(),
);
setState(() {}); setState(() {});
}, },
child: Container( child: Container(
@@ -221,7 +216,9 @@ class _CreateGameViewState extends State<CreateGameView> {
) )
.toList(), .toList(),
onChanged: (value) { onChanged: (value) {
print(value); setState(() {
selectedPlayers = value;
});
}, },
), ),
), ),
@@ -230,21 +227,19 @@ class _CreateGameViewState extends State<CreateGameView> {
text: 'Create game', text: 'Create game',
sizeRelativeToWidth: 0.95, sizeRelativeToWidth: 0.95,
buttonType: ButtonType.primary, buttonType: ButtonType.primary,
onPressed: onPressed: _enableCreateGameButton()
(_gameNameController.text.isEmpty || ? () async {
selectedGroup == null ||
selectedRuleset == null)
? null
: () async {
Game game = Game( Game game = Game(
name: _gameNameController.text.trim(), name: _gameNameController.text.trim(),
createdAt: DateTime.now(), createdAt: DateTime.now(),
group: selectedGroup!, group: selectedGroup!,
players: selectedPlayers,
); );
// TODO: Replace with navigation to GameResultView() // TODO: Replace with navigation to GameResultView()
print('Created game: $game'); print('Created game: $game');
Navigator.pop(context); Navigator.pop(context);
}, }
: null,
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
], ],
@@ -266,4 +261,13 @@ class _CreateGameViewState extends State<CreateGameView> {
return 'Least Points'; return 'Least Points';
} }
} }
/// Determines whether the "Create Game" button should be enabled based on
/// the current state of the input fields.
bool _enableCreateGameButton() {
return _gameNameController.text.isNotEmpty &&
(selectedGroup != null ||
(selectedPlayers != null && selectedPlayers!.isNotEmpty)) &&
selectedRuleset != null;
}
} }

View File

@@ -178,12 +178,12 @@ class _GameHistoryViewState extends State<GameHistoryView> {
), ),
), ),
Positioned( Positioned(
bottom: 110, bottom: MediaQuery.paddingOf(context).bottom,
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
child: Center( child: Center(
child: CustomWidthButton( child: CustomWidthButton(
text: 'Create Game', text: 'Create Game',
sizeRelativeToWidth: 0.95, sizeRelativeToWidth: 0.90,
onPressed: () { onPressed: () {
Navigator.of(context).push( Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(

View File

@@ -92,7 +92,6 @@ class _GroupsViewState extends State<GroupsView> {
); );
}, },
), ),
Positioned( Positioned(
bottom: MediaQuery.paddingOf(context).bottom, bottom: MediaQuery.paddingOf(context).bottom,
child: CustomWidthButton( child: CustomWidthButton(