Compare commits
5 Commits
2838376434
...
b5234c765c
| Author | SHA1 | Date | |
|---|---|---|---|
| b5234c765c | |||
| 919c9f57ac | |||
| 27424694ce | |||
| 84338f8f66 | |||
| 733df2dcb5 |
@@ -16,9 +16,9 @@ class CustomTheme {
|
||||
|
||||
static BoxDecoration highlightedBoxDecoration = BoxDecoration(
|
||||
color: boxColor,
|
||||
border: Border.all(color: Colors.blue),
|
||||
border: Border.all(color: primaryColor),
|
||||
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(
|
||||
|
||||
@@ -36,7 +36,7 @@ class _ChooseRulesetViewState extends State<ChooseRulesetView> {
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
scrolledUnderElevation: 0,
|
||||
title: const Text(
|
||||
'Choose Gametype',
|
||||
'Choose Ruleset',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
centerTitle: true,
|
||||
|
||||
@@ -52,6 +52,9 @@ class _CreateGameViewState extends State<CreateGameView> {
|
||||
/// the [ChooseRulesetView]
|
||||
int selectedRulesetIndex = -1;
|
||||
|
||||
/// The currently selected players
|
||||
List<Player>? selectedPlayers;
|
||||
|
||||
/// List of available rulesets with their display names and descriptions
|
||||
/// as tuples of (Ruleset, String, String)
|
||||
List<(Ruleset, String, String)> rulesets = [
|
||||
@@ -174,14 +177,6 @@ class _CreateGameViewState extends State<CreateGameView> {
|
||||
selectedGroupIndex = groupsList.indexWhere(
|
||||
(g) => g.id == selectedGroup?.id,
|
||||
);
|
||||
print('selectedGroup: $selectedGroup');
|
||||
print(
|
||||
playerList
|
||||
.where(
|
||||
(p) => !selectedGroup!.members.any((m) => m.id == p.id),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
setState(() {});
|
||||
},
|
||||
child: Container(
|
||||
@@ -221,7 +216,9 @@ class _CreateGameViewState extends State<CreateGameView> {
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
print(value);
|
||||
setState(() {
|
||||
selectedPlayers = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -230,21 +227,19 @@ class _CreateGameViewState extends State<CreateGameView> {
|
||||
text: 'Create game',
|
||||
sizeRelativeToWidth: 0.95,
|
||||
buttonType: ButtonType.primary,
|
||||
onPressed:
|
||||
(_gameNameController.text.isEmpty ||
|
||||
selectedGroup == null ||
|
||||
selectedRuleset == null)
|
||||
? null
|
||||
: () async {
|
||||
onPressed: _enableCreateGameButton()
|
||||
? () async {
|
||||
Game game = Game(
|
||||
name: _gameNameController.text.trim(),
|
||||
createdAt: DateTime.now(),
|
||||
group: selectedGroup!,
|
||||
players: selectedPlayers,
|
||||
);
|
||||
// TODO: Replace with navigation to GameResultView()
|
||||
print('Created game: $game');
|
||||
Navigator.pop(context);
|
||||
},
|
||||
}
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
@@ -266,4 +261,13 @@ class _CreateGameViewState extends State<CreateGameView> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,12 +178,12 @@ class _GameHistoryViewState extends State<GameHistoryView> {
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 110,
|
||||
bottom: MediaQuery.paddingOf(context).bottom,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Center(
|
||||
child: CustomWidthButton(
|
||||
text: 'Create Game',
|
||||
sizeRelativeToWidth: 0.95,
|
||||
sizeRelativeToWidth: 0.90,
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
|
||||
@@ -92,7 +92,6 @@ class _GroupsViewState extends State<GroupsView> {
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Positioned(
|
||||
bottom: MediaQuery.paddingOf(context).bottom,
|
||||
child: CustomWidthButton(
|
||||
|
||||
Reference in New Issue
Block a user