diff --git a/lib/core/enums.dart b/lib/core/enums.dart index 8c809b0..af1f4a6 100644 --- a/lib/core/enums.dart +++ b/lib/core/enums.dart @@ -22,3 +22,10 @@ enum ImportResult { /// - [ExportResult.canceled]: The export operation was canceled by the user. /// - [ExportResult.unknownException]: An exception occurred during export. enum ExportResult { success, canceled, unknownException } + +/// Different rulesets available for games +/// - [Ruleset.singleWinner]: The game is won by a single player +/// - [Ruleset.singleLoser]: The game is lost by a single player +/// - [Ruleset.mostPoints]: The player with the most points wins. +/// - [Ruleset.lastPoints]: The player with the fewest points wins. +enum Ruleset { singleWinner, singleLoser, mostPoints, lastPoints } diff --git a/lib/presentation/views/main_menu/create_game/choose_group_view.dart b/lib/presentation/views/main_menu/create_game/choose_group_view.dart new file mode 100644 index 0000000..168fb99 --- /dev/null +++ b/lib/presentation/views/main_menu/create_game/choose_group_view.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; +import 'package:game_tracker/core/custom_theme.dart'; +import 'package:game_tracker/data/dto/group.dart'; +import 'package:game_tracker/presentation/widgets/tiles/group_tile.dart'; + +class ChooseGroupView extends StatefulWidget { + final List groups; + + const ChooseGroupView({super.key, required this.groups}); + + @override + State createState() => _ChooseGroupViewState(); +} + +class _ChooseGroupViewState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: CustomTheme.backgroundColor, + appBar: AppBar( + backgroundColor: CustomTheme.backgroundColor, + scrolledUnderElevation: 0, + title: const Text( + 'Choose Group', + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + ), + centerTitle: true, + ), + body: ListView.builder( + padding: const EdgeInsets.only(bottom: 85), + itemCount: widget.groups.length, + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () => Navigator.of(context).pop(widget.groups[index]), + child: GroupTile(group: widget.groups[index]), + ); + }, + ), + ); + } +} diff --git a/lib/presentation/views/main_menu/create_game/choose_ruleset_view.dart b/lib/presentation/views/main_menu/create_game/choose_ruleset_view.dart new file mode 100644 index 0000000..5939405 --- /dev/null +++ b/lib/presentation/views/main_menu/create_game/choose_ruleset_view.dart @@ -0,0 +1,95 @@ +import 'package:flutter/material.dart'; +import 'package:game_tracker/core/custom_theme.dart'; +import 'package:game_tracker/core/enums.dart'; + +class ChooseRulesetView extends StatefulWidget { + const ChooseRulesetView({super.key}); + + @override + State createState() => _ChooseRulesetViewState(); +} + +class _ChooseRulesetViewState extends State { + List<(Ruleset, String, String)> rulesets = [ + ( + Ruleset.singleWinner, + 'Single Winner', + 'Exactly one winner is chosen; ties are resolved by a predefined tiebreaker.', + ), + ( + Ruleset.singleLoser, + 'Single Loser', + 'Exactly one loser is determined; last place receives the penalty or consequence.', + ), + ( + Ruleset.mostPoints, + 'Most Points', + 'Traditional ruleset: the player with the most points wins.', + ), + ( + Ruleset.lastPoints, + 'Least Points', + 'Inverse scoring: the player with the fewest points wins.', + ), + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: CustomTheme.backgroundColor, + appBar: AppBar( + backgroundColor: CustomTheme.backgroundColor, + scrolledUnderElevation: 0, + title: const Text( + 'Choose Group', + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + ), + centerTitle: true, + ), + body: ListView.builder( + padding: const EdgeInsets.only(bottom: 85), + itemCount: rulesets.length, + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () => Navigator.of(context).pop(rulesets[index].$1), + child: Container( + margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), + padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12), + decoration: BoxDecoration( + color: CustomTheme.boxColor, + border: Border.all(color: CustomTheme.boxBorder), + borderRadius: BorderRadius.circular(12), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: Text( + rulesets[index].$2, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), + ), + ], + ), + const SizedBox(height: 5), + Text( + rulesets[index].$3, + style: const TextStyle(fontSize: 14), + ), + const SizedBox(height: 2.5), + ], + ), + ), + ); + }, + ), + ); + } +}