Compare commits
5 Commits
2838376434
...
b5234c765c
| Author | SHA1 | Date | |
|---|---|---|---|
| b5234c765c | |||
| 919c9f57ac | |||
| 27424694ce | |||
| 84338f8f66 | |||
| 733df2dcb5 |
@@ -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(
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
Reference in New Issue
Block a user