178 Commits

Author SHA1 Message Date
ab20bd764b implement draft blur navbar
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m0s
Pull Request Pipeline / lint (pull_request) Failing after 2m6s
2026-01-11 11:30:00 +01:00
8ca4e3210e remove button in match view for testing 2026-01-11 11:28:21 +01:00
a480530919 Merge branch 'development' into enhancement/138-neues-navbar-design
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m31s
Pull Request Pipeline / lint (pull_request) Successful in 2m34s
# Conflicts:
#	pubspec.yaml
2026-01-10 22:18:54 +01:00
906c8d8450 Merge pull request 'Versions- und Build Nr in Einstellungen' (#149) from enhancement/146-versions-und-build-nr-in-einstellungen into development
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 1m58s
Pull Request Pipeline / lint (pull_request) Successful in 2m7s
Reviewed-on: #149
Reviewed-by: Mathis Kirchner <mathis.kirchner.mk@gmail.com>
2026-01-10 20:56:25 +00:00
000bdc8cbc Merge remote-tracking branch 'origin/development' into enhancement/146-versions-und-build-nr-in-einstellungen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-10 21:54:09 +01:00
497f30421d Updated string
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m9s
Pull Request Pipeline / lint (pull_request) Successful in 2m9s
2026-01-10 21:29:45 +01:00
adedb85eb2 Merge pull request 'Gruppen nach Spielern durchsuchen' (#147) from enhancement/136-gruppen-nach-spielern-durchsuchen into development
Reviewed-on: #147
Reviewed-by: Felix Kirchner <felix.kirchner.fk@gmail.com>
2026-01-10 20:27:53 +00:00
2a72332bcd Updated error string
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m9s
2026-01-10 21:23:28 +01:00
7aa41abe61 Implemented version number 2026-01-10 16:20:21 +01:00
e1263d51ad Merge branch 'development' into enhancement/136-gruppen-nach-spielern-durchsuchen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m0s
Pull Request Pipeline / lint (pull_request) Successful in 2m3s
2026-01-10 15:06:17 +00:00
8791b5296e Merge pull request 'MatchSummaryTile durch MatchTile ersetzen' (#142) from enhancement/137-matchsummarytile-durch-matchtile-ersetzen into development
Reviewed-on: #142
Reviewed-by: Mathis Kirchner <mathis.kirchner.mk@gmail.com>
2026-01-10 15:05:42 +00:00
f2a4327166 Implemented adaptive page route
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m4s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-10 15:55:19 +01:00
d34990ed50 Removed print 2026-01-10 15:54:41 +01:00
2ef671884d New method for specific winner refreshing 2026-01-10 15:54:11 +01:00
2ef8eb6534 Made winner field non final 2026-01-10 15:53:31 +01:00
6f0e5ba5c2 add ability to search for groups members in choose_group_view.dart
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-10 15:19:18 +01:00
1c07346aaf Updated version
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m20s
Pull Request Pipeline / lint (pull_request) Successful in 2m28s
2026-01-10 15:16:09 +01:00
830a64b5dd Small changes
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m29s
Pull Request Pipeline / lint (pull_request) Successful in 2m32s
2026-01-10 15:15:52 +01:00
9221f64fa5 Merge branch 'development' into enhancement/137-matchsummarytile-durch-matchtile-ersetzen
# Conflicts:
#	lib/presentation/views/main_menu/match_view/match_view.dart
#	pubspec.yaml
2026-01-10 15:15:14 +01:00
c4f6749882 Fixed state issue in home view
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m2s
Pull Request Pipeline / lint (pull_request) Successful in 2m3s
2026-01-10 15:13:56 +01:00
14a043785e Merge pull request 'PageRoutes adaptable machen' (#145) from enhancement/128-PageRoutes-adaptable-machen into development
Reviewed-on: #145
Reviewed-by: gelbeinhalb <spam@yannick-weigert.de>
Reviewed-by: Felix Kirchner <felix.kirchner.fk@gmail.com>
2026-01-10 14:06:10 +00:00
9eb9c0eb7f remove unneccessary import
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m18s
Pull Request Pipeline / lint (pull_request) Successful in 2m18s
2026-01-10 15:02:01 +01:00
54ec865f04 fix merge issues
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m14s
Pull Request Pipeline / lint (pull_request) Failing after 2m23s
2026-01-10 15:00:33 +01:00
d5e7a17127 Merge remote-tracking branch 'origin/development' into enhancement/128-PageRoutes-adaptable-machen
# Conflicts:
#	lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart
2026-01-10 14:57:33 +01:00
275f64b296 Merge pull request 'SnackBar Sichtbarkeit' (#144) from bug/130-Snackbar-Sichtbarkeit into development
Reviewed-on: #144
Reviewed-by: gelbeinhalb <spam@yannick-weigert.de>
Reviewed-by: Felix Kirchner <felix.kirchner.fk@gmail.com>
2026-01-10 13:54:57 +00:00
97ca62b083 refactor: rename AdaptivePageRoute to adaptivePageRoute for lowerCamelCase
All checks were successful
Pull Request Pipeline / lint (pull_request) Successful in 2m13s
Pull Request Pipeline / test (pull_request) Successful in 2m18s
2026-01-10 14:52:59 +01:00
32fb1550ff Merge remote-tracking branch 'origin/enhancement/128-PageRoutes-adaptable-machen' into enhancement/128-PageRoutes-adaptable-machen
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m4s
Pull Request Pipeline / lint (pull_request) Failing after 2m10s
# Conflicts:
#	lib/main.dart
2026-01-10 14:44:53 +01:00
d67972624e replaced ternary operator solution with custom adaptive_page_route.dart 2026-01-10 14:44:33 +01:00
595cf6ead0 Changed skeleton data from 3 to 2 tiles
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m2s
Pull Request Pipeline / lint (pull_request) Successful in 2m4s
2026-01-10 14:20:09 +01:00
6faafe9fab Changed android page transition to Android U transition
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m5s
Pull Request Pipeline / lint (pull_request) Successful in 2m8s
2026-01-10 14:16:16 +01:00
66b90aac25 Fixed issue with android page transition
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m5s
2026-01-10 14:09:08 +01:00
d22855fc1a Fixed match view tile width
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m6s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-10 13:57:54 +01:00
1be86bc3c5 Added theme box design 2026-01-10 13:57:46 +01:00
db3e8215fa Added ios swipe back gesture
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-10 13:42:09 +01:00
2c4cef76d8 Reimplemented info tile & match tile into it
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m3s
2026-01-09 23:55:29 +01:00
a4ef9705f9 made PageRoutes adapt to os, default to MaterialPageRoute
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m4s
Pull Request Pipeline / lint (pull_request) Successful in 2m7s
2026-01-09 22:22:26 +01:00
799c849570 wrap every view that uses a snackbar in ScaffoldMessenger
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-09 21:55:58 +01:00
799b7d8403 Implemented new nav bar with selected animation
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m7s
2026-01-09 21:12:09 +01:00
644728a9df Removed unneccesary code
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m4s
2026-01-09 20:19:23 +01:00
afb7a5f1d4 MatchTiles only show when recent games are available 2026-01-09 20:15:50 +01:00
3d510d5b3d Implemented compact mode for match tiles 2026-01-09 20:04:10 +01:00
a9d2325eee Implemented match tile in home view 2026-01-09 19:50:51 +01:00
349ff948de Modified match tile 2026-01-09 19:50:44 +01:00
c2394c3733 Merge pull request 'MVP-Refactoring' (#139) from refactoring/68-mvp-refactoring into development
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m6s
Pull Request Pipeline / lint (pull_request) Successful in 2m8s
Reviewed-on: #139
Reviewed-by: gelbeinhalb <spam@yannick-weigert.de>
Reviewed-by: Mathis Kirchner <mathis.kirchner.mk@gmail.com>
2026-01-08 20:24:01 +00:00
88766652b9 Small loc corrections
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m6s
Pull Request Pipeline / lint (pull_request) Successful in 2m21s
2026-01-08 21:21:33 +01:00
2a1573ee2d Remove Whitespace
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m12s
Pull Request Pipeline / lint (pull_request) Successful in 2m15s
2026-01-08 21:15:01 +01:00
cfb07bfe28 Updated localizations
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m14s
Pull Request Pipeline / lint (pull_request) Successful in 2m18s
2026-01-08 21:13:24 +01:00
d741990f2f Fixed navbar issue
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m4s
Pull Request Pipeline / lint (pull_request) Successful in 2m9s
2026-01-08 21:07:30 +01:00
76121eb4fb Updated localizations
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m6s
Pull Request Pipeline / lint (pull_request) Successful in 2m18s
2026-01-07 17:30:19 +01:00
d5ee6449b0 Updated localizations
All checks were successful
Pull Request Pipeline / lint (pull_request) Successful in 2m11s
Pull Request Pipeline / test (pull_request) Successful in 2m10s
2026-01-07 17:02:06 +01:00
7d9757abb6 Merge branch 'development' into refactoring/68-mvp-refactoring
# Conflicts:
#	lib/l10n/generated/app_localizations.dart
#	lib/l10n/generated/app_localizations_de.dart
#	lib/l10n/generated/app_localizations_en.dart
2026-01-07 16:58:15 +01:00
d94d51c6ea Merge pull request 'change settings icons to filled and rounded' (#140) from enhancement/135-settings-icons into development
Reviewed-on: #140
Reviewed-by: Felix Kirchner <felix.kirchner.fk@gmail.com>
2026-01-07 14:23:27 +00:00
gelbeinhalb
803cf8a972 update app_localizations
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m0s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-07 15:17:13 +01:00
gelbeinhalb
13be75a65b change settings icons to filled and rounded
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m5s
2026-01-07 15:12:12 +01:00
aef12bd65a Refactored several theme settings into custom theme
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m9s
2026-01-07 14:54:53 +01:00
02d79574dd Simplified app bar logic in views 2026-01-07 14:43:13 +01:00
fdd0e7579a Updated game title process 2026-01-07 14:35:07 +01:00
cd2770be26 Removed unnessecary setStates 2026-01-07 14:33:52 +01:00
e196d6e5ef Corrected strings 2026-01-07 14:32:40 +01:00
bc3beac866 Replaced Matches with Spiele 2026-01-07 14:25:14 +01:00
aa936a938d Corrected translation 2026-01-07 14:23:47 +01:00
2811ea892e Added dispose & formatting 2026-01-07 14:15:23 +01:00
4b1d3923a0 Optimized ruleset touples 2026-01-07 14:11:14 +01:00
0f824bb30a Optimized statistics tile 2026-01-07 14:10:09 +01:00
21c74b74bc Refactored components 2026-01-07 14:05:19 +01:00
6e45e9435b Refactored views 2026-01-07 13:27:39 +01:00
a78614851b Added constants class 2026-01-07 13:02:09 +01:00
8df9a27dc7 Merge pull request 'Lokalisierung implementieren' (#112) from feature/100-lokalisierung-hinzufügen into development
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m7s
Reviewed-on: #112
Reviewed-by: Felix Kirchner <felix.kirchner.fk@gmail.com>
2026-01-07 11:30:11 +00:00
52180eeb6d Merge branch 'development' into feature/100-lokalisierung-hinzufügen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m2s
Pull Request Pipeline / lint (pull_request) Successful in 2m4s
2026-01-07 11:28:04 +00:00
0893667e41 Merge pull request 'Konsistenzfehler im JSON Vermeiden' (#125) from enhancement/70-konsistenzfehler-im-json-vermeiden into development
Reviewed-on: #125
Reviewed-by: Felix Kirchner <felix.kirchner.fk@gmail.com>
2026-01-07 11:27:44 +00:00
1dc5286c6b change double to single quotes
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m2s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-07 12:08:21 +01:00
gelbeinhalb
f140ebae2e Merge branch 'enhancement/70-konsistenzfehler-im-json-vermeiden' of git.yannick-weigert.de:liquid-development/game-tracker into enhancement/70-konsistenzfehler-im-json-vermeiden
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m16s
Pull Request Pipeline / lint (pull_request) Successful in 2m22s
2026-01-07 12:00:33 +01:00
a487e4071f Sort files
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m17s
Pull Request Pipeline / lint (pull_request) Failing after 2m24s
2026-01-07 12:00:25 +01:00
gelbeinhalb
99044c0ea0 remove unnecessary check 2026-01-07 12:00:25 +01:00
69effa2b7d change winner localization to not include placeholder 2026-01-07 11:49:10 +01:00
5db008c274 Merge branch 'development' into feature/100-lokalisierung-hinzufügen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m8s
Pull Request Pipeline / lint (pull_request) Successful in 2m12s
2026-01-05 15:04:19 +00:00
feaa0709a7 Merge branch 'development' into enhancement/70-konsistenzfehler-im-json-vermeiden
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m14s
Pull Request Pipeline / lint (pull_request) Successful in 2m17s
2026-01-05 15:03:39 +00:00
gelbeinhalb
2fea3597fe Merge branch 'enhancement/70-konsistenzfehler-im-json-vermeiden' of git.yannick-weigert.de:liquid-development/game-tracker into enhancement/70-konsistenzfehler-im-json-vermeiden
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-05 11:46:34 +01:00
gelbeinhalb
7b2314a25e fix null error for winnerId and groupId in match import 2026-01-05 11:46:26 +01:00
gelbeinhalb
7f6c1cb9a6 change InsertMode to insertOrIgnore not insertOrReplace 2026-01-05 11:40:57 +01:00
dcfed75a93 Merge pull request 'Player in Gewinner Auswahl, Match- und Grouptile sortieren' (#134) from enhancement/133-gewinner-auswahl-sortieren into development
Reviewed-on: #134
Reviewed-by: Felix Kirchner <felix.kirchner.fk@gmail.com>
2026-01-04 20:46:04 +00:00
7fa434782c remove semicolon and empty line
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m5s
2026-01-03 17:49:37 +01:00
bdcee85eb9 sort players in group tile 2026-01-03 17:49:15 +01:00
072dba1cde sort players in match tile 2026-01-03 17:45:35 +01:00
3c7c4598ff sort players in winner selection 2026-01-03 17:42:25 +01:00
1a20d7b64c Merge branch 'development' into enhancement/70-konsistenzfehler-im-json-vermeiden
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m24s
Pull Request Pipeline / lint (pull_request) Successful in 2m27s
2026-01-03 14:39:40 +00:00
ec94e12ed7 implement changes
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m27s
Pull Request Pipeline / lint (pull_request) Successful in 2m33s
2026-01-03 15:38:25 +01:00
9fc308554c Merge remote-tracking branch 'origin/development' into feature/100-lokalisierung-hinzufügen
# Conflicts:
#	lib/presentation/views/main_menu/match_view/create_match/choose_game_view.dart
#	lib/presentation/views/main_menu/match_view/create_match/choose_group_view.dart
#	lib/presentation/views/main_menu/match_view/create_match/choose_ruleset_view.dart
2026-01-03 14:42:53 +01:00
42cef337aa Merge pull request 'ChooseViews Speichern nicht bei Zurück gehen' (#127) from bug/126-ChooseViews-Speichern-nicht-bei-Zurück-gehen into development
Reviewed-on: #127
Reviewed-by: Felix Kirchner <felix.kirchner.fk@gmail.com>
2026-01-03 12:53:51 +00:00
gelbeinhalb
d9980edf0e Merge branch 'enhancement/70-konsistenzfehler-im-json-vermeiden' of git.yannick-weigert.de:liquid-development/game-tracker into enhancement/70-konsistenzfehler-im-json-vermeiden
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m7s
Pull Request Pipeline / lint (pull_request) Successful in 2m7s
2026-01-03 13:20:59 +01:00
gelbeinhalb
4c084cae4a remove ?? as members cant be null 2026-01-03 13:20:36 +01:00
gelbeinhalb
cecfd5da4e update schema.json to current data import version 2026-01-03 13:19:58 +01:00
5289660327 add comment
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m5s
Pull Request Pipeline / lint (pull_request) Successful in 2m8s
2026-01-03 11:02:43 +01:00
16e1f542f5 fix choose rulset & choose group view not saving 2026-01-03 11:02:38 +01:00
e4ae526d93 fix choose_game_view not saving
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m5s
2026-01-03 10:16:28 +01:00
2f65316a51 Merge branch 'development' into enhancement/70-konsistenzfehler-im-json-vermeiden
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m5s
Pull Request Pipeline / lint (pull_request) Failing after 2m8s
2026-01-02 20:45:47 +00:00
31abb7f1e4 Merge remote-tracking branch 'origin/development' into feature/100-lokalisierung-hinzufügen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m7s
Pull Request Pipeline / lint (pull_request) Successful in 2m12s
# Conflicts:
#	lib/presentation/widgets/player_selection.dart
2026-01-02 21:32:40 +01:00
132966f3d2 increase title_description_list_tile width to make german translation fully visible
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m9s
Pull Request Pipeline / lint (pull_request) Successful in 2m23s
2026-01-02 21:28:46 +01:00
77095725de fix game choose view highlighting not working 2026-01-02 21:26:54 +01:00
d081a597db Merge pull request 'Ausgewählte Spieler durch Gruppe werden nicht aussortiert' (#124) from bug/113-ausgewählte-spieler-durch-gruppe-werden-nicht-aussortiert into development
Reviewed-on: #124
Reviewed-by: Mathis Kirchner <mathis.kirchner.mk@gmail.com>
2026-01-02 20:22:45 +00:00
bdc3453d7f correct spelling mistake
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m9s
Pull Request Pipeline / lint (pull_request) Successful in 2m9s
2026-01-02 21:20:30 +01:00
678ab90af3 removed unneccessary null assertion operators
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-02 21:16:13 +01:00
a038c22ba6 removed else in fallback 2026-01-02 21:13:00 +01:00
22fcff73bd configure en locale as fallback
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m5s
Pull Request Pipeline / lint (pull_request) Failing after 2m7s
2026-01-02 21:11:37 +01:00
gelbeinhalb
4a67dae456 change import/export json logic to remove redundant data
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m4s
Pull Request Pipeline / lint (pull_request) Failing after 2m5s
2026-01-02 20:37:10 +01:00
3c22b084d6 made getters non nullable and removed all null assertion operators
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m10s
Pull Request Pipeline / lint (pull_request) Failing after 2m11s
2026-01-02 19:01:44 +01:00
7f923f6dff Merge remote-tracking branch 'origin/development' into feature/100-lokalisierung-hinzufügen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m15s
Pull Request Pipeline / lint (pull_request) Successful in 2m15s
# Conflicts:
#	lib/presentation/views/main_menu/home_view.dart
#	lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart
#	lib/presentation/views/main_menu/match_view/match_view.dart
2026-01-02 18:49:34 +01:00
87856e6548 Simplified info texts
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m8s
Pull Request Pipeline / lint (pull_request) Successful in 2m8s
2026-01-02 18:41:39 +01:00
cb7804cf55 Fixed Problem with widget state 2026-01-02 18:38:13 +01:00
304fa82a93 Fixed bug in player selection
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m7s
Pull Request Pipeline / lint (pull_request) Successful in 2m7s
2026-01-01 23:14:52 +01:00
f84a645e61 Merge pull request 'Optionaler Match-Name' (#121) from enhancement/115-Optionaler-Match-Name into development
Reviewed-on: #121
2026-01-01 21:50:11 +00:00
b0073addf8 remove unnecessary trim
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m18s
Pull Request Pipeline / lint (pull_request) Successful in 2m18s
2026-01-01 22:45:55 +01:00
b5c17ac5a9 Merge branch 'development' into enhancement/115-Optionaler-Match-Name
All checks were successful
Pull Request Pipeline / lint (pull_request) Successful in 2m41s
Pull Request Pipeline / test (pull_request) Successful in 2m44s
2026-01-01 21:43:37 +00:00
4451f9e2a9 Merge branch 'development' into feature/100-lokalisierung-hinzufügen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m34s
Pull Request Pipeline / lint (pull_request) Successful in 2m36s
2026-01-01 21:43:19 +00:00
1d4fdae84b Hotfix: Missing game renames
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m5s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-01 22:40:26 +01:00
60862de4c4 Merge pull request 'Letztes Tile in Matchview nicht lesbar' (#123) from bug/122-Letztes-Tile-in-MatchView-nicht-lesbar into development
Reviewed-on: #123
Reviewed-by: Felix Kirchner <felix.kirchner.fk@gmail.com>
2026-01-01 21:33:02 +00:00
6899bb0c3c add comment
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m6s
Pull Request Pipeline / lint (pull_request) Successful in 2m11s
2026-01-01 21:47:13 +01:00
55a22b292f changed bottom padding
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m6s
Pull Request Pipeline / lint (pull_request) Successful in 2m7s
2026-01-01 21:40:18 +01:00
db30b0fd5a removed double quotes
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m19s
Pull Request Pipeline / lint (pull_request) Successful in 2m23s
2026-01-01 19:15:57 +01:00
5ee0d59377 implement optional match name with game name as default
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m23s
Pull Request Pipeline / lint (pull_request) Failing after 2m24s
2026-01-01 19:13:50 +01:00
f22595e678 Add localization for 'none_group' option in English and German
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m9s
2026-01-01 18:44:43 +01:00
25fe10eb9a added missing square bracket 2026-01-01 18:44:28 +01:00
5a318f9760 Merge remote-tracking branch 'origin/feature/100-lokalisierung-hinzufügen' into feature/100-lokalisierung-hinzufügen 2026-01-01 18:44:03 +01:00
0051990168 Remove auto_localize dependency from pubspec.yaml 2026-01-01 18:43:06 +01:00
7e21c65026 Merge branch 'development' into feature/100-lokalisierung-hinzufügen
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m11s
Pull Request Pipeline / lint (pull_request) Failing after 2m35s
2026-01-01 17:33:47 +00:00
cc23c03f6b Add localization for 'not available' message in English and German
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m4s
Pull Request Pipeline / lint (pull_request) Failing after 2m15s
2026-01-01 18:32:01 +01:00
d77b5f20f9 Update statistics_view.dart to use localized 'not available' message for players 2026-01-01 18:31:53 +01:00
3c3bf506cb Add TODO for implementing quick create functionality in home_view.dart 2026-01-01 18:31:37 +01:00
8afba5680b Add localization for no statistics available message and removed dots from all messages
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m6s
Pull Request Pipeline / lint (pull_request) Successful in 2m11s
2026-01-01 18:18:14 +01:00
7103765054 Update statistics_view.dart to use localized message no statistics available instead of no data available 2026-01-01 18:17:53 +01:00
bc01a6de9a Add localization for search input fields in English and German
All checks were successful
Pull Request Pipeline / lint (pull_request) Successful in 2m26s
Pull Request Pipeline / test (pull_request) Successful in 2m15s
2026-01-01 18:10:44 +01:00
ad87dca674 add generated files
Some checks failed
Pull Request Pipeline / lint (pull_request) Failing after 2m47s
Pull Request Pipeline / test (pull_request) Successful in 2m27s
2026-01-01 18:10:24 +01:00
633a21d829 Updated search bar hint texts to use localization for group and player searches
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m38s
Pull Request Pipeline / lint (pull_request) Failing after 2m54s
2026-01-01 18:10:08 +01:00
81f63c1c07 made statistics_view.dart use localization and fix merge error
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m41s
Pull Request Pipeline / lint (pull_request) Successful in 2m42s
2026-01-01 18:09:50 +01:00
fc6c74b377 Merge pull request 'Entfernen von Ausgewählten Spielern, fügt sie nicht wieder zur Auswahl hinzu' (#117) from bug/116-entfernen-von-ausgewählten-spielern-fuegt-sie-nicht-wieder-zur-auswahl-hinzu into development
Reviewed-on: #117
Reviewed-by: Mathis Kirchner <mathis.kirchner.mk@gmail.com>
2026-01-01 16:50:07 +00:00
15d09f381a New created players will be added now at the front too
All checks were successful
Pull Request Pipeline / lint (pull_request) Successful in 2m9s
Pull Request Pipeline / test (pull_request) Successful in 2m8s
2026-01-01 17:47:15 +01:00
f97c341b81 added devtools_options.yaml to .gitignore
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m16s
Pull Request Pipeline / lint (pull_request) Successful in 2m23s
2026-01-01 17:43:24 +01:00
7bf03ec388 added auto-generated files to git
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m26s
Pull Request Pipeline / lint (pull_request) Successful in 2m26s
2026-01-01 17:42:38 +01:00
0bfaba4225 Refactored German localization strings by removing redundant entries
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m25s
2026-01-01 17:40:36 +01:00
bbb7914fc5 Updated sorting logic & added comments
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m0s
Pull Request Pipeline / lint (pull_request) Successful in 2m5s
2026-01-01 16:39:57 +01:00
86dbc9afb0 Optimized ruleset selection in CreateMatchView
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m2s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2026-01-01 00:42:21 +01:00
73aea0d0f5 added missings consts
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m4s
Pull Request Pipeline / lint (pull_request) Failing after 2m8s
2026-01-01 00:39:15 +01:00
ed9e3af768 merged dev into branch and fixed missing comma
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Failing after 2m5s
2026-01-01 00:34:55 +01:00
d93ead40b6 Merge remote-tracking branch 'origin/development' into feature/100-lokalisierung-hinzufügen
# Conflicts:
#	lib/presentation/views/main_menu/statistics_view.dart
2026-01-01 00:32:10 +01:00
3374a80c27 Merge pull request 'Bei 0 gespielten Matches keine Stats anzeigen' (#111) from enhancement/109-bei-0-gespielten-matches-keine-stats-anzeigen into development
Reviewed-on: #111
2025-12-31 23:30:26 +00:00
534d19efc3 Implemented localization across the application.
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m5s
Pull Request Pipeline / lint (pull_request) Failing after 2m22s
2026-01-01 00:21:09 +01:00
d9a26a8cf7 Added English and German localization files containing all strings used in app 2026-01-01 00:20:44 +01:00
8e05e9d61b Added l10n.yaml for localization configuration 2026-01-01 00:20:22 +01:00
179ac2fe21 Update localization dependencies and enable code generation 2026-01-01 00:20:16 +01:00
2b78617924 Redo seperate visibility
All checks were successful
Pull Request Pipeline / lint (pull_request) Successful in 2m11s
Pull Request Pipeline / test (pull_request) Successful in 2m11s
2025-12-31 19:11:34 +01:00
175a9cb349 Added hiding statistics tiles if their corresponding data is not available
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m4s
2025-12-31 18:36:33 +01:00
18f0626e95 Added empty statistics message 2025-12-31 18:33:09 +01:00
d99a04549a Merge pull request 'Möglichkeit der horizontalen Nutzung deaktivieren' (#110) from feature/108-Möglichkeit-der-horizontalen-Nutzung-deaktivieren into development
Reviewed-on: #110
2025-12-31 17:00:31 +00:00
cc1ecc4c86 Merge branch 'development' into feature/108-Möglichkeit-der-horizontalen-Nutzung-deaktivieren
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m15s
Pull Request Pipeline / lint (pull_request) Successful in 2m22s
2025-12-31 16:41:08 +00:00
16cdf9db3e Restricted app orientation to portrait mode on iOS and Android
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m21s
Pull Request Pipeline / lint (pull_request) Successful in 2m24s
2025-12-31 17:39:20 +01:00
da494ed146 Merge pull request 'Fehlende Umbenennungen' (#106) from refactoring/105-fehlende-umbenennungen into development
Reviewed-on: #106
Reviewed-by: Mathis Kirchner <mathis.kirchner.mk@gmail.com>
2025-12-31 16:27:29 +00:00
af0242c44f Merge branch 'development' into refactoring/105-fehlende-umbenennungen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m4s
Pull Request Pipeline / lint (pull_request) Successful in 2m7s
2025-12-31 16:25:19 +00:00
cd63f5cf06 Merge pull request 'Fehlende Info in CreateGroupView' (#107) from bug/73-Fehlende-Info-in-CreateGroupView into development
Reviewed-on: #107
Reviewed-by: Mathis Kirchner <mathis.kirchner.mk@gmail.com>
2025-12-31 16:24:31 +00:00
8c3282b954 Changed color to white
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 1m57s
Pull Request Pipeline / lint (pull_request) Successful in 4m58s
2025-12-31 17:10:47 +01:00
1c0fb9f3ab Merge branch 'development' into bug/73-Fehlende-Info-in-CreateGroupView
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m19s
Pull Request Pipeline / lint (pull_request) Successful in 2m21s
2025-12-31 16:41:26 +01:00
bfca41bd36 Fixed info message placement
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m19s
Pull Request Pipeline / lint (pull_request) Successful in 2m21s
2025-12-31 16:38:09 +01:00
92b8ef0877 Merge branch 'development' into refactoring/105-fehlende-umbenennungen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m18s
Pull Request Pipeline / lint (pull_request) Successful in 2m18s
2025-12-30 21:22:34 +01:00
5428064c53 Some last changes
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m16s
Pull Request Pipeline / lint (pull_request) Successful in 2m21s
2025-12-30 21:22:07 +01:00
27916456db Merge pull request 'Fehler bei Match-Erstellung' (#104) from bug/102-fehler-bei-match-erstellung into development
Reviewed-on: #104
Reviewed-by: Mathis Kirchner <mathis.kirchner.mk@gmail.com>
2025-12-30 20:17:18 +00:00
58fe38fd72 Updated comment
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m4s
Pull Request Pipeline / lint (pull_request) Successful in 2m10s
2025-12-30 21:02:03 +01:00
ecd03dfd9d Updated hint text 2025-12-30 21:01:40 +01:00
05c6625bf3 Renamed MatchResultView and match variable 2025-12-30 21:01:07 +01:00
9821af39fe Renamed test files 2025-12-30 21:00:56 +01:00
c1789458e0 Added tests for bug causing behaviour
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m6s
Pull Request Pipeline / lint (pull_request) Successful in 2m8s
2025-12-30 20:56:39 +01:00
e19f696714 Fixed tests with adding players and groups to database on setup
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m6s
Pull Request Pipeline / lint (pull_request) Successful in 2m11s
2025-12-30 18:51:57 +01:00
9cb35dc4a1 Updated comments
Some checks failed
Pull Request Pipeline / test (pull_request) Failing after 2m9s
Pull Request Pipeline / lint (pull_request) Successful in 2m9s
2025-12-30 18:45:28 +01:00
b8b65c4ca1 Removed lines that added the group and players to the db again in addMatch()
Some checks failed
Pull Request Pipeline / lint (pull_request) Successful in 2m9s
Pull Request Pipeline / test (pull_request) Failing after 2m19s
2025-12-30 18:23:15 +01:00
356cb1fb43 Updated insert mode to fix problem with replacing existing player match connections 2025-12-30 18:21:39 +01:00
4c8896d2d9 Merge pull request 'Fehlende Aktualisierung in MatchView' (#101) from bug/95-fehlende-aktualisierung-in-matchview into development
Reviewed-on: #101
Reviewed-by: Mathis Kirchner <mathis.kirchner.mk@gmail.com>
2025-12-30 16:49:02 +00:00
31c8598222 Made cleaner version
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m4s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2025-12-29 19:28:47 +01:00
884680d329 Merge branch 'development' into bug/95-fehlende-aktualisierung-in-matchview
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s
2025-12-29 19:23:11 +01:00
5ae569f2e7 Fixed updating error
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m3s
2025-12-29 19:16:25 +01:00
37d6ad81fd Merge pull request 'ChooseGroupView zeigt keine Group entspricht der Suche, obwohl nur Gruppen leer' (#98) from bug/94-choosegroupview-zeigt-keine-group-entspricht-der-suche-obwohl-nur-gruppen-leer into development
Reviewed-on: #98
Reviewed-by: Mathis Kirchner <mathis.kirchner.mk@gmail.com>
2025-12-29 17:47:11 +00:00
59 changed files with 3828 additions and 1449 deletions

1
.gitignore vendored
View File

@@ -195,3 +195,4 @@ app.*.map.json
/android/app/debug /android/app/debug
/android/app/profile /android/app/profile
/android/app/release /android/app/release
/devtools_options.yaml

View File

@@ -6,6 +6,7 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"
android:screenOrientation="portrait"
android:launchMode="singleTop" android:launchMode="singleTop"
android:taskAffinity="" android:taskAffinity=""
android:theme="@style/LaunchTheme" android:theme="@style/LaunchTheme"

View File

@@ -2,63 +2,9 @@
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-04/schema#",
"type": "object", "type": "object",
"properties": { "properties": {
"games": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"name": {
"type": "string"
},
"players": { "players": {
"type": [
"array",
"null"
],
"properties": {
"id": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"createdAt",
"name"
]
}
},
"group": {
"type": [
"object",
"null"
],
"properties": {
"id": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"name": {
"type": "string"
},
"members": {
"type": "array", "type": "array",
"items": [ "items": {
{
"type": "object", "type": "object",
"properties": { "properties": {
"id": { "id": {
@@ -77,103 +23,82 @@
"name" "name"
] ]
} }
]
}
},
"required": [
"id",
"createdAt",
"name",
"members"
]
},
"winner": {
"type": ["object","null"]
},
"required": [
"id",
"createdAt",
"name"
]
}
]
}, },
"groups": { "groups": {
"type": "array", "type": "array",
"items": [ "items": {
{
"type": "object", "type": "object",
"properties": { "properties": {
"id": { "id": {
"type": "string" "type": "string"
}, },
"createdAt": {
"type": "string"
},
"name": { "name": {
"type": "string" "type": "string"
}, },
"members": { "createdAt": {
"type": "string"
},
"memberIds": {
"type": "array", "type": "array",
"items": [ "items": {
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"name": {
"type": "string" "type": "string"
} }
}
}, },
"required": [ "required": [
"id", "id",
"createdAt",
"name"
]
}
]
}
},
"required": [
"id",
"createdAt",
"name", "name",
"members" "createdAt",
"memberIds"
] ]
} }
]
}, },
"players": { "matches": {
"type": "array", "type": "array",
"items": [ "items": {
{ "type": "object",
"type": [
"object",
"null"
],
"properties": { "properties": {
"id": { "id": {
"type": "string" "type": "string"
}, },
"name": {
"type": "string"
},
"createdAt": { "createdAt": {
"type": "string" "type": "string"
}, },
"name": { "groupId": {
"anyOf": [
{"type": "string"},
{"type": "null"}
]
},
"playerIds": {
"type": "array",
"items": {
"type": "string" "type": "string"
} }
}, },
"winnerId": {
"anyOf": [
{"type": "string"},
{"type": "null"}
]
}
},
"required": [ "required": [
"id", "id",
"name",
"createdAt", "createdAt",
"name" "groupId",
] "playerIds"
}
] ]
} }
} }
},
"required": [
"players",
"groups",
"matches"
]
} }

View File

@@ -31,8 +31,6 @@
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array> <array>
<string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>UISupportedInterfaceOrientations~ipad</key> <key>UISupportedInterfaceOrientations~ipad</key>
<array> <array>

5
l10n.yaml Normal file
View File

@@ -0,0 +1,5 @@
arb-dir: lib/l10n/arb
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
output-dir: lib/l10n/generated
nullable-getter: false

View File

@@ -0,0 +1,19 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
Route<T> adaptivePageRoute<T>({
required Widget Function(BuildContext) builder,
bool fullscreenDialog = false,
}) {
if (Platform.isIOS) {
return CupertinoPageRoute<T>(
builder: builder,
fullscreenDialog: fullscreenDialog,
);
}
return MaterialPageRoute<T>(
builder: builder,
fullscreenDialog: fullscreenDialog,
);
}

View File

@@ -1,2 +1,6 @@
class Constants {
Constants._(); // Private constructor to prevent instantiation
/// Minimum duration of all app skeletons /// Minimum duration of all app skeletons
Duration minimumSkeletonDuration = const Duration(milliseconds: 250); static Duration minimumSkeletonDuration = const Duration(milliseconds: 250);
}

View File

@@ -1,35 +1,61 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class CustomTheme { class CustomTheme {
CustomTheme._(); // Private constructor to prevent instantiation
// ==================== Colors ====================
static Color primaryColor = const Color(0xFF7505E4); static Color primaryColor = const Color(0xFF7505E4);
static Color secondaryColor = const Color(0xFFAFA2FF); static Color secondaryColor = const Color(0xFFAFA2FF);
static Color backgroundColor = const Color(0xFF0B0B0B); static Color backgroundColor = const Color(0xFF0B0B0B);
static Color boxColor = const Color(0xFF101010); static Color boxColor = const Color(0xFF101010);
static Color onBoxColor = const Color(0xFF181818); static Color onBoxColor = const Color(0xFF181818);
static Color boxBorder = const Color(0xFF272727); static Color boxBorder = const Color(0xFF272727);
static const Color textColor = Colors.white;
static Color navBarItemSelectedColor = primaryColor.withValues(green: 0.4);
static Color navBarItemUnselectedColor = Colors.white.withValues(alpha: 0.6);
// ==================== Border Radius ====================
static const double standardBorderRadius = 12.0;
static BorderRadius get standardBorderRadiusAll =>
BorderRadius.circular(standardBorderRadius);
// ==================== Padding & Margins ====================
static const EdgeInsets standardMargin = EdgeInsets.symmetric(
horizontal: 12,
vertical: 10,
);
static const EdgeInsets tileMargin = EdgeInsets.symmetric(
horizontal: 12,
vertical: 5,
);
// ==================== Decorations ====================
static BoxDecoration standardBoxDecoration = BoxDecoration( static BoxDecoration standardBoxDecoration = BoxDecoration(
color: boxColor, color: boxColor,
border: Border.all(color: boxBorder), border: Border.all(color: boxBorder),
borderRadius: BorderRadius.circular(12), borderRadius: standardBorderRadiusAll,
); );
static BoxDecoration highlightedBoxDecoration = BoxDecoration( static BoxDecoration highlightedBoxDecoration = BoxDecoration(
color: boxColor, color: boxColor,
border: Border.all(color: primaryColor), border: Border.all(color: primaryColor),
borderRadius: BorderRadius.circular(12), borderRadius: standardBorderRadiusAll,
boxShadow: [BoxShadow(color: primaryColor.withAlpha(120), blurRadius: 12)], boxShadow: [BoxShadow(color: primaryColor.withAlpha(120), blurRadius: 12)],
); );
// ==================== App Bar Theme ====================
static AppBarTheme appBarTheme = AppBarTheme( static AppBarTheme appBarTheme = AppBarTheme(
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
foregroundColor: Colors.white, foregroundColor: textColor,
elevation: 0, elevation: 0,
scrolledUnderElevation: 0,
centerTitle: true,
titleTextStyle: const TextStyle( titleTextStyle: const TextStyle(
color: Colors.white, color: textColor,
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
overflow: TextOverflow.ellipsis,
), ),
iconTheme: const IconThemeData(color: Colors.white), iconTheme: const IconThemeData(color: textColor),
); );
} }

View File

@@ -1,4 +1,10 @@
import 'package:flutter/material.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
/// Button types used for styling the [CustomWidthButton] /// Button types used for styling the [CustomWidthButton]
/// - [ButtonType.primary]: Primary button style.
/// - [ButtonType.secondary]: Secondary button style.
/// - [ButtonType.tertiary]: Tertiary button style.
enum ButtonType { primary, secondary, tertiary } enum ButtonType { primary, secondary, tertiary }
/// Result types for import operations in the [SettingsView] /// Result types for import operations in the [SettingsView]
@@ -30,16 +36,17 @@ enum ExportResult { success, canceled, unknownException }
/// - [Ruleset.leastPoints]: The player with the fewest points wins. /// - [Ruleset.leastPoints]: The player with the fewest points wins.
enum Ruleset { singleWinner, singleLoser, mostPoints, leastPoints } enum Ruleset { singleWinner, singleLoser, mostPoints, leastPoints }
/// Translates a [Ruleset] enum value to its corresponding string representation. /// Translates a [Ruleset] enum value to its corresponding localized string.
String translateRulesetToString(Ruleset ruleset) { String translateRulesetToString(Ruleset ruleset, BuildContext context) {
final loc = AppLocalizations.of(context);
switch (ruleset) { switch (ruleset) {
case Ruleset.singleWinner: case Ruleset.singleWinner:
return 'Single Winner'; return loc.single_winner;
case Ruleset.singleLoser: case Ruleset.singleLoser:
return 'Single Loser'; return loc.single_loser;
case Ruleset.mostPoints: case Ruleset.mostPoints:
return 'Most Points'; return loc.most_points;
case Ruleset.leastPoints: case Ruleset.leastPoints:
return 'Least Points'; return loc.least_points;
} }
} }

View File

@@ -95,6 +95,8 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
} }
// Insert unique groups in batch // Insert unique groups in batch
// Using insertOrIgnore to avoid triggering cascade deletes on
// player_group associations when groups already exist
await db.batch( await db.batch(
(b) => b.insertAll( (b) => b.insertAll(
groupTable, groupTable,
@@ -107,7 +109,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
), ),
) )
.toList(), .toList(),
mode: InsertMode.insertOrReplace, mode: InsertMode.insertOrIgnore,
), ),
); );
@@ -120,6 +122,8 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
} }
if (uniquePlayers.isNotEmpty) { if (uniquePlayers.isNotEmpty) {
// Using insertOrIgnore to avoid triggering cascade deletes on
// player_group associations when players already exist
await db.batch( await db.batch(
(b) => b.insertAll( (b) => b.insertAll(
db.playerTable, db.playerTable,
@@ -132,7 +136,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
), ),
) )
.toList(), .toList(),
mode: InsertMode.insertOrReplace, mode: InsertMode.insertOrIgnore,
), ),
); );
} }

View File

@@ -21,7 +21,7 @@ class GroupMatchDao extends DatabaseAccessor<AppDatabase>
} }
await into(groupMatchTable).insert( await into(groupMatchTable).insert(
GroupMatchTableCompanion.insert(groupId: groupId, matchId: matchId), GroupMatchTableCompanion.insert(groupId: groupId, matchId: matchId),
mode: InsertMode.insertOrReplace, mode: InsertMode.insertOrIgnore,
); );
} }

View File

@@ -65,8 +65,9 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
); );
} }
/// Adds a new [Match] to the database. /// Adds a new [Match] to the database. Also adds players and group
/// Also adds associated players and group if they exist. /// associations. This method assumes that the players and groups added to
/// this match are already present in the database.
Future<void> addMatch({required Match match}) async { Future<void> addMatch({required Match match}) async {
await db.transaction(() async { await db.transaction(() async {
await into(matchTable).insert( await into(matchTable).insert(
@@ -80,7 +81,6 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
); );
if (match.players != null) { if (match.players != null) {
await db.playerDao.addPlayersAsList(players: match.players!);
for (final p in match.players ?? []) { for (final p in match.players ?? []) {
await db.playerMatchDao.addPlayerToMatch( await db.playerMatchDao.addPlayerToMatch(
matchId: match.id, matchId: match.id,
@@ -90,7 +90,6 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
} }
if (match.group != null) { if (match.group != null) {
await db.groupDao.addGroup(group: match.group!);
await db.groupMatchDao.addGroupToMatch( await db.groupMatchDao.addGroupToMatch(
matchId: match.id, matchId: match.id,
groupId: match.group!.id, groupId: match.group!.id,
@@ -102,6 +101,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
/// Adds multiple [Match]s to the database in a batch operation. /// Adds multiple [Match]s to the database in a batch operation.
/// Also adds associated players and groups if they exist. /// Also adds associated players and groups if they exist.
/// If the [matches] list is empty, the method returns immediately. /// If the [matches] list is empty, the method returns immediately.
/// This Method should only be used to import matches from a different device.
Future<void> addMatchAsList({required List<Match> matches}) async { Future<void> addMatchAsList({required List<Match> matches}) async {
if (matches.isEmpty) return; if (matches.isEmpty) return;
await db.transaction(() async { await db.transaction(() async {
@@ -124,6 +124,8 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
); );
// Add all groups of the matches in batch // Add all groups of the matches in batch
// Using insertOrIgnore to avoid overwriting existing groups (which would
// trigger cascade deletes on player_group associations)
await db.batch( await db.batch(
(b) => b.insertAll( (b) => b.insertAll(
db.groupTable, db.groupTable,
@@ -137,7 +139,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
), ),
) )
.toList(), .toList(),
mode: InsertMode.insertOrReplace, mode: InsertMode.insertOrIgnore,
), ),
); );
@@ -158,6 +160,8 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
} }
if (uniquePlayers.isNotEmpty) { if (uniquePlayers.isNotEmpty) {
// Using insertOrIgnore to avoid triggering cascade deletes on
// player_group/player_match associations when players already exist
await db.batch( await db.batch(
(b) => b.insertAll( (b) => b.insertAll(
db.playerTable, db.playerTable,
@@ -170,7 +174,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
), ),
) )
.toList(), .toList(),
mode: InsertMode.insertOrReplace, mode: InsertMode.insertOrIgnore,
), ),
); );
} }
@@ -186,7 +190,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
matchId: match.id, matchId: match.id,
playerId: p.id, playerId: p.id,
), ),
mode: InsertMode.insertOrReplace, mode: InsertMode.insertOrIgnore,
); );
} }
} }
@@ -204,7 +208,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
playerId: m.id, playerId: m.id,
groupId: match.group!.id, groupId: match.group!.id,
), ),
mode: InsertMode.insertOrReplace, mode: InsertMode.insertOrIgnore,
); );
} }
} }
@@ -221,7 +225,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
matchId: match.id, matchId: match.id,
groupId: match.group!.id, groupId: match.group!.id,
), ),
mode: InsertMode.insertOrReplace, mode: InsertMode.insertOrIgnore,
); );
} }
} }

View File

@@ -50,6 +50,8 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
} }
/// Adds multiple [players] to the database in a batch operation. /// Adds multiple [players] to the database in a batch operation.
/// Uses insertOrIgnore to avoid triggering cascade deletes on
/// player_group associations when players already exist.
Future<bool> addPlayersAsList({required List<Player> players}) async { Future<bool> addPlayersAsList({required List<Player> players}) async {
if (players.isEmpty) return false; if (players.isEmpty) return false;
@@ -65,7 +67,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
), ),
) )
.toList(), .toList(),
mode: InsertMode.insertOrReplace, mode: InsertMode.insertOrIgnore,
), ),
); );

View File

@@ -18,7 +18,7 @@ class PlayerMatchDao extends DatabaseAccessor<AppDatabase>
}) async { }) async {
await into(playerMatchTable).insert( await into(playerMatchTable).insert(
PlayerMatchTableCompanion.insert(playerId: playerId, matchId: matchId), PlayerMatchTableCompanion.insert(playerId: playerId, matchId: matchId),
mode: InsertMode.insertOrReplace, mode: InsertMode.insertOrIgnore,
); );
} }
@@ -121,7 +121,7 @@ class PlayerMatchDao extends DatabaseAccessor<AppDatabase>
inserts.map( inserts.map(
(c) => into( (c) => into(
playerMatchTable, playerMatchTable,
).insert(c, mode: InsertMode.insertOrReplace), ).insert(c, mode: InsertMode.insertOrIgnore),
), ),
); );
} }

View File

@@ -9,7 +9,7 @@ class Match {
final String name; final String name;
final List<Player>? players; final List<Player>? players;
final Group? group; final Group? group;
final Player? winner; Player? winner;
Match({ Match({
String? id, String? id,

83
lib/l10n/arb/app_de.arb Normal file
View File

@@ -0,0 +1,83 @@
{
"@@locale": "de",
"all_players": "Alle Spieler:innen",
"all_players_selected": "Alle Spieler:innen ausgewählt",
"amount_of_matches": "Anzahl der Spiele",
"cancel": "Abbrechen",
"choose_game": "Spielvorlage wählen",
"choose_group": "Gruppe wählen",
"choose_ruleset": "Regelwerk wählen",
"could_not_add_player": "Spieler:in {playerName} konnte nicht hinzugefügt werden",
"create_group": "Gruppe erstellen",
"create_match": "Spiel erstellen",
"create_new_group": "Neue Gruppe erstellen",
"create_new_match": "Neues Spiel erstellen",
"data_successfully_deleted": "Daten erfolgreich gelöscht",
"data_successfully_exported": "Daten erfolgreich exportiert",
"data_successfully_imported": "Daten erfolgreich importiert",
"days_ago": "vor {count} Tagen",
"delete": "Löschen",
"delete_all_data": "Alle Daten löschen",
"error_creating_group": "Fehler beim Erstellen der Gruppe, bitte erneut versuchen",
"error_reading_file": "Fehler beim Lesen der Datei",
"export_canceled": "Export abgebrochen",
"export_data": "Daten exportieren",
"format_exception": "Formatfehler (siehe Konsole)",
"game": "Spielvorlage",
"game_name": "Spielvorlagenname",
"group": "Gruppe",
"group_name": "Gruppenname",
"groups": "Gruppen",
"home": "Startseite",
"import_canceled": "Import abgebrochen",
"import_data": "Daten importieren",
"info": "Info",
"invalid_schema": "Ungültiges Schema",
"least_points": "Niedrigste Punkte",
"match_in_progress": "Spiel läuft...",
"match_name": "Spieltitel",
"matches": "Spiele",
"menu": "Menü",
"most_points": "Höchste Punkte",
"no_data_available": "Keine Daten verfügbar",
"no_groups_created_yet": "Noch keine Gruppen erstellt",
"no_matches_created_yet": "Noch keine Spiele erstellt",
"no_players_created_yet": "Noch keine Spieler:in erstellt",
"no_players_found_with_that_name": "Keine Spieler:in mit diesem Namen gefunden",
"no_players_selected": "Keine Spieler:innen ausgewählt",
"no_recent_matches_available": "Keine letzten Spiele verfügbar",
"no_second_match_available": "Kein zweites Spiel verfügbar",
"no_statistics_available": "Keine Statistiken verfügbar",
"none": "Kein",
"none_group": "Keine",
"not_available": "Nicht verfügbar",
"player_name": "Spieler:innenname",
"players": "Spieler:innen",
"players_count": "{count} Spieler",
"quick_create": "Schnellzugriff",
"recent_matches": "Letzte Spiele",
"ruleset": "Regelwerk",
"ruleset_least_points": "Umgekehrte Wertung: Der/die Spieler:in mit den wenigsten Punkten gewinnt.",
"ruleset_most_points": "Traditionelles Regelwerk: Der/die Spieler:in mit den meisten Punkten gewinnt.",
"ruleset_single_loser": "Genau ein:e Verlierer:in wird bestimmt; der letzte Platz erhält die Strafe oder Konsequenz.",
"ruleset_single_winner": "Genau ein:e Gewinner:in wird gewählt; Unentschieden werden durch einen vordefinierten Tie-Breaker aufgelöst.",
"search_for_groups": "Nach Gruppen suchen",
"search_for_players": "Nach Spieler:innen suchen",
"select_winner": "Gewinner:in wählen:",
"selected_players": "Ausgewählte Spieler:innen",
"settings": "Einstellungen",
"single_loser": "Ein:e Verlierer:in",
"single_winner": "Ein:e Gewinner:in",
"statistics": "Statistiken",
"stats": "Statistiken",
"successfully_added_player": "Spieler:in {playerName} erfolgreich hinzugefügt",
"there_is_no_group_matching_your_search": "Es gibt keine Gruppe, die deiner Suche entspricht",
"this_cannot_be_undone": "Dies kann nicht rückgängig gemacht werden",
"today_at": "Heute um",
"undo": "Rückgängig",
"unknown_exception": "Unbekannter Fehler (siehe Konsole)",
"winner": "Gewinner:in",
"winrate": "Siegquote",
"wins": "Siege",
"yesterday_at": "Gestern um"
}

343
lib/l10n/arb/app_en.arb Normal file
View File

@@ -0,0 +1,343 @@
{
"@@locale": "en",
"@all_players": {
"description": "Label for all players list"
},
"@all_players_selected": {
"description": "Message when all players are added to selection"
},
"@amount_of_matches": {
"description": "Label for amount of matches statistic"
},
"@app_name": {
"description": "The name of the App"
},
"@cancel": {
"description": "Cancel button text"
},
"@choose_game": {
"description": "Label for choosing a game"
},
"@choose_group": {
"description": "Label for choosing a group"
},
"@choose_ruleset": {
"description": "Label for choosing a ruleset"
},
"@could_not_add_player": {
"description": "Error message when adding a player fails"
},
"@create_group": {
"description": "Button text to create a group"
},
"@create_match": {
"description": "Button text to create a match"
},
"@create_new_group": {
"description": "Button text to create a new group"
},
"@create_new_match": {
"description": "Button text to create a new match"
},
"@data_successfully_deleted": {
"description": "Success message after deleting data"
},
"@data_successfully_exported": {
"description": "Success message after exporting data"
},
"@data_successfully_imported": {
"description": "Success message after importing data"
},
"@days_ago": {
"description": "Date format for days ago",
"placeholders": {
"count": {
"type": "int"
}
}
},
"@delete": {
"description": "Delete button text"
},
"@delete_all_data": {
"description": "Confirmation dialog for deleting all data"
},
"@error_creating_group": {
"description": "Error message when group creation fails"
},
"@error_reading_file": {
"description": "Error message when file cannot be read"
},
"@export_canceled": {
"description": "Message when export is canceled"
},
"@export_data": {
"description": "Export data menu item"
},
"@format_exception": {
"description": "Error message for format exceptions"
},
"@game": {
"description": "Game label"
},
"@game_name": {
"description": "Placeholder for game name search"
},
"@group": {
"description": "Group label"
},
"@group_name": {
"description": "Placeholder for group name input"
},
"@groups": {
"description": "Label for groups"
},
"@home": {
"description": "Home tab label"
},
"@import_canceled": {
"description": "Message when import is canceled"
},
"@import_data": {
"description": "Import data menu item"
},
"@info": {
"description": "Info label"
},
"@invalid_schema": {
"description": "Error message for invalid schema"
},
"@least_points": {
"description": "Title for least points ruleset"
},
"@match_in_progress": {
"description": "Message when match is in progress"
},
"@match_name": {
"description": "Placeholder for match name input"
},
"@matches": {
"description": "Label for matches"
},
"@menu": {
"description": "Menu label"
},
"@most_points": {
"description": "Title for most points ruleset"
},
"@no_data_available": {
"description": "Message when no data in the statistic tiles is given"
},
"@no_groups_created_yet": {
"description": "Message when no groups exist"
},
"@no_matches_created_yet": {
"description": "Message when no matches exist"
},
"@no_players_created_yet": {
"description": "Message when no players exist"
},
"@no_players_found_with_that_name": {
"description": "Message when search returns no results"
},
"@no_players_selected": {
"description": "Message when no players are selected"
},
"@no_recent_matches_available": {
"description": "Message when no recent matches exist"
},
"@no_second_match_available": {
"description": "Message when no second match exists"
},
"@no_statistics_available": {
"description": "Message when no statistics are available, because no matches were played yet"
},
"@none": {
"description": "None option label"
},
"@none_group": {
"description": "None group option label"
},
"@not_available": {
"description": "Abbreviation for not available"
},
"@player_name": {
"description": "Placeholder for player name input"
},
"@players": {
"description": "Players label"
},
"@players_count": {
"description": "Shows the number of players",
"placeholders": {
"count": {
"type": "int"
}
}
},
"@quick_create": {
"description": "Title for quick create section"
},
"@recent_matches": {
"description": "Title for recent matches section"
},
"@ruleset": {
"description": "Ruleset label"
},
"@ruleset_least_points": {
"description": "Description for least points ruleset"
},
"@ruleset_most_points": {
"description": "Description for most points ruleset"
},
"@ruleset_single_loser": {
"description": "Description for single loser ruleset"
},
"@ruleset_single_winner": {
"description": "Description for single winner ruleset"
},
"@search_for_groups": {
"description": "Hint text for group search input field"
},
"@search_for_players": {
"description": "Hint text for player search input field"
},
"@select_winner": {
"description": "Label to select the winner"
},
"@selected_players": {
"description": "Shows the number of selected players"
},
"@settings": {
"description": "Settings label"
},
"@single_loser": {
"description": "Title for single loser ruleset"
},
"@single_winner": {
"description": "Title for single winner ruleset"
},
"@statistics": {
"description": "Statistics tab label"
},
"@stats": {
"description": "Stats tab label (short)"
},
"@successfully_added_player": {
"description": "Success message when adding a player",
"placeholders": {
"playerName": {
"type": "String",
"example": "John"
}
}
},
"@there_is_no_group_matching_your_search": {
"description": "Message when search returns no groups"
},
"@this_cannot_be_undone": {
"description": "Warning message for irreversible actions"
},
"@today_at": {
"description": "Date format for today"
},
"@undo": {
"description": "Undo button text"
},
"@unknown_exception": {
"description": "Error message for unknown exceptions"
},
"@winner": {
"description": "Winner label"
},
"@winrate": {
"description": "Label for winrate statistic"
},
"@wins": {
"description": "Label for wins statistic"
},
"@yesterday_at": {
"description": "Date format for yesterday"
},
"all_players": "All players",
"all_players_selected": "All players selected",
"amount_of_matches": "Amount of Matches",
"app_name": "Game Tracker",
"cancel": "Cancel",
"choose_game": "Choose Game",
"choose_group": "Choose Group",
"choose_ruleset": "Choose Ruleset",
"could_not_add_player": "Could not add player",
"create_group": "Create Group",
"create_match": "Create match",
"create_new_group": "Create new group",
"create_new_match": "Create new match",
"data_successfully_deleted": "Data successfully deleted",
"data_successfully_exported": "Data successfully exported",
"data_successfully_imported": "Data successfully imported",
"days_ago": "{count} days ago",
"delete": "Delete",
"delete_all_data": "Delete all data",
"error_creating_group": "Error while creating group, please try again",
"error_reading_file": "Error reading file",
"export_canceled": "Export canceled",
"export_data": "Export data",
"format_exception": "Format Exception (see console)",
"game": "Game",
"game_name": "Game Name",
"group": "Group",
"group_name": "Group name",
"groups": "Groups",
"home": "Home",
"import_canceled": "Import canceled",
"import_data": "Import data",
"info": "Info",
"invalid_schema": "Invalid Schema",
"least_points": "Least Points",
"match_in_progress": "Match in progress...",
"match_name": "Match name",
"matches": "Matches",
"menu": "Menu",
"most_points": "Most Points",
"no_data_available": "No data available",
"no_groups_created_yet": "No groups created yet",
"no_matches_created_yet": "No matches created yet",
"no_players_created_yet": "No players created yet",
"no_players_found_with_that_name": "No players found with that name",
"no_players_selected": "No players selected",
"no_recent_matches_available": "No recent matches available",
"no_second_match_available": "No second match available",
"no_statistics_available": "No statistics available",
"none": "None",
"none_group": "None",
"not_available": "Not available",
"player_name": "Player name",
"players": "Players",
"players_count": "{count} Players",
"quick_create": "Quick Create",
"recent_matches": "Recent Matches",
"ruleset": "Ruleset",
"ruleset_least_points": "Inverse scoring: the player with the fewest points wins.",
"ruleset_most_points": "Traditional ruleset: the player with the most points wins.",
"ruleset_single_loser": "Exactly one loser is determined; last place receives the penalty or consequence.",
"ruleset_single_winner": "Exactly one winner is chosen; ties are resolved by a predefined tiebreaker.",
"search_for_groups": "Search for groups",
"search_for_players": "Search for players",
"select_winner": "Select Winner:",
"selected_players": "Selected players",
"settings": "Settings",
"single_loser": "Single Loser",
"single_winner": "Single Winner",
"statistics": "Statistics",
"stats": "Stats",
"successfully_added_player": "Successfully added player {playerName}",
"there_is_no_group_matching_your_search": "There is no group matching your search",
"this_cannot_be_undone": "This can't be undone",
"today_at": "Today at",
"undo": "Undo",
"unknown_exception": "Unknown Exception (see console)",
"winner": "Winner",
"winrate": "Winrate",
"wins": "Wins",
"yesterday_at": "Yesterday at"
}

View File

@@ -0,0 +1,620 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart' as intl;
import 'app_localizations_de.dart';
import 'app_localizations_en.dart';
// ignore_for_file: type=lint
/// Callers can lookup localized strings with an instance of AppLocalizations
/// returned by `AppLocalizations.of(context)`.
///
/// Applications need to include `AppLocalizations.delegate()` in their app's
/// `localizationDelegates` list, and the locales they support in the app's
/// `supportedLocales` list. For example:
///
/// ```dart
/// import 'generated/app_localizations.dart';
///
/// return MaterialApp(
/// localizationsDelegates: AppLocalizations.localizationsDelegates,
/// supportedLocales: AppLocalizations.supportedLocales,
/// home: MyApplicationHome(),
/// );
/// ```
///
/// ## Update pubspec.yaml
///
/// Please make sure to update your pubspec.yaml to include the following
/// packages:
///
/// ```yaml
/// dependencies:
/// # Internationalization support.
/// flutter_localizations:
/// sdk: flutter
/// intl: any # Use the pinned version from flutter_localizations
///
/// # Rest of dependencies
/// ```
///
/// ## iOS Applications
///
/// iOS applications define key application metadata, including supported
/// locales, in an Info.plist file that is built into the application bundle.
/// To configure the locales supported by your app, youll need to edit this
/// file.
///
/// First, open your projects ios/Runner.xcworkspace Xcode workspace file.
/// Then, in the Project Navigator, open the Info.plist file under the Runner
/// projects Runner folder.
///
/// Next, select the Information Property List item, select Add Item from the
/// Editor menu, then select Localizations from the pop-up menu.
///
/// Select and expand the newly-created Localizations item then, for each
/// locale your application supports, add a new item and select the locale
/// you wish to add from the pop-up menu in the Value field. This list should
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
AppLocalizations(String locale)
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
final String localeName;
static AppLocalizations of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations)!;
}
static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();
/// A list of this localizations delegate along with the default localizations
/// delegates.
///
/// Returns a list of localizations delegates containing this delegate along with
/// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
/// and GlobalWidgetsLocalizations.delegate.
///
/// Additional delegates can be added by appending to this list in
/// MaterialApp. This list does not have to be used at all if a custom list
/// of delegates is preferred or required.
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
<LocalizationsDelegate<dynamic>>[
delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
];
/// A list of this localizations delegate's supported locales.
static const List<Locale> supportedLocales = <Locale>[
Locale('de'),
Locale('en'),
];
/// Label for all players list
///
/// In en, this message translates to:
/// **'All players'**
String get all_players;
/// Message when all players are added to selection
///
/// In en, this message translates to:
/// **'All players selected'**
String get all_players_selected;
/// Label for amount of matches statistic
///
/// In en, this message translates to:
/// **'Amount of Matches'**
String get amount_of_matches;
/// The name of the App
///
/// In en, this message translates to:
/// **'Game Tracker'**
String get app_name;
/// Cancel button text
///
/// In en, this message translates to:
/// **'Cancel'**
String get cancel;
/// Label for choosing a game
///
/// In en, this message translates to:
/// **'Choose Game'**
String get choose_game;
/// Label for choosing a group
///
/// In en, this message translates to:
/// **'Choose Group'**
String get choose_group;
/// Label for choosing a ruleset
///
/// In en, this message translates to:
/// **'Choose Ruleset'**
String get choose_ruleset;
/// Error message when adding a player fails
///
/// In en, this message translates to:
/// **'Could not add player'**
String could_not_add_player(Object playerName);
/// Button text to create a group
///
/// In en, this message translates to:
/// **'Create Group'**
String get create_group;
/// Button text to create a match
///
/// In en, this message translates to:
/// **'Create match'**
String get create_match;
/// Button text to create a new group
///
/// In en, this message translates to:
/// **'Create new group'**
String get create_new_group;
/// Button text to create a new match
///
/// In en, this message translates to:
/// **'Create new match'**
String get create_new_match;
/// Success message after deleting data
///
/// In en, this message translates to:
/// **'Data successfully deleted'**
String get data_successfully_deleted;
/// Success message after exporting data
///
/// In en, this message translates to:
/// **'Data successfully exported'**
String get data_successfully_exported;
/// Success message after importing data
///
/// In en, this message translates to:
/// **'Data successfully imported'**
String get data_successfully_imported;
/// Date format for days ago
///
/// In en, this message translates to:
/// **'{count} days ago'**
String days_ago(int count);
/// Delete button text
///
/// In en, this message translates to:
/// **'Delete'**
String get delete;
/// Confirmation dialog for deleting all data
///
/// In en, this message translates to:
/// **'Delete all data'**
String get delete_all_data;
/// Error message when group creation fails
///
/// In en, this message translates to:
/// **'Error while creating group, please try again'**
String get error_creating_group;
/// Error message when file cannot be read
///
/// In en, this message translates to:
/// **'Error reading file'**
String get error_reading_file;
/// Message when export is canceled
///
/// In en, this message translates to:
/// **'Export canceled'**
String get export_canceled;
/// Export data menu item
///
/// In en, this message translates to:
/// **'Export data'**
String get export_data;
/// Error message for format exceptions
///
/// In en, this message translates to:
/// **'Format Exception (see console)'**
String get format_exception;
/// Game label
///
/// In en, this message translates to:
/// **'Game'**
String get game;
/// Placeholder for game name search
///
/// In en, this message translates to:
/// **'Game Name'**
String get game_name;
/// Group label
///
/// In en, this message translates to:
/// **'Group'**
String get group;
/// Placeholder for group name input
///
/// In en, this message translates to:
/// **'Group name'**
String get group_name;
/// Label for groups
///
/// In en, this message translates to:
/// **'Groups'**
String get groups;
/// Home tab label
///
/// In en, this message translates to:
/// **'Home'**
String get home;
/// Message when import is canceled
///
/// In en, this message translates to:
/// **'Import canceled'**
String get import_canceled;
/// Import data menu item
///
/// In en, this message translates to:
/// **'Import data'**
String get import_data;
/// Info label
///
/// In en, this message translates to:
/// **'Info'**
String get info;
/// Error message for invalid schema
///
/// In en, this message translates to:
/// **'Invalid Schema'**
String get invalid_schema;
/// Title for least points ruleset
///
/// In en, this message translates to:
/// **'Least Points'**
String get least_points;
/// Message when match is in progress
///
/// In en, this message translates to:
/// **'Match in progress...'**
String get match_in_progress;
/// Placeholder for match name input
///
/// In en, this message translates to:
/// **'Match name'**
String get match_name;
/// Label for matches
///
/// In en, this message translates to:
/// **'Matches'**
String get matches;
/// Menu label
///
/// In en, this message translates to:
/// **'Menu'**
String get menu;
/// Title for most points ruleset
///
/// In en, this message translates to:
/// **'Most Points'**
String get most_points;
/// Message when no data in the statistic tiles is given
///
/// In en, this message translates to:
/// **'No data available'**
String get no_data_available;
/// Message when no groups exist
///
/// In en, this message translates to:
/// **'No groups created yet'**
String get no_groups_created_yet;
/// Message when no matches exist
///
/// In en, this message translates to:
/// **'No matches created yet'**
String get no_matches_created_yet;
/// Message when no players exist
///
/// In en, this message translates to:
/// **'No players created yet'**
String get no_players_created_yet;
/// Message when search returns no results
///
/// In en, this message translates to:
/// **'No players found with that name'**
String get no_players_found_with_that_name;
/// Message when no players are selected
///
/// In en, this message translates to:
/// **'No players selected'**
String get no_players_selected;
/// Message when no recent matches exist
///
/// In en, this message translates to:
/// **'No recent matches available'**
String get no_recent_matches_available;
/// Message when no second match exists
///
/// In en, this message translates to:
/// **'No second match available'**
String get no_second_match_available;
/// Message when no statistics are available, because no matches were played yet
///
/// In en, this message translates to:
/// **'No statistics available'**
String get no_statistics_available;
/// None option label
///
/// In en, this message translates to:
/// **'None'**
String get none;
/// None group option label
///
/// In en, this message translates to:
/// **'None'**
String get none_group;
/// Abbreviation for not available
///
/// In en, this message translates to:
/// **'Not available'**
String get not_available;
/// Placeholder for player name input
///
/// In en, this message translates to:
/// **'Player name'**
String get player_name;
/// Players label
///
/// In en, this message translates to:
/// **'Players'**
String get players;
/// Shows the number of players
///
/// In en, this message translates to:
/// **'{count} Players'**
String players_count(int count);
/// Title for quick create section
///
/// In en, this message translates to:
/// **'Quick Create'**
String get quick_create;
/// Title for recent matches section
///
/// In en, this message translates to:
/// **'Recent Matches'**
String get recent_matches;
/// Ruleset label
///
/// In en, this message translates to:
/// **'Ruleset'**
String get ruleset;
/// Description for least points ruleset
///
/// In en, this message translates to:
/// **'Inverse scoring: the player with the fewest points wins.'**
String get ruleset_least_points;
/// Description for most points ruleset
///
/// In en, this message translates to:
/// **'Traditional ruleset: the player with the most points wins.'**
String get ruleset_most_points;
/// Description for single loser ruleset
///
/// In en, this message translates to:
/// **'Exactly one loser is determined; last place receives the penalty or consequence.'**
String get ruleset_single_loser;
/// Description for single winner ruleset
///
/// In en, this message translates to:
/// **'Exactly one winner is chosen; ties are resolved by a predefined tiebreaker.'**
String get ruleset_single_winner;
/// Hint text for group search input field
///
/// In en, this message translates to:
/// **'Search for groups'**
String get search_for_groups;
/// Hint text for player search input field
///
/// In en, this message translates to:
/// **'Search for players'**
String get search_for_players;
/// Label to select the winner
///
/// In en, this message translates to:
/// **'Select Winner:'**
String get select_winner;
/// Shows the number of selected players
///
/// In en, this message translates to:
/// **'Selected players'**
String get selected_players;
/// Settings label
///
/// In en, this message translates to:
/// **'Settings'**
String get settings;
/// Title for single loser ruleset
///
/// In en, this message translates to:
/// **'Single Loser'**
String get single_loser;
/// Title for single winner ruleset
///
/// In en, this message translates to:
/// **'Single Winner'**
String get single_winner;
/// Statistics tab label
///
/// In en, this message translates to:
/// **'Statistics'**
String get statistics;
/// Stats tab label (short)
///
/// In en, this message translates to:
/// **'Stats'**
String get stats;
/// Success message when adding a player
///
/// In en, this message translates to:
/// **'Successfully added player {playerName}'**
String successfully_added_player(String playerName);
/// Message when search returns no groups
///
/// In en, this message translates to:
/// **'There is no group matching your search'**
String get there_is_no_group_matching_your_search;
/// Warning message for irreversible actions
///
/// In en, this message translates to:
/// **'This can\'t be undone'**
String get this_cannot_be_undone;
/// Date format for today
///
/// In en, this message translates to:
/// **'Today at'**
String get today_at;
/// Undo button text
///
/// In en, this message translates to:
/// **'Undo'**
String get undo;
/// Error message for unknown exceptions
///
/// In en, this message translates to:
/// **'Unknown Exception (see console)'**
String get unknown_exception;
/// Winner label
///
/// In en, this message translates to:
/// **'Winner'**
String get winner;
/// Label for winrate statistic
///
/// In en, this message translates to:
/// **'Winrate'**
String get winrate;
/// Label for wins statistic
///
/// In en, this message translates to:
/// **'Wins'**
String get wins;
/// Date format for yesterday
///
/// In en, this message translates to:
/// **'Yesterday at'**
String get yesterday_at;
}
class _AppLocalizationsDelegate
extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate();
@override
Future<AppLocalizations> load(Locale locale) {
return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
}
@override
bool isSupported(Locale locale) =>
<String>['de', 'en'].contains(locale.languageCode);
@override
bool shouldReload(_AppLocalizationsDelegate old) => false;
}
AppLocalizations lookupAppLocalizations(Locale locale) {
// Lookup logic when only language code is specified.
switch (locale.languageCode) {
case 'de':
return AppLocalizationsDe();
case 'en':
return AppLocalizationsEn();
}
throw FlutterError(
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.',
);
}

View File

@@ -0,0 +1,269 @@
// ignore: unused_import
import 'package:intl/intl.dart' as intl;
import 'app_localizations.dart';
// ignore_for_file: type=lint
/// The translations for German (`de`).
class AppLocalizationsDe extends AppLocalizations {
AppLocalizationsDe([String locale = 'de']) : super(locale);
@override
String get all_players => 'Alle Spieler:innen';
@override
String get all_players_selected => 'Alle Spieler:innen ausgewählt';
@override
String get amount_of_matches => 'Anzahl der Spiele';
@override
String get app_name => 'Game Tracker';
@override
String get cancel => 'Abbrechen';
@override
String get choose_game => 'Spielvorlage wählen';
@override
String get choose_group => 'Gruppe wählen';
@override
String get choose_ruleset => 'Regelwerk wählen';
@override
String could_not_add_player(Object playerName) {
return 'Spieler:in $playerName konnte nicht hinzugefügt werden';
}
@override
String get create_group => 'Gruppe erstellen';
@override
String get create_match => 'Spiel erstellen';
@override
String get create_new_group => 'Neue Gruppe erstellen';
@override
String get create_new_match => 'Neues Spiel erstellen';
@override
String get data_successfully_deleted => 'Daten erfolgreich gelöscht';
@override
String get data_successfully_exported => 'Daten erfolgreich exportiert';
@override
String get data_successfully_imported => 'Daten erfolgreich importiert';
@override
String days_ago(int count) {
return 'vor $count Tagen';
}
@override
String get delete => 'Löschen';
@override
String get delete_all_data => 'Alle Daten löschen';
@override
String get error_creating_group =>
'Fehler beim Erstellen der Gruppe, bitte erneut versuchen';
@override
String get error_reading_file => 'Fehler beim Lesen der Datei';
@override
String get export_canceled => 'Export abgebrochen';
@override
String get export_data => 'Daten exportieren';
@override
String get format_exception => 'Formatfehler (siehe Konsole)';
@override
String get game => 'Spielvorlage';
@override
String get game_name => 'Spielvorlagenname';
@override
String get group => 'Gruppe';
@override
String get group_name => 'Gruppenname';
@override
String get groups => 'Gruppen';
@override
String get home => 'Startseite';
@override
String get import_canceled => 'Import abgebrochen';
@override
String get import_data => 'Daten importieren';
@override
String get info => 'Info';
@override
String get invalid_schema => 'Ungültiges Schema';
@override
String get least_points => 'Niedrigste Punkte';
@override
String get match_in_progress => 'Spiel läuft...';
@override
String get match_name => 'Spieltitel';
@override
String get matches => 'Spiele';
@override
String get menu => 'Menü';
@override
String get most_points => 'Höchste Punkte';
@override
String get no_data_available => 'Keine Daten verfügbar';
@override
String get no_groups_created_yet => 'Noch keine Gruppen erstellt';
@override
String get no_matches_created_yet => 'Noch keine Spiele erstellt';
@override
String get no_players_created_yet => 'Noch keine Spieler:in erstellt';
@override
String get no_players_found_with_that_name =>
'Keine Spieler:in mit diesem Namen gefunden';
@override
String get no_players_selected => 'Keine Spieler:innen ausgewählt';
@override
String get no_recent_matches_available => 'Keine letzten Spiele verfügbar';
@override
String get no_second_match_available => 'Kein zweites Spiel verfügbar';
@override
String get no_statistics_available => 'Keine Statistiken verfügbar';
@override
String get none => 'Kein';
@override
String get none_group => 'Keine';
@override
String get not_available => 'Nicht verfügbar';
@override
String get player_name => 'Spieler:innenname';
@override
String get players => 'Spieler:innen';
@override
String players_count(int count) {
return '$count Spieler';
}
@override
String get quick_create => 'Schnellzugriff';
@override
String get recent_matches => 'Letzte Spiele';
@override
String get ruleset => 'Regelwerk';
@override
String get ruleset_least_points =>
'Umgekehrte Wertung: Der/die Spieler:in mit den wenigsten Punkten gewinnt.';
@override
String get ruleset_most_points =>
'Traditionelles Regelwerk: Der/die Spieler:in mit den meisten Punkten gewinnt.';
@override
String get ruleset_single_loser =>
'Genau ein:e Verlierer:in wird bestimmt; der letzte Platz erhält die Strafe oder Konsequenz.';
@override
String get ruleset_single_winner =>
'Genau ein:e Gewinner:in wird gewählt; Unentschieden werden durch einen vordefinierten Tie-Breaker aufgelöst.';
@override
String get search_for_groups => 'Nach Gruppen suchen';
@override
String get search_for_players => 'Nach Spieler:innen suchen';
@override
String get select_winner => 'Gewinner:in wählen:';
@override
String get selected_players => 'Ausgewählte Spieler:innen';
@override
String get settings => 'Einstellungen';
@override
String get single_loser => 'Ein:e Verlierer:in';
@override
String get single_winner => 'Ein:e Gewinner:in';
@override
String get statistics => 'Statistiken';
@override
String get stats => 'Statistiken';
@override
String successfully_added_player(String playerName) {
return 'Spieler:in $playerName erfolgreich hinzugefügt';
}
@override
String get there_is_no_group_matching_your_search =>
'Es gibt keine Gruppe, die deiner Suche entspricht';
@override
String get this_cannot_be_undone =>
'Dies kann nicht rückgängig gemacht werden';
@override
String get today_at => 'Heute um';
@override
String get undo => 'Rückgängig';
@override
String get unknown_exception => 'Unbekannter Fehler (siehe Konsole)';
@override
String get winner => 'Gewinner:in';
@override
String get winrate => 'Siegquote';
@override
String get wins => 'Siege';
@override
String get yesterday_at => 'Gestern um';
}

View File

@@ -0,0 +1,268 @@
// ignore: unused_import
import 'package:intl/intl.dart' as intl;
import 'app_localizations.dart';
// ignore_for_file: type=lint
/// The translations for English (`en`).
class AppLocalizationsEn extends AppLocalizations {
AppLocalizationsEn([String locale = 'en']) : super(locale);
@override
String get all_players => 'All players';
@override
String get all_players_selected => 'All players selected';
@override
String get amount_of_matches => 'Amount of Matches';
@override
String get app_name => 'Game Tracker';
@override
String get cancel => 'Cancel';
@override
String get choose_game => 'Choose Game';
@override
String get choose_group => 'Choose Group';
@override
String get choose_ruleset => 'Choose Ruleset';
@override
String could_not_add_player(Object playerName) {
return 'Could not add player';
}
@override
String get create_group => 'Create Group';
@override
String get create_match => 'Create match';
@override
String get create_new_group => 'Create new group';
@override
String get create_new_match => 'Create new match';
@override
String get data_successfully_deleted => 'Data successfully deleted';
@override
String get data_successfully_exported => 'Data successfully exported';
@override
String get data_successfully_imported => 'Data successfully imported';
@override
String days_ago(int count) {
return '$count days ago';
}
@override
String get delete => 'Delete';
@override
String get delete_all_data => 'Delete all data';
@override
String get error_creating_group =>
'Error while creating group, please try again';
@override
String get error_reading_file => 'Error reading file';
@override
String get export_canceled => 'Export canceled';
@override
String get export_data => 'Export data';
@override
String get format_exception => 'Format Exception (see console)';
@override
String get game => 'Game';
@override
String get game_name => 'Game Name';
@override
String get group => 'Group';
@override
String get group_name => 'Group name';
@override
String get groups => 'Groups';
@override
String get home => 'Home';
@override
String get import_canceled => 'Import canceled';
@override
String get import_data => 'Import data';
@override
String get info => 'Info';
@override
String get invalid_schema => 'Invalid Schema';
@override
String get least_points => 'Least Points';
@override
String get match_in_progress => 'Match in progress...';
@override
String get match_name => 'Match name';
@override
String get matches => 'Matches';
@override
String get menu => 'Menu';
@override
String get most_points => 'Most Points';
@override
String get no_data_available => 'No data available';
@override
String get no_groups_created_yet => 'No groups created yet';
@override
String get no_matches_created_yet => 'No matches created yet';
@override
String get no_players_created_yet => 'No players created yet';
@override
String get no_players_found_with_that_name =>
'No players found with that name';
@override
String get no_players_selected => 'No players selected';
@override
String get no_recent_matches_available => 'No recent matches available';
@override
String get no_second_match_available => 'No second match available';
@override
String get no_statistics_available => 'No statistics available';
@override
String get none => 'None';
@override
String get none_group => 'None';
@override
String get not_available => 'Not available';
@override
String get player_name => 'Player name';
@override
String get players => 'Players';
@override
String players_count(int count) {
return '$count Players';
}
@override
String get quick_create => 'Quick Create';
@override
String get recent_matches => 'Recent Matches';
@override
String get ruleset => 'Ruleset';
@override
String get ruleset_least_points =>
'Inverse scoring: the player with the fewest points wins.';
@override
String get ruleset_most_points =>
'Traditional ruleset: the player with the most points wins.';
@override
String get ruleset_single_loser =>
'Exactly one loser is determined; last place receives the penalty or consequence.';
@override
String get ruleset_single_winner =>
'Exactly one winner is chosen; ties are resolved by a predefined tiebreaker.';
@override
String get search_for_groups => 'Search for groups';
@override
String get search_for_players => 'Search for players';
@override
String get select_winner => 'Select Winner:';
@override
String get selected_players => 'Selected players';
@override
String get settings => 'Settings';
@override
String get single_loser => 'Single Loser';
@override
String get single_winner => 'Single Winner';
@override
String get statistics => 'Statistics';
@override
String get stats => 'Stats';
@override
String successfully_added_player(String playerName) {
return 'Successfully added player $playerName';
}
@override
String get there_is_no_group_matching_your_search =>
'There is no group matching your search';
@override
String get this_cannot_be_undone => 'This can\'t be undone';
@override
String get today_at => 'Today at';
@override
String get undo => 'Undo';
@override
String get unknown_exception => 'Unknown Exception (see console)';
@override
String get winner => 'Winner';
@override
String get winrate => 'Winrate';
@override
String get wins => 'Wins';
@override
String get yesterday_at => 'Yesterday at';
}

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/data/db/database.dart'; import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/views/main_menu/custom_navigation_bar.dart'; import 'package:game_tracker/presentation/views/main_menu/custom_navigation_bar.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -20,22 +21,36 @@ class GameTracker extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
localeResolutionCallback: (locale, supportedLocales) {
for (final supportedLocale in supportedLocales) {
if (supportedLocale.languageCode == locale?.languageCode) {
return supportedLocale;
}
}
return supportedLocales.firstWhere(
(locale) => locale.languageCode == 'en',
);
},
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
title: 'Game Tracker', onGenerateTitle: (context) => AppLocalizations.of(context).app_name,
darkTheme: ThemeData.dark(),
themeMode: ThemeMode.dark, // forces dark mode themeMode: ThemeMode.dark, // forces dark mode
theme: ThemeData( theme: ThemeData(
primaryColor: CustomTheme.primaryColor, primaryColor: CustomTheme.primaryColor,
scaffoldBackgroundColor: CustomTheme.backgroundColor, scaffoldBackgroundColor: CustomTheme.backgroundColor,
appBarTheme: CustomTheme.appBarTheme, appBarTheme: CustomTheme.appBarTheme,
colorScheme: ColorScheme.fromSeed( colorScheme: ColorScheme.fromSeed(
seedColor: CustomTheme.primaryColor, seedColor: CustomTheme.primaryColor,
brightness: Brightness.dark, brightness: Brightness.dark,
).copyWith(surface: CustomTheme.backgroundColor), ).copyWith(surface: CustomTheme.backgroundColor),
pageTransitionsTheme: const PageTransitionsTheme(
builders: {
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
TargetPlatform.android: PredictiveBackPageTransitionsBuilder(),
},
),
), ),
home: const CustomNavigationBar(), home: const CustomNavigationBar(),
); );
} }

View File

@@ -1,5 +1,9 @@
import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/adaptive_page_route.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/views/main_menu/group_view/groups_view.dart'; import 'package:game_tracker/presentation/views/main_menu/group_view/groups_view.dart';
import 'package:game_tracker/presentation/views/main_menu/home_view.dart'; import 'package:game_tracker/presentation/views/main_menu/home_view.dart';
import 'package:game_tracker/presentation/views/main_menu/match_view/match_view.dart'; import 'package:game_tracker/presentation/views/main_menu/match_view/match_view.dart';
@@ -16,16 +20,15 @@ class CustomNavigationBar extends StatefulWidget {
class _CustomNavigationBarState extends State<CustomNavigationBar> class _CustomNavigationBarState extends State<CustomNavigationBar>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
/// Currently selected tab index
int currentIndex = 0; int currentIndex = 0;
/// Key count to force rebuild of tab views
int tabKeyCount = 0; int tabKeyCount = 0;
@override
void initState() {
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
// Pretty ugly but works // Pretty ugly but works
final List<Widget> tabs = [ final List<Widget> tabs = [
KeyedSubtree(key: ValueKey('home_$tabKeyCount'), child: const HomeView()), KeyedSubtree(key: ValueKey('home_$tabKeyCount'), child: const HomeView()),
@@ -46,7 +49,7 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
appBar: AppBar( appBar: AppBar(
centerTitle: true, centerTitle: true,
title: Text( title: Text(
_currentTabTitle(), _currentTabTitle(context),
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold), style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
), ),
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
@@ -56,7 +59,7 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
onPressed: () async { onPressed: () async {
await Navigator.push( await Navigator.push(
context, context,
MaterialPageRoute(builder: (_) => const SettingsView()), adaptivePageRoute(builder: (_) => const SettingsView()),
); );
setState(() { setState(() {
tabKeyCount++; tabKeyCount++;
@@ -70,18 +73,61 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
body: tabs[currentIndex], body: tabs[currentIndex],
extendBody: true, extendBody: true,
bottomNavigationBar: SafeArea( bottomNavigationBar: SizedBox(
minimum: const EdgeInsets.only(bottom: 30), height: 70 + MediaQuery.of(context).padding.bottom,
child: Container( child: Stack(
margin: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 10), children: [
decoration: BoxDecoration( // Dynamisch generierte Blur-Layer für ultra-smooth Übergang
borderRadius: BorderRadius.circular(24), ...List.generate(35, (index) {
color: CustomTheme.primaryColor, // Verwende kubische Kurve für noch natürlicheren, weicheren Übergang
final progress = index / 34.0; // 0.0 bis 1.0
final cubic = progress * progress * progress; // Kubische Kurve
final blurStrength = 0.5 + (cubic * 50.0); // Sehr sanft von 0.5 bis 50.5
// Höhe geht jetzt komplett von 100% bis 0% (ganz nach unten)
// Mit extra Dichte am unteren Ende für weicheren Übergang
final heightFactor = index < 25
? 1.0 - (progress * 0.7) // Erste 25 Layer: 100% bis 30%
: 0.3 - ((index - 25) / 34.0); // Letzte 10 Layer: 30% bis 0% (dichter)
return Positioned(
left: 0,
right: 0,
bottom: 0,
height: (70 + MediaQuery.of(context).padding.bottom) * heightFactor.clamp(0.05, 1.0),
child: ClipRect(
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: blurStrength,
sigmaY: blurStrength,
), ),
child: ClipRRect( child: Container(
borderRadius: BorderRadius.circular(24), color: Colors.transparent,
),
),
),
);
}),
// Gradient-Overlay
Positioned.fill(
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [
CustomTheme.boxColor.withValues(alpha: 1),
CustomTheme.boxColor.withValues(alpha: 0.0),
],
stops: const [0.4, 1],
),
),
),
),
// Navbar-Inhalt
SafeArea(
child: SizedBox( child: SizedBox(
height: 60, height: 70,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[ children: <Widget>[
@@ -89,55 +135,59 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
index: 0, index: 0,
isSelected: currentIndex == 0, isSelected: currentIndex == 0,
icon: Icons.home_rounded, icon: Icons.home_rounded,
label: 'Home', label: loc.home,
onTabTapped: onTabTapped, onTabTapped: onTabTapped,
), ),
NavbarItem( NavbarItem(
index: 1, index: 1,
isSelected: currentIndex == 1, isSelected: currentIndex == 1,
icon: Icons.gamepad_rounded, icon: Icons.gamepad_rounded,
label: 'Matches', label: loc.matches,
onTabTapped: onTabTapped, onTabTapped: onTabTapped,
), ),
NavbarItem( NavbarItem(
index: 2, index: 2,
isSelected: currentIndex == 2, isSelected: currentIndex == 2,
icon: Icons.group_rounded, icon: Icons.group_rounded,
label: 'Groups', label: loc.groups,
onTabTapped: onTabTapped, onTabTapped: onTabTapped,
), ),
NavbarItem( NavbarItem(
index: 3, index: 3,
isSelected: currentIndex == 3, isSelected: currentIndex == 3,
icon: Icons.bar_chart_rounded, icon: Icons.bar_chart_rounded,
label: 'Stats', label: loc.statistics,
onTabTapped: onTabTapped, onTabTapped: onTabTapped,
), ),
], ],
), ),
), ),
), ),
],
), ),
), ),
); );
} }
/// Handles tab tap events. Updates the current [index] state.
void onTabTapped(int index) { void onTabTapped(int index) {
setState(() { setState(() {
currentIndex = index; currentIndex = index;
}); });
} }
String _currentTabTitle() { /// Returns the title of the current tab based on [currentIndex].
String _currentTabTitle(context) {
final loc = AppLocalizations.of(context);
switch (currentIndex) { switch (currentIndex) {
case 0: case 0:
return 'Home'; return loc.home;
case 1: case 1:
return 'Matches'; return loc.matches;
case 2: case 2:
return 'Groups'; return loc.groups;
case 3: case 3:
return 'Statistics'; return loc.statistics;
default: default:
return ''; return '';
} }

View File

@@ -4,6 +4,7 @@ import 'package:game_tracker/core/enums.dart';
import 'package:game_tracker/data/db/database.dart'; import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/data/dto/group.dart';
import 'package:game_tracker/data/dto/player.dart'; import 'package:game_tracker/data/dto/player.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart'; import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
import 'package:game_tracker/presentation/widgets/player_selection.dart'; import 'package:game_tracker/presentation/widgets/player_selection.dart';
import 'package:game_tracker/presentation/widgets/text_input/text_input_field.dart'; import 'package:game_tracker/presentation/widgets/text_input/text_input_field.dart';
@@ -17,8 +18,12 @@ class CreateGroupView extends StatefulWidget {
} }
class _CreateGroupViewState extends State<CreateGroupView> { class _CreateGroupViewState extends State<CreateGroupView> {
final _groupNameController = TextEditingController();
late final AppDatabase db; late final AppDatabase db;
/// Controller for the group name input field
final _groupNameController = TextEditingController();
/// List of currently selected players
List<Player> selectedPlayers = []; List<Player> selectedPlayers = [];
@override @override
@@ -38,29 +43,20 @@ class _CreateGroupViewState extends State<CreateGroupView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( final loc = AppLocalizations.of(context);
return ScaffoldMessenger(
child: Scaffold(
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
appBar: AppBar( appBar: AppBar(title: Text(loc.create_new_group)),
backgroundColor: CustomTheme.backgroundColor,
scrolledUnderElevation: 0,
title: const Text(
'Create new group',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
centerTitle: true,
),
body: SafeArea( body: SafeArea(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Container( Container(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), margin: CustomTheme.standardMargin,
child: TextInputField( child: TextInputField(
controller: _groupNameController, controller: _groupNameController,
hintText: 'Group name', hintText: loc.group_name,
onChanged: (value) {
setState(() {});
},
), ),
), ),
Expanded( Expanded(
@@ -73,7 +69,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
), ),
), ),
CustomWidthButton( CustomWidthButton(
text: 'Create group', text: loc.create_group,
sizeRelativeToWidth: 0.95, sizeRelativeToWidth: 0.95,
buttonType: ButtonType.primary, buttonType: ButtonType.primary,
onPressed: onPressed:
@@ -94,22 +90,24 @@ class _CreateGroupViewState extends State<CreateGroupView> {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
backgroundColor: CustomTheme.boxColor, backgroundColor: CustomTheme.boxColor,
content: const Center( content: Center(
child: Text( child: Text(
'Error while creating group, please try again', AppLocalizations.of(
style: TextStyle(color: Colors.white), context,
).error_creating_group,
style: const TextStyle(color: Colors.white),
), ),
), ),
), ),
); );
} }
setState(() {});
}, },
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
], ],
), ),
), ),
),
); );
} }
} }

View File

@@ -1,9 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/adaptive_page_route.dart';
import 'package:game_tracker/core/constants.dart'; import 'package:game_tracker/core/constants.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/data/db/database.dart'; import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/data/dto/group.dart';
import 'package:game_tracker/data/dto/player.dart'; import 'package:game_tracker/data/dto/player.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/views/main_menu/group_view/create_group_view.dart'; import 'package:game_tracker/presentation/views/main_menu/group_view/create_group_view.dart';
import 'package:game_tracker/presentation/widgets/app_skeleton.dart'; import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart'; import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
@@ -20,7 +22,11 @@ class GroupsView extends StatefulWidget {
class _GroupsViewState extends State<GroupsView> { class _GroupsViewState extends State<GroupsView> {
late final AppDatabase db; late final AppDatabase db;
/// Loaded groups from the database
late List<Group> loadedGroups; late List<Group> loadedGroups;
/// Loading state
bool isLoading = true; bool isLoading = true;
List<Group> groups = List.filled( List<Group> groups = List.filled(
@@ -34,12 +40,14 @@ class _GroupsViewState extends State<GroupsView> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
db = Provider.of<AppDatabase>(context, listen: false); db = Provider.of<AppDatabase>(context, listen: false);
loadGroups(); loadGroups();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return Scaffold( return Scaffold(
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
body: Stack( body: Stack(
@@ -49,11 +57,11 @@ class _GroupsViewState extends State<GroupsView> {
enabled: isLoading, enabled: isLoading,
child: Visibility( child: Visibility(
visible: groups.isNotEmpty, visible: groups.isNotEmpty,
replacement: const Center( replacement: Center(
child: TopCenteredMessage( child: TopCenteredMessage(
icon: Icons.info, icon: Icons.info,
title: 'Info', title: loc.info,
message: 'No groups created yet', message: loc.no_groups_created_yet,
), ),
), ),
child: ListView.builder( child: ListView.builder(
@@ -73,12 +81,12 @@ class _GroupsViewState extends State<GroupsView> {
Positioned( Positioned(
bottom: MediaQuery.paddingOf(context).bottom, bottom: MediaQuery.paddingOf(context).bottom,
child: CustomWidthButton( child: CustomWidthButton(
text: 'Create Group', text: loc.create_group,
sizeRelativeToWidth: 0.90, sizeRelativeToWidth: 0.90,
onPressed: () async { onPressed: () async {
await Navigator.push( await Navigator.push(
context, context,
MaterialPageRoute( adaptivePageRoute(
builder: (context) { builder: (context) {
return const CreateGroupView(); return const CreateGroupView();
}, },
@@ -98,7 +106,7 @@ class _GroupsViewState extends State<GroupsView> {
void loadGroups() { void loadGroups() {
Future.wait([ Future.wait([
db.groupDao.getAllGroups(), db.groupDao.getAllGroups(),
Future.delayed(minimumSkeletonDuration), Future.delayed(Constants.minimumSkeletonDuration),
]).then((results) { ]).then((results) {
loadedGroups = results[0] as List<Group>; loadedGroups = results[0] as List<Group>;
setState(() { setState(() {

View File

@@ -1,13 +1,16 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/adaptive_page_route.dart';
import 'package:game_tracker/core/constants.dart'; import 'package:game_tracker/core/constants.dart';
import 'package:game_tracker/data/db/database.dart'; import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/data/dto/group.dart';
import 'package:game_tracker/data/dto/match.dart'; import 'package:game_tracker/data/dto/match.dart';
import 'package:game_tracker/data/dto/player.dart'; import 'package:game_tracker/data/dto/player.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/views/main_menu/match_view/match_result_view.dart';
import 'package:game_tracker/presentation/widgets/app_skeleton.dart'; import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
import 'package:game_tracker/presentation/widgets/buttons/quick_create_button.dart'; import 'package:game_tracker/presentation/widgets/buttons/quick_create_button.dart';
import 'package:game_tracker/presentation/widgets/tiles/game_tile.dart';
import 'package:game_tracker/presentation/widgets/tiles/info_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/info_tile.dart';
import 'package:game_tracker/presentation/widgets/tiles/match_tile.dart';
import 'package:game_tracker/presentation/widgets/tiles/quick_info_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/quick_info_tile.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -20,9 +23,17 @@ class HomeView extends StatefulWidget {
class _HomeViewState extends State<HomeView> { class _HomeViewState extends State<HomeView> {
bool isLoading = true; bool isLoading = true;
/// Amount of matches in the database
int matchCount = 0; int matchCount = 0;
/// Amount of groups in the database
int groupCount = 0; int groupCount = 0;
/// Loaded recent matches from the database
List<Match> loadedRecentMatches = []; List<Match> loadedRecentMatches = [];
/// Recent matches to display, initially filled with skeleton matches
List<Match> recentMatches = List.filled( List<Match> recentMatches = List.filled(
2, 2,
Match( Match(
@@ -34,43 +45,18 @@ class _HomeViewState extends State<HomeView> {
Player(name: 'Skeleton Player 2'), Player(name: 'Skeleton Player 2'),
], ],
), ),
winner: Player(name: 'Skeleton Player 1'),
), ),
); );
@override @override
void initState() { void initState() {
super.initState(); super.initState();
final db = Provider.of<AppDatabase>(context, listen: false); loadHomeViewData();
Future.wait([
db.matchDao.getMatchCount(),
db.groupDao.getGroupCount(),
db.matchDao.getAllMatches(),
Future.delayed(minimumSkeletonDuration),
]).then((results) {
matchCount = results[0] as int;
groupCount = results[1] as int;
loadedRecentMatches = results[2] as List<Match>;
recentMatches =
(loadedRecentMatches
..sort((a, b) => b.createdAt.compareTo(a.createdAt)))
.take(2)
.toList();
if (loadedRecentMatches.length < 2) {
recentMatches.add(
Match(name: 'Dummy Match', winner: null, group: null, players: null),
);
}
if (mounted) {
setState(() {
isLoading = false;
});
}
});
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return LayoutBuilder( return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {
return AppSkeleton( return AppSkeleton(
@@ -86,7 +72,7 @@ class _HomeViewState extends State<HomeView> {
QuickInfoTile( QuickInfoTile(
width: constraints.maxWidth * 0.45, width: constraints.maxWidth * 0.45,
height: constraints.maxHeight * 0.15, height: constraints.maxHeight * 0.15,
title: 'Matches', title: loc.matches,
icon: Icons.groups_rounded, icon: Icons.groups_rounded,
value: matchCount, value: matchCount,
), ),
@@ -94,7 +80,7 @@ class _HomeViewState extends State<HomeView> {
QuickInfoTile( QuickInfoTile(
width: constraints.maxWidth * 0.45, width: constraints.maxWidth * 0.45,
height: constraints.maxHeight * 0.15, height: constraints.maxHeight * 0.15,
title: 'Groups', title: loc.groups,
icon: Icons.groups_rounded, icon: Icons.groups_rounded,
value: groupCount, value: groupCount,
), ),
@@ -104,59 +90,46 @@ class _HomeViewState extends State<HomeView> {
padding: const EdgeInsets.symmetric(vertical: 16.0), padding: const EdgeInsets.symmetric(vertical: 16.0),
child: InfoTile( child: InfoTile(
width: constraints.maxWidth * 0.95, width: constraints.maxWidth * 0.95,
title: 'Recent Matches', title: loc.recent_matches,
icon: Icons.timer, icon: Icons.history_rounded,
content: Padding( content: Column(
padding: const EdgeInsets.symmetric(horizontal: 40.0),
child: Visibility(
visible: !isLoading && loadedRecentMatches.isNotEmpty,
replacement: const Center(
heightFactor: 12,
child: Text('No recent games available'),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
MatchTile( if (recentMatches.isNotEmpty)
matchTitle: recentMatches[0].name, for (Match match in recentMatches)
game: 'Winner', Padding(
ruleset: 'Ruleset', padding: const EdgeInsets.symmetric(
players: _getPlayerText(recentMatches[0]), vertical: 6.0,
winner: recentMatches[0].winner == null
? 'Match in progress...'
: recentMatches[0].winner!.name,
), ),
const Padding( child: MatchTile(
padding: EdgeInsets.symmetric(vertical: 8.0), compact: true,
child: Divider(), width: constraints.maxWidth * 0.9,
match: match,
onTap: () async {
await Navigator.of(context).push(
adaptivePageRoute(
fullscreenDialog: true,
builder: (context) =>
MatchResultView(match: match),
), ),
if (loadedRecentMatches.length > 1) ...[ );
MatchTile( await updatedWinnerinRecentMatches(match.id);
matchTitle: recentMatches[1].name, },
game: 'Winner',
ruleset: 'Ruleset',
players: _getPlayerText(recentMatches[1]),
winner: recentMatches[1].winner == null
? 'Game in progress...'
: recentMatches[1].winner!.name,
), ),
const SizedBox(height: 8), )
] else ...[ else
const Center( Center(
heightFactor: 5.35, heightFactor: 5,
child: Text('No second game available'), child: Text(loc.no_recent_matches_available),
), ),
], ],
],
), ),
), ),
), ),
), Padding(
), padding: EdgeInsets.zero,
InfoTile( child: InfoTile(
width: constraints.maxWidth * 0.95, width: constraints.maxWidth * 0.95,
title: 'Quick Create', title: loc.quick_create,
icon: Icons.add_box_rounded, icon: Icons.add_box_rounded,
content: Column( content: Column(
children: [ children: [
@@ -202,6 +175,8 @@ class _HomeViewState extends State<HomeView> {
], ],
), ),
), ),
),
SizedBox(height: MediaQuery.paddingOf(context).bottom),
], ],
), ),
), ),
@@ -210,14 +185,41 @@ class _HomeViewState extends State<HomeView> {
); );
} }
String _getPlayerText(Match game) { /// Loads the data for the HomeView from the database.
if (game.group == null) { /// This includes the match count, group count, and recent matches.
final playerCount = game.players?.length ?? 0; Future<void> loadHomeViewData() async {
return '$playerCount Players'; final db = Provider.of<AppDatabase>(context, listen: false);
Future.wait([
db.matchDao.getMatchCount(),
db.groupDao.getGroupCount(),
db.matchDao.getAllMatches(),
Future.delayed(Constants.minimumSkeletonDuration),
]).then((results) {
matchCount = results[0] as int;
groupCount = results[1] as int;
loadedRecentMatches = results[2] as List<Match>;
recentMatches =
(loadedRecentMatches
..sort((a, b) => b.createdAt.compareTo(a.createdAt)))
.take(2)
.toList();
if (mounted) {
setState(() {
isLoading = false;
});
} }
if (game.players == null || game.players!.isEmpty) { });
return game.group!.name; }
/// Updates the winner information for a specific match in the recent matches list.
Future<void> updatedWinnerinRecentMatches(String matchId) async {
final db = Provider.of<AppDatabase>(context, listen: false);
final winner = await db.matchDao.getWinner(matchId: matchId);
final matchIndex = recentMatches.indexWhere((match) => match.id == matchId);
if (matchIndex != -1) {
setState(() {
recentMatches[matchIndex].winner = winner;
});
} }
return '${game.group!.name} + ${game.players!.length}';
} }
} }

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/core/enums.dart'; import 'package:game_tracker/core/enums.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/text_input/custom_search_bar.dart'; import 'package:game_tracker/presentation/widgets/text_input/custom_search_bar.dart';
import 'package:game_tracker/presentation/widgets/tiles/title_description_list_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/title_description_list_tile.dart';
@@ -19,9 +20,12 @@ class ChooseGameView extends StatefulWidget {
} }
class _ChooseGameViewState extends State<ChooseGameView> { class _ChooseGameViewState extends State<ChooseGameView> {
late int selectedGameIndex; /// Controller for the search bar
final TextEditingController searchBarController = TextEditingController(); final TextEditingController searchBarController = TextEditingController();
/// Currently selected game index
late int selectedGameIndex;
@override @override
void initState() { void initState() {
selectedGameIndex = widget.initialGameIndex; selectedGameIndex = widget.initialGameIndex;
@@ -30,30 +34,35 @@ class _ChooseGameViewState extends State<ChooseGameView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return Scaffold( return Scaffold(
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
appBar: AppBar( appBar: AppBar(
backgroundColor: CustomTheme.backgroundColor,
scrolledUnderElevation: 0,
leading: IconButton( leading: IconButton(
icon: const Icon(Icons.arrow_back_ios), icon: const Icon(Icons.arrow_back_ios),
onPressed: () { onPressed: () {
Navigator.of(context).pop(selectedGameIndex); Navigator.of(context).pop(selectedGameIndex);
}, },
), ),
title: const Text( title: Text(loc.choose_game),
'Choose Game',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
), ),
centerTitle: true, body: PopScope(
), // This fixes that the Android Back Gesture didn't return the
body: Column( // selectedGameIndex and therefore the selected Game wasn't saved
canPop: false,
onPopInvokedWithResult: (bool didPop, Object? result) {
if (didPop) {
return;
}
Navigator.of(context).pop(selectedGameIndex);
},
child: Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
child: CustomSearchBar( child: CustomSearchBar(
controller: searchBarController, controller: searchBarController,
hintText: 'Game Name', hintText: loc.game_name,
), ),
), ),
const SizedBox(height: 5), const SizedBox(height: 5),
@@ -64,7 +73,10 @@ class _ChooseGameViewState extends State<ChooseGameView> {
return TitleDescriptionListTile( return TitleDescriptionListTile(
title: widget.games[index].$1, title: widget.games[index].$1,
description: widget.games[index].$2, description: widget.games[index].$2,
badgeText: translateRulesetToString(widget.games[index].$3), badgeText: translateRulesetToString(
widget.games[index].$3,
context,
),
isHighlighted: selectedGameIndex == index, isHighlighted: selectedGameIndex == index,
onPressed: () async { onPressed: () async {
setState(() { setState(() {
@@ -81,6 +93,7 @@ class _ChooseGameViewState extends State<ChooseGameView> {
), ),
], ],
), ),
),
); );
} }
} }

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/data/dto/group.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/text_input/custom_search_bar.dart'; import 'package:game_tracker/presentation/widgets/text_input/custom_search_bar.dart';
import 'package:game_tracker/presentation/widgets/tiles/group_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/group_tile.dart';
import 'package:game_tracker/presentation/widgets/top_centered_message.dart'; import 'package:game_tracker/presentation/widgets/top_centered_message.dart';
@@ -22,7 +23,6 @@ class ChooseGroupView extends StatefulWidget {
class _ChooseGroupViewState extends State<ChooseGroupView> { class _ChooseGroupViewState extends State<ChooseGroupView> {
late String selectedGroupId; late String selectedGroupId;
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
final String hintText = 'Group Name';
late final List<Group> filteredGroups; late final List<Group> filteredGroups;
@override @override
@@ -34,11 +34,10 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return Scaffold( return Scaffold(
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
appBar: AppBar( appBar: AppBar(
backgroundColor: CustomTheme.backgroundColor,
scrolledUnderElevation: 0,
leading: IconButton( leading: IconButton(
icon: const Icon(Icons.arrow_back_ios), icon: const Icon(Icons.arrow_back_ios),
onPressed: () { onPressed: () {
@@ -51,19 +50,31 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
); );
}, },
), ),
title: const Text( title: Text(loc.choose_group),
'Choose Group',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
), ),
centerTitle: true, body: PopScope(
// This fixes that the Android Back Gesture didn't return the
// selectedGroupId and therefore the selected Group wasn't saved
canPop: false,
onPopInvokedWithResult: (bool didPop, Object? result) {
if (didPop) {
return;
}
Navigator.of(context).pop(
selectedGroupId == ''
? null
: widget.groups.firstWhere(
(group) => group.id == selectedGroupId,
), ),
body: Column( );
},
child: Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
child: CustomSearchBar( child: CustomSearchBar(
controller: controller, controller: controller,
hintText: hintText, hintText: loc.search_for_groups,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
filterGroups(value); filterGroups(value);
@@ -76,15 +87,17 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
visible: filteredGroups.isNotEmpty, visible: filteredGroups.isNotEmpty,
replacement: Visibility( replacement: Visibility(
visible: widget.groups.isNotEmpty, visible: widget.groups.isNotEmpty,
replacement: const TopCenteredMessage( replacement: TopCenteredMessage(
icon: Icons.info, icon: Icons.info,
title: 'Info', title: loc.info,
message: 'You have no groups created yet', message: loc.no_groups_created_yet,
), ),
child: const TopCenteredMessage( child: TopCenteredMessage(
icon: Icons.info, icon: Icons.info,
title: 'Info', title: loc.info,
message: 'There is no group matching your search', message: AppLocalizations.of(
context,
).there_is_no_group_matching_your_search,
), ),
), ),
child: ListView.builder( child: ListView.builder(
@@ -113,11 +126,11 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
), ),
], ],
), ),
),
); );
} }
/// Filters the groups based on the search query. /// Filters the groups based on the search [query].
/// TODO: Maybe implement also targetting player names?
void filterGroups(String query) { void filterGroups(String query) {
setState(() { setState(() {
if (query.isEmpty) { if (query.isEmpty) {
@@ -127,7 +140,11 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
filteredGroups.clear(); filteredGroups.clear();
filteredGroups.addAll( filteredGroups.addAll(
widget.groups.where( widget.groups.where(
(group) => group.name.toLowerCase().contains(query.toLowerCase()), (group) =>
group.name.toLowerCase().contains(query.toLowerCase()) ||
group.members.any(
(player) => player.name.toLowerCase().contains(query.toLowerCase()),
),
), ),
); );
} }

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/core/enums.dart'; import 'package:game_tracker/core/enums.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/tiles/title_description_list_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/title_description_list_tile.dart';
class ChooseRulesetView extends StatefulWidget { class ChooseRulesetView extends StatefulWidget {
@@ -18,6 +19,7 @@ class ChooseRulesetView extends StatefulWidget {
} }
class _ChooseRulesetViewState extends State<ChooseRulesetView> { class _ChooseRulesetViewState extends State<ChooseRulesetView> {
/// Currently selected ruleset index
late int selectedRulesetIndex; late int selectedRulesetIndex;
@override @override
@@ -28,14 +30,13 @@ class _ChooseRulesetViewState extends State<ChooseRulesetView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return DefaultTabController( return DefaultTabController(
length: 2, length: 2,
initialIndex: 0, initialIndex: 0,
child: Scaffold( child: Scaffold(
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
appBar: AppBar( appBar: AppBar(
backgroundColor: CustomTheme.backgroundColor,
scrolledUnderElevation: 0,
leading: IconButton( leading: IconButton(
icon: const Icon(Icons.arrow_back_ios), icon: const Icon(Icons.arrow_back_ios),
onPressed: () { onPressed: () {
@@ -46,13 +47,23 @@ class _ChooseRulesetViewState extends State<ChooseRulesetView> {
); );
}, },
), ),
title: const Text( title: Text(loc.choose_ruleset),
'Choose Ruleset',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
), ),
centerTitle: true, body: PopScope(
), // This fixes that the Android Back Gesture didn't return the
body: ListView.builder( // selectedRulesetIndex and therefore the selected Ruleset wasn't saved
canPop: false,
onPopInvokedWithResult: (bool didPop, Object? result) {
if (didPop) {
return;
}
Navigator.of(context).pop(
selectedRulesetIndex == -1
? null
: widget.rulesets[selectedRulesetIndex].$1,
);
},
child: ListView.builder(
padding: const EdgeInsets.only(bottom: 85), padding: const EdgeInsets.only(bottom: 85),
itemCount: widget.rulesets.length, itemCount: widget.rulesets.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
@@ -66,13 +77,17 @@ class _ChooseRulesetViewState extends State<ChooseRulesetView> {
} }
}); });
}, },
title: translateRulesetToString(widget.rulesets[index].$1), title: translateRulesetToString(
widget.rulesets[index].$1,
context,
),
description: widget.rulesets[index].$2, description: widget.rulesets[index].$2,
isHighlighted: selectedRulesetIndex == index, isHighlighted: selectedRulesetIndex == index,
); );
}, },
), ),
), ),
),
); );
} }
} }

View File

@@ -1,11 +1,12 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/adaptive_page_route.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/core/enums.dart'; import 'package:game_tracker/core/enums.dart';
import 'package:game_tracker/data/db/database.dart'; import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/data/dto/group.dart';
import 'package:game_tracker/data/dto/match.dart'; import 'package:game_tracker/data/dto/match.dart';
import 'package:game_tracker/data/dto/player.dart'; import 'package:game_tracker/data/dto/player.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/choose_game_view.dart'; import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/choose_game_view.dart';
import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/choose_group_view.dart'; import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/choose_group_view.dart';
import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/choose_ruleset_view.dart'; import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/choose_ruleset_view.dart';
@@ -25,11 +26,13 @@ class CreateMatchView extends StatefulWidget {
} }
class _CreateMatchViewState extends State<CreateMatchView> { class _CreateMatchViewState extends State<CreateMatchView> {
/// Reference to the app database
late final AppDatabase db; late final AppDatabase db;
/// Controller for the game name input field /// Controller for the match name input field
final TextEditingController _gameNameController = TextEditingController(); final TextEditingController _matchNameController = TextEditingController();
/// Hint text for the match name input field
String? hintText;
/// List of all groups from the database /// List of all groups from the database
List<Group> groupsList = []; List<Group> groupsList = [];
@@ -64,38 +67,13 @@ class _CreateMatchViewState extends State<CreateMatchView> {
/// The currently selected players /// The currently selected players
List<Player>? selectedPlayers; List<Player>? selectedPlayers;
/// List of available rulesets with their descriptions /// List of available rulesets with their localized string representations
/// as tuples of (Ruleset, String) late final List<(Ruleset, String)> _rulesets;
/// TODO: Replace when rulesets are implemented
List<(Ruleset, String)> rulesets = [
(
Ruleset.singleWinner,
'Exactly one winner is chosen; ties are resolved by a predefined tiebreaker.',
),
(
Ruleset.singleLoser,
'Exactly one loser is determined; last place receives the penalty or consequence.',
),
(
Ruleset.mostPoints,
'Traditional ruleset: the player with the most points wins.',
),
(
Ruleset.leastPoints,
'Inverse scoring: the player with the fewest points wins.',
),
];
// TODO: Replace when games are implemented
List<(String, String, Ruleset)> games = [
('Example Game 1', 'This is a discription', Ruleset.leastPoints),
('Example Game 2', '', Ruleset.singleWinner),
];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_gameNameController.addListener(() { _matchNameController.addListener(() {
setState(() {}); setState(() {});
}); });
@@ -107,42 +85,63 @@ class _CreateMatchViewState extends State<CreateMatchView> {
]).then((result) async { ]).then((result) async {
groupsList = result[0] as List<Group>; groupsList = result[0] as List<Group>;
playerList = result[1] as List<Player>; playerList = result[1] as List<Player>;
}); setState(() {
filteredPlayerList = List.from(playerList); filteredPlayerList = List.from(playerList);
});
});
} }
@override
void dispose() {
_matchNameController.dispose();
super.dispose();
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
final loc = AppLocalizations.of(context);
hintText ??= loc.match_name;
_rulesets = [
(Ruleset.singleWinner, loc.ruleset_single_winner),
(Ruleset.singleLoser, loc.ruleset_single_loser),
(Ruleset.mostPoints, loc.ruleset_most_points),
(Ruleset.leastPoints, loc.ruleset_least_points),
];
}
// TODO: Replace when games are implemented
List<(String, String, Ruleset)> games = [
('Example Game 1', 'This is a description', Ruleset.leastPoints),
('Example Game 2', '', Ruleset.singleWinner),
];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( final loc = AppLocalizations.of(context);
return ScaffoldMessenger(
child: Scaffold(
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
appBar: AppBar( appBar: AppBar(title: Text(loc.create_new_match)),
backgroundColor: CustomTheme.backgroundColor,
scrolledUnderElevation: 0,
title: const Text(
'Create new game',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
centerTitle: true,
),
body: SafeArea( body: SafeArea(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Container( Container(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 5), margin: CustomTheme.tileMargin,
child: TextInputField( child: TextInputField(
controller: _gameNameController, controller: _matchNameController,
hintText: 'Game name', hintText: hintText ?? '',
), ),
), ),
ChooseTile( ChooseTile(
title: 'Game', title: loc.game,
trailingText: selectedGameIndex == -1 trailingText: selectedGameIndex == -1
? 'None' ? loc.none
: games[selectedGameIndex].$1, : games[selectedGameIndex].$1,
onPressed: () async { onPressed: () async {
selectedGameIndex = await Navigator.of(context).push( selectedGameIndex = await Navigator.of(context).push(
MaterialPageRoute( adaptivePageRoute(
builder: (context) => ChooseGameView( builder: (context) => ChooseGameView(
games: games, games: games,
initialGameIndex: selectedGameIndex, initialGameIndex: selectedGameIndex,
@@ -151,31 +150,34 @@ class _CreateMatchViewState extends State<CreateMatchView> {
); );
setState(() { setState(() {
if (selectedGameIndex != -1) { if (selectedGameIndex != -1) {
hintText = games[selectedGameIndex].$1;
selectedRuleset = games[selectedGameIndex].$3; selectedRuleset = games[selectedGameIndex].$3;
selectedRulesetIndex = rulesets.indexWhere( selectedRulesetIndex = _rulesets.indexWhere(
(r) => r.$1 == selectedRuleset, (r) => r.$1 == selectedRuleset,
); );
} else { } else {
hintText = loc.match_name;
selectedRuleset = null; selectedRuleset = null;
} }
}); });
}, },
), ),
ChooseTile( ChooseTile(
title: 'Ruleset', title: loc.ruleset,
trailingText: selectedRuleset == null trailingText: selectedRuleset == null
? 'None' ? loc.none
: translateRulesetToString(selectedRuleset!), : translateRulesetToString(selectedRuleset!, context),
onPressed: () async { onPressed: () async {
selectedRuleset = await Navigator.of(context).push( selectedRuleset = await Navigator.of(context).push(
MaterialPageRoute( adaptivePageRoute(
builder: (context) => ChooseRulesetView( builder: (context) => ChooseRulesetView(
rulesets: rulesets, rulesets: _rulesets,
initialRulesetIndex: selectedRulesetIndex, initialRulesetIndex: selectedRulesetIndex,
), ),
), ),
); );
selectedRulesetIndex = rulesets.indexWhere( if (!mounted) return;
selectedRulesetIndex = _rulesets.indexWhere(
(r) => r.$1 == selectedRuleset, (r) => r.$1 == selectedRuleset,
); );
selectedGameIndex = -1; selectedGameIndex = -1;
@@ -183,13 +185,13 @@ class _CreateMatchViewState extends State<CreateMatchView> {
}, },
), ),
ChooseTile( ChooseTile(
title: 'Group', title: loc.group,
trailingText: selectedGroup == null trailingText: selectedGroup == null
? 'None' ? loc.none_group
: selectedGroup!.name, : selectedGroup!.name,
onPressed: () async { onPressed: () async {
selectedGroup = await Navigator.of(context).push( selectedGroup = await Navigator.of(context).push(
MaterialPageRoute( adaptivePageRoute(
builder: (context) => ChooseGroupView( builder: (context) => ChooseGroupView(
groups: groupsList, groups: groupsList,
initialGroupId: selectedGroupId, initialGroupId: selectedGroupId,
@@ -222,13 +224,15 @@ class _CreateMatchViewState extends State<CreateMatchView> {
), ),
), ),
CustomWidthButton( CustomWidthButton(
text: 'Create game', text: loc.create_match,
sizeRelativeToWidth: 0.95, sizeRelativeToWidth: 0.95,
buttonType: ButtonType.primary, buttonType: ButtonType.primary,
onPressed: _enableCreateGameButton() onPressed: _enableCreateGameButton()
? () async { ? () async {
Match match = Match( Match match = Match(
name: _gameNameController.text.trim(), name: _matchNameController.text.isEmpty
? (hintText ?? '')
: _matchNameController.text.trim(),
createdAt: DateTime.now(), createdAt: DateTime.now(),
group: selectedGroup, group: selectedGroup,
players: selectedPlayers, players: selectedPlayers,
@@ -237,9 +241,9 @@ class _CreateMatchViewState extends State<CreateMatchView> {
if (context.mounted) { if (context.mounted) {
Navigator.pushReplacement( Navigator.pushReplacement(
context, context,
CupertinoPageRoute( adaptivePageRoute(
fullscreenDialog: true, fullscreenDialog: true,
builder: (context) => GameResultView( builder: (context) => MatchResultView(
match: match, match: match,
onWinnerChanged: widget.onWinnerChanged, onWinnerChanged: widget.onWinnerChanged,
), ),
@@ -252,14 +256,17 @@ class _CreateMatchViewState extends State<CreateMatchView> {
], ],
), ),
), ),
),
); );
} }
/// Determines whether the "Create Game" button should be enabled based on /// Determines whether the "Create Match" button should be enabled.
/// the current state of the input fields. ///
/// Returns `true` if:
/// - A ruleset is selected AND
/// - Either a group is selected OR at least 2 players are selected
bool _enableCreateGameButton() { bool _enableCreateGameButton() {
return _gameNameController.text.isNotEmpty && return (selectedGroup != null ||
(selectedGroup != null ||
(selectedPlayers != null && selectedPlayers!.length > 1)) && (selectedPlayers != null && selectedPlayers!.length > 1)) &&
selectedRuleset != null; selectedRuleset != null;
} }

View File

@@ -3,22 +3,27 @@ import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/data/db/database.dart'; import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/data/dto/match.dart'; import 'package:game_tracker/data/dto/match.dart';
import 'package:game_tracker/data/dto/player.dart'; import 'package:game_tracker/data/dto/player.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/tiles/custom_radio_list_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/custom_radio_list_tile.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class GameResultView extends StatefulWidget { class MatchResultView extends StatefulWidget {
final Match match; final Match match;
final VoidCallback? onWinnerChanged; final VoidCallback? onWinnerChanged;
const GameResultView({super.key, required this.match, this.onWinnerChanged}); const MatchResultView({super.key, required this.match, this.onWinnerChanged});
@override @override
State<GameResultView> createState() => _GameResultViewState(); State<MatchResultView> createState() => _MatchResultViewState();
} }
class _GameResultViewState extends State<GameResultView> { class _MatchResultViewState extends State<MatchResultView> {
late final List<Player> allPlayers;
late final AppDatabase db; late final AppDatabase db;
/// List of all players who participated in the match
late final List<Player> allPlayers;
/// Currently selected winner player
Player? _selectedPlayer; Player? _selectedPlayer;
@override @override
@@ -35,20 +40,18 @@ class _GameResultViewState extends State<GameResultView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return Scaffold( return Scaffold(
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
appBar: AppBar( appBar: AppBar(
backgroundColor: CustomTheme.backgroundColor, leading: IconButton(
scrolledUnderElevation: 0, icon: const Icon(Icons.close),
title: Text( onPressed: () {
widget.match.name, widget.onWinnerChanged?.call();
style: const TextStyle( Navigator.of(context).pop();
fontSize: 20, },
fontWeight: FontWeight.bold,
overflow: TextOverflow.ellipsis,
), ),
), title: Text(widget.match.name),
centerTitle: true,
), ),
body: SafeArea( body: SafeArea(
child: Column( child: Column(
@@ -72,9 +75,9 @@ class _GameResultViewState extends State<GameResultView> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Text( Text(
'Select Winner:', loc.select_winner,
style: TextStyle( style: const TextStyle(
fontSize: 18, fontSize: 18,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
@@ -123,6 +126,8 @@ class _GameResultViewState extends State<GameResultView> {
); );
} }
/// Handles saving or removing the winner in the database
/// based on the current selection.
Future<void> _handleWinnerSaving() async { Future<void> _handleWinnerSaving() async {
if (_selectedPlayer == null) { if (_selectedPlayer == null) {
await db.matchDao.removeWinner(matchId: widget.match.id); await db.matchDao.removeWinner(matchId: widget.match.id);
@@ -135,12 +140,22 @@ class _GameResultViewState extends State<GameResultView> {
widget.onWinnerChanged?.call(); widget.onWinnerChanged?.call();
} }
List<Player> getAllPlayers(Match game) { /// Retrieves all players associated with the given [match].
if (game.group == null && game.players != null) { /// This includes players directly assigned to the match
return [...game.players!]; /// as well as members of the group (if any).
} else if (game.group != null && game.players != null) { /// The returned list is sorted alphabetically by player name.
return [...game.players!, ...game.group!.members]; List<Player> getAllPlayers(Match match) {
List<Player> players = [];
if (match.group == null && match.players != null) {
players = [...match.players!];
} else if (match.group != null && match.players != null) {
players = [...match.players!, ...match.group!.members];
} else {
players = [...match.group!.members];
} }
return [...game.group!.members];
players.sort((a, b) => a.name.compareTo(b.name));
return players;
} }
} }

View File

@@ -1,18 +1,19 @@
import 'dart:core' hide Match; import 'dart:core' hide Match;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/adaptive_page_route.dart';
import 'package:game_tracker/core/constants.dart'; import 'package:game_tracker/core/constants.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/data/db/database.dart'; import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/data/dto/group.dart';
import 'package:game_tracker/data/dto/match.dart'; import 'package:game_tracker/data/dto/match.dart';
import 'package:game_tracker/data/dto/player.dart'; import 'package:game_tracker/data/dto/player.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/create_match_view.dart'; import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/create_match_view.dart';
import 'package:game_tracker/presentation/views/main_menu/match_view/match_result_view.dart'; import 'package:game_tracker/presentation/views/main_menu/match_view/match_result_view.dart';
import 'package:game_tracker/presentation/widgets/app_skeleton.dart'; import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart'; import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
import 'package:game_tracker/presentation/widgets/tiles/game_history_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/match_tile.dart';
import 'package:game_tracker/presentation/widgets/top_centered_message.dart'; import 'package:game_tracker/presentation/widgets/top_centered_message.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -27,10 +28,12 @@ class _MatchViewState extends State<MatchView> {
late final AppDatabase db; late final AppDatabase db;
bool isLoading = true; bool isLoading = true;
/// Loaded matches from the database,
/// initially filled with skeleton matches
List<Match> matches = List.filled( List<Match> matches = List.filled(
4, 4,
Match( Match(
name: 'Skeleton Gamename', name: 'Skeleton match name',
group: Group( group: Group(
name: 'Group name', name: 'Group name',
members: List.filled(5, Player(name: 'Player')), members: List.filled(5, Player(name: 'Player')),
@@ -49,6 +52,7 @@ class _MatchViewState extends State<MatchView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return Scaffold( return Scaffold(
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
body: Stack( body: Stack(
@@ -58,11 +62,11 @@ class _MatchViewState extends State<MatchView> {
enabled: isLoading, enabled: isLoading,
child: Visibility( child: Visibility(
visible: matches.isNotEmpty, visible: matches.isNotEmpty,
replacement: const Center( replacement: Center(
child: TopCenteredMessage( child: TopCenteredMessage(
icon: Icons.report, icon: Icons.report,
title: 'Info', title: loc.info,
message: 'No games created yet', message: loc.no_matches_created_yet,
), ),
), ),
child: ListView.builder( child: ListView.builder(
@@ -71,16 +75,20 @@ class _MatchViewState extends State<MatchView> {
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
if (index == matches.length) { if (index == matches.length) {
return SizedBox( return SizedBox(
height: MediaQuery.paddingOf(context).bottom - 80, height: MediaQuery.paddingOf(context).bottom - 20,
); );
} }
return GameHistoryTile( return Center(
child: Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: MatchTile(
width: MediaQuery.sizeOf(context).width * 0.95,
onTap: () async { onTap: () async {
Navigator.push( Navigator.push(
context, context,
CupertinoPageRoute( adaptivePageRoute(
fullscreenDialog: true, fullscreenDialog: true,
builder: (context) => GameResultView( builder: (context) => MatchResultView(
match: matches[index], match: matches[index],
onWinnerChanged: loadGames, onWinnerChanged: loadGames,
), ),
@@ -88,6 +96,8 @@ class _MatchViewState extends State<MatchView> {
); );
}, },
match: matches[index], match: matches[index],
),
),
); );
}, },
), ),
@@ -95,29 +105,32 @@ class _MatchViewState extends State<MatchView> {
), ),
Positioned( Positioned(
bottom: MediaQuery.paddingOf(context).bottom, bottom: MediaQuery.paddingOf(context).bottom,
child: CustomWidthButton( child: SizedBox.shrink()
text: 'Create Game', /* CustomWidthButton(
text: loc.create_match,
sizeRelativeToWidth: 0.90, sizeRelativeToWidth: 0.90,
onPressed: () async { onPressed: () async {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( adaptivePageRoute(
builder: (context) => builder: (context) =>
CreateMatchView(onWinnerChanged: loadGames), CreateMatchView(onWinnerChanged: loadGames),
), ),
); );
}, },
), ),
*/
), ),
], ],
), ),
); );
} }
/// Loads the games from the database and sorts them by creation date.
void loadGames() { void loadGames() {
Future.wait([ Future.wait([
db.matchDao.getAllMatches(), db.matchDao.getAllMatches(),
Future.delayed(minimumSkeletonDuration), Future.delayed(Constants.minimumSkeletonDuration),
]).then((results) { ]).then((results) {
if (mounted) { if (mounted) {
setState(() { setState(() {

View File

@@ -1,8 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/core/enums.dart'; import 'package:game_tracker/core/enums.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/tiles/settings_list_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/settings_list_tile.dart';
import 'package:game_tracker/services/data_transfer_service.dart'; import 'package:game_tracker/services/data_transfer_service.dart';
import 'package:package_info_plus/package_info_plus.dart';
class SettingsView extends StatefulWidget { class SettingsView extends StatefulWidget {
const SettingsView({super.key}); const SettingsView({super.key});
@@ -12,47 +14,59 @@ class SettingsView extends StatefulWidget {
} }
class _SettingsViewState extends State<SettingsView> { class _SettingsViewState extends State<SettingsView> {
PackageInfo _packageInfo = PackageInfo(
appName: 'n.A.',
packageName: 'n.A.',
version: 'n.A.',
buildNumber: 'n.A.',
);
@override
void initState() {
super.initState();
_initPackageInfo();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( final loc = AppLocalizations.of(context);
return ScaffoldMessenger(
child: Scaffold(
appBar: AppBar(backgroundColor: CustomTheme.backgroundColor), appBar: AppBar(backgroundColor: CustomTheme.backgroundColor),
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
body: LayoutBuilder( body: Column(
builder: (BuildContext context, BoxConstraints constraints) =>
SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Padding( Padding(
padding: EdgeInsets.fromLTRB(24, 0, 24, 10), padding: const EdgeInsets.fromLTRB(24, 0, 24, 10),
child: Text( child: Text(
textAlign: TextAlign.start, textAlign: TextAlign.start,
'Menu', loc.menu,
style: TextStyle( style: const TextStyle(
fontSize: 28, fontSize: 28,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
), ),
const Padding( Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 10), padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
child: Text( child: Text(
textAlign: TextAlign.start, textAlign: TextAlign.start,
'Settings', loc.settings,
style: TextStyle( style: const TextStyle(
fontSize: 22, fontSize: 22,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
), ),
SettingsListTile( SettingsListTile(
title: 'Export data', title: loc.export_data,
icon: Icons.upload_outlined, icon: Icons.upload_rounded,
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16), suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
onPressed: () async { onPressed: () async {
final String json = final String json = await DataTransferService.getAppDataAsJson(
await DataTransferService.getAppDataAsJson(context); context,
);
final result = await DataTransferService.exportData( final result = await DataTransferService.exportData(
json, json,
'game_tracker-data', 'game_tracker-data',
@@ -62,35 +76,33 @@ class _SettingsViewState extends State<SettingsView> {
}, },
), ),
SettingsListTile( SettingsListTile(
title: 'Import data', title: loc.import_data,
icon: Icons.download_outlined, icon: Icons.download_rounded,
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16), suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
onPressed: () async { onPressed: () async {
final result = await DataTransferService.importData( final result = await DataTransferService.importData(context);
context,
);
if (!context.mounted) return; if (!context.mounted) return;
showImportSnackBar(context: context, result: result); showImportSnackBar(context: context, result: result);
}, },
), ),
SettingsListTile( SettingsListTile(
title: 'Delete all data', title: loc.delete_all_data,
icon: Icons.download_outlined, icon: Icons.delete_rounded,
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16), suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
onPressed: () { onPressed: () {
showDialog<bool>( showDialog<bool>(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: const Text('Delete all data?'), title: Text('${loc.delete_all_data}?'),
content: const Text('This can\'t be undone'), content: Text(loc.this_cannot_be_undone),
actions: [ actions: [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(false), onPressed: () => Navigator.of(context).pop(false),
child: const Text('Abbrechen'), child: Text(loc.cancel),
), ),
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(true), onPressed: () => Navigator.of(context).pop(true),
child: const Text('Löschen'), child: Text(loc.delete),
), ),
], ],
), ),
@@ -99,16 +111,31 @@ class _SettingsViewState extends State<SettingsView> {
DataTransferService.deleteAllData(context); DataTransferService.deleteAllData(context);
showSnackbar( showSnackbar(
context: context, context: context,
message: 'Daten erfolgreich gelöscht', message: AppLocalizations.of(
context,
).data_successfully_deleted,
); );
} }
}); });
}, },
), ),
], const Spacer(),
Padding(
padding: const EdgeInsets.all(20),
child: Center(
child: Text(
'Version ${_packageInfo.version} (${_packageInfo.buildNumber})',
style: TextStyle(
color: Colors.grey.shade600,
fontSize: 14,
fontWeight: FontWeight.w600,
), ),
), ),
), ),
),
],
),
),
); );
} }
@@ -120,25 +147,20 @@ class _SettingsViewState extends State<SettingsView> {
required BuildContext context, required BuildContext context,
required ImportResult result, required ImportResult result,
}) { }) {
final loc = AppLocalizations.of(context);
switch (result) { switch (result) {
case ImportResult.success: case ImportResult.success:
showSnackbar(context: context, message: 'Data successfully imported'); showSnackbar(context: context, message: loc.data_successfully_imported);
case ImportResult.invalidSchema: case ImportResult.invalidSchema:
showSnackbar(context: context, message: 'Invalid Schema'); showSnackbar(context: context, message: loc.invalid_schema);
case ImportResult.fileReadError: case ImportResult.fileReadError:
showSnackbar(context: context, message: 'Error reading file'); showSnackbar(context: context, message: loc.error_reading_file);
case ImportResult.canceled: case ImportResult.canceled:
showSnackbar(context: context, message: 'Import canceled'); showSnackbar(context: context, message: loc.import_canceled);
case ImportResult.formatException: case ImportResult.formatException:
showSnackbar( showSnackbar(context: context, message: loc.format_exception);
context: context,
message: 'Format Exception (see console)',
);
case ImportResult.unknownException: case ImportResult.unknownException:
showSnackbar( showSnackbar(context: context, message: loc.unknown_exception);
context: context,
message: 'Unknown Exception (see console)',
);
} }
} }
@@ -150,16 +172,14 @@ class _SettingsViewState extends State<SettingsView> {
required BuildContext context, required BuildContext context,
required ExportResult result, required ExportResult result,
}) { }) {
final loc = AppLocalizations.of(context);
switch (result) { switch (result) {
case ExportResult.success: case ExportResult.success:
showSnackbar(context: context, message: 'Data successfully exported'); showSnackbar(context: context, message: loc.data_successfully_exported);
case ExportResult.canceled: case ExportResult.canceled:
showSnackbar(context: context, message: 'Export canceled'); showSnackbar(context: context, message: loc.export_canceled);
case ExportResult.unknownException: case ExportResult.unknownException:
showSnackbar( showSnackbar(context: context, message: loc.unknown_exception);
context: context,
message: 'Unknown Exception (see console)',
);
} }
} }
@@ -175,6 +195,7 @@ class _SettingsViewState extends State<SettingsView> {
Duration duration = const Duration(seconds: 3), Duration duration = const Duration(seconds: 3),
VoidCallback? action, VoidCallback? action,
}) { }) {
final loc = AppLocalizations.of(context);
final messenger = ScaffoldMessenger.of(context); final messenger = ScaffoldMessenger.of(context);
messenger.hideCurrentSnackBar(); messenger.hideCurrentSnackBar();
messenger.showSnackBar( messenger.showSnackBar(
@@ -183,9 +204,16 @@ class _SettingsViewState extends State<SettingsView> {
backgroundColor: CustomTheme.onBoxColor, backgroundColor: CustomTheme.onBoxColor,
duration: duration, duration: duration,
action: action != null action: action != null
? SnackBarAction(label: 'Rückgängig', onPressed: action) ? SnackBarAction(label: loc.undo, onPressed: action)
: null, : null,
), ),
); );
} }
Future<void> _initPackageInfo() async {
final info = await PackageInfo.fromPlatform();
setState(() {
_packageInfo = info;
});
}
} }

View File

@@ -3,8 +3,10 @@ import 'package:game_tracker/core/constants.dart';
import 'package:game_tracker/data/db/database.dart'; import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/data/dto/match.dart'; import 'package:game_tracker/data/dto/match.dart';
import 'package:game_tracker/data/dto/player.dart'; import 'package:game_tracker/data/dto/player.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/app_skeleton.dart'; import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
import 'package:game_tracker/presentation/widgets/tiles/statistics_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/statistics_tile.dart';
import 'package:game_tracker/presentation/widgets/top_centered_message.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class StatisticsView extends StatefulWidget { class StatisticsView extends StatefulWidget {
@@ -23,28 +25,12 @@ class _StatisticsViewState extends State<StatisticsView> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
final db = Provider.of<AppDatabase>(context, listen: false); loadStatisticData();
Future.wait([
db.matchDao.getAllMatches(),
db.playerDao.getAllPlayers(),
Future.delayed(minimumSkeletonDuration),
]).then((results) async {
final matches = results[0] as List<Match>;
final players = results[1] as List<Player>;
winCounts = _calculateWinsForAllPlayers(matches, players);
matchCounts = _calculateMatchAmountsForAllPlayers(matches, players);
winRates = computeWinRatePercent(wins: winCounts, matches: matchCounts);
if (mounted) {
setState(() {
isLoading = false;
});
}
});
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return LayoutBuilder( return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {
return SingleChildScrollView( return SingleChildScrollView(
@@ -58,18 +44,25 @@ class _StatisticsViewState extends State<StatisticsView> {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
SizedBox(height: constraints.maxHeight * 0.01), SizedBox(height: constraints.maxHeight * 0.01),
Visibility(
visible:
winCounts.isEmpty &&
matchCounts.isEmpty &&
winRates.isEmpty,
replacement: Column(
children: [
StatisticsTile( StatisticsTile(
icon: Icons.sports_score, icon: Icons.sports_score,
title: 'Wins', title: loc.wins,
width: constraints.maxWidth * 0.95, width: constraints.maxWidth * 0.95,
values: winCounts, values: winCounts,
itemCount: 3, itemCount: 3,
barColor: Colors.blue, barColor: Colors.green,
), ),
SizedBox(height: constraints.maxHeight * 0.02), SizedBox(height: constraints.maxHeight * 0.02),
StatisticsTile( StatisticsTile(
icon: Icons.percent, icon: Icons.percent,
title: 'Winrate', title: loc.winrate,
width: constraints.maxWidth * 0.95, width: constraints.maxWidth * 0.95,
values: winRates, values: winRates,
itemCount: 5, itemCount: 5,
@@ -78,11 +71,21 @@ class _StatisticsViewState extends State<StatisticsView> {
SizedBox(height: constraints.maxHeight * 0.02), SizedBox(height: constraints.maxHeight * 0.02),
StatisticsTile( StatisticsTile(
icon: Icons.casino, icon: Icons.casino,
title: 'Amount of Matches', title: loc.amount_of_matches,
width: constraints.maxWidth * 0.95, width: constraints.maxWidth * 0.95,
values: matchCounts, values: matchCounts,
itemCount: 10, itemCount: 10,
barColor: Colors.green, barColor: Colors.blue,
),
],
),
child: TopCenteredMessage(
icon: Icons.info,
title: loc.info,
message: AppLocalizations.of(
context,
).no_statistics_available,
),
), ),
SizedBox(height: MediaQuery.paddingOf(context).bottom), SizedBox(height: MediaQuery.paddingOf(context).bottom),
], ],
@@ -94,13 +97,45 @@ class _StatisticsViewState extends State<StatisticsView> {
); );
} }
/// Loads matches and players from the database
/// and calculates statistics for each player
void loadStatisticData() {
final db = Provider.of<AppDatabase>(context, listen: false);
Future.wait([
db.matchDao.getAllMatches(),
db.playerDao.getAllPlayers(),
Future.delayed(Constants.minimumSkeletonDuration),
]).then((results) async {
if (!mounted) return;
final matches = results[0] as List<Match>;
final players = results[1] as List<Player>;
winCounts = _calculateWinsForAllPlayers(
matches: matches,
players: players,
context: context,
);
matchCounts = _calculateMatchAmountsForAllPlayers(
matches: matches,
players: players,
context: context,
);
winRates = computeWinRatePercent(wins: winCounts, matches: matchCounts);
setState(() {
isLoading = false;
});
});
}
/// Calculates the number of wins for each player /// Calculates the number of wins for each player
/// and returns a sorted list of tuples (playerName, winCount) /// and returns a sorted list of tuples (playerName, winCount)
List<(String, int)> _calculateWinsForAllPlayers( List<(String, int)> _calculateWinsForAllPlayers({
List<Match> matches, required List<Match> matches,
List<Player> players, required List<Player> players,
) { required BuildContext context,
}) {
List<(String, int)> winCounts = []; List<(String, int)> winCounts = [];
final loc = AppLocalizations.of(context);
// Getting the winners // Getting the winners
for (var match in matches) { for (var match in matches) {
@@ -131,7 +166,7 @@ class _StatisticsViewState extends State<StatisticsView> {
final playerId = winCounts[i].$1; final playerId = winCounts[i].$1;
final player = players.firstWhere( final player = players.firstWhere(
(p) => p.id == playerId, (p) => p.id == playerId,
orElse: () => Player(id: playerId, name: 'N.a.'), orElse: () => Player(id: playerId, name: loc.not_available),
); );
winCounts[i] = (player.name, winCounts[i].$2); winCounts[i] = (player.name, winCounts[i].$2);
} }
@@ -143,11 +178,13 @@ class _StatisticsViewState extends State<StatisticsView> {
/// Calculates the number of matches played for each player /// Calculates the number of matches played for each player
/// and returns a sorted list of tuples (playerName, matchCount) /// and returns a sorted list of tuples (playerName, matchCount)
List<(String, int)> _calculateMatchAmountsForAllPlayers( List<(String, int)> _calculateMatchAmountsForAllPlayers({
List<Match> matches, required List<Match> matches,
List<Player> players, required List<Player> players,
) { required BuildContext context,
}) {
List<(String, int)> matchCounts = []; List<(String, int)> matchCounts = [];
final loc = AppLocalizations.of(context);
// Counting matches for each player // Counting matches for each player
for (var match in matches) { for (var match in matches) {
@@ -193,7 +230,7 @@ class _StatisticsViewState extends State<StatisticsView> {
final playerId = matchCounts[i].$1; final playerId = matchCounts[i].$1;
final player = players.firstWhere( final player = players.firstWhere(
(p) => p.id == playerId, (p) => p.id == playerId,
orElse: () => Player(id: playerId, name: 'N.a.'), orElse: () => Player(id: playerId, name: loc.not_available),
); );
matchCounts[i] = (player.name, matchCounts[i].$2); matchCounts[i] = (player.name, matchCounts[i].$2);
} }

View File

@@ -1,11 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:skeletonizer/skeletonizer.dart'; import 'package:skeletonizer/skeletonizer.dart';
/// A widget that provides a skeleton loading effect to its child widget tree.
/// - [child]: The widget tree to apply the skeleton effect to.
/// - [enabled]: A boolean to enable or disable the skeleton effect.
/// - [fixLayoutBuilder]: A boolean to fix the layout builder for AnimatedSwitcher.
class AppSkeleton extends StatefulWidget { class AppSkeleton extends StatefulWidget {
final Widget child;
final bool enabled;
final bool fixLayoutBuilder;
const AppSkeleton({ const AppSkeleton({
super.key, super.key,
required this.child, required this.child,
@@ -13,6 +13,15 @@ class AppSkeleton extends StatefulWidget {
this.fixLayoutBuilder = false, this.fixLayoutBuilder = false,
}); });
/// The widget tree to apply the skeleton effect to.
final Widget child;
/// A boolean to enable or disable the skeleton effect.
final bool enabled;
/// A boolean to fix the layout builder for AnimatedSwitcher.
final bool fixLayoutBuilder;
@override @override
State<AppSkeleton> createState() => _AppSkeletonState(); State<AppSkeleton> createState() => _AppSkeletonState();
} }

View File

@@ -2,6 +2,12 @@ import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/core/enums.dart'; import 'package:game_tracker/core/enums.dart';
/// A custom button widget that is designed to have a width relative to the screen size.
/// It supports three types of buttons: primary, secondary, and text buttons.
/// - [text]: The text to display on the button.
/// - [buttonType]: The type of button to display. Defaults to [ButtonType.primary].
/// - [sizeRelativeToWidth]: The size of the button relative to the width of the screen.
/// - [onPressed]: The callback to be invoked when the button is pressed.
class CustomWidthButton extends StatelessWidget { class CustomWidthButton extends StatelessWidget {
const CustomWidthButton({ const CustomWidthButton({
super.key, super.key,
@@ -11,9 +17,16 @@ class CustomWidthButton extends StatelessWidget {
this.onPressed, this.onPressed,
}); });
/// The text to display on the button.
final String text; final String text;
/// The size of the button relative to the width of the screen.
final double sizeRelativeToWidth; final double sizeRelativeToWidth;
/// The callback to be invoked when the button is pressed.
final VoidCallback? onPressed; final VoidCallback? onPressed;
/// The type of button to display. Depends on the enum [ButtonType].
final ButtonType buttonType; final ButtonType buttonType;
@override @override
@@ -47,7 +60,7 @@ class CustomWidthButton extends StatelessWidget {
60, 60,
), ),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12), borderRadius: CustomTheme.standardBorderRadiusAll,
), ),
), ),
child: Text( child: Text(
@@ -78,7 +91,7 @@ class CustomWidthButton extends StatelessWidget {
), ),
side: BorderSide(color: borderSideColor, width: 2), side: BorderSide(color: borderSideColor, width: 2),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12), borderRadius: CustomTheme.standardBorderRadiusAll,
), ),
), ),
child: Text( child: Text(

View File

@@ -1,15 +1,22 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
/// A button widget designed for quick creating matches in the [HomeView]
/// - [text]: The text to display on the button.
/// - [onPressed]: The callback to be invoked when the button is pressed.
class QuickCreateButton extends StatefulWidget { class QuickCreateButton extends StatefulWidget {
final String text;
final VoidCallback? onPressed;
const QuickCreateButton({ const QuickCreateButton({
super.key, super.key,
required this.text, required this.text,
required this.onPressed, required this.onPressed,
}); });
/// The text to display on the button.
final String text;
/// The callback to be invoked when the button is pressed.
final VoidCallback? onPressed;
@override @override
State<QuickCreateButton> createState() => _QuickCreateButtonState(); State<QuickCreateButton> createState() => _QuickCreateButtonState();
} }
@@ -22,7 +29,9 @@ class _QuickCreateButtonState extends State<QuickCreateButton> {
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
minimumSize: const Size(140, 45), minimumSize: const Size(140, 45),
backgroundColor: CustomTheme.primaryColor, backgroundColor: CustomTheme.primaryColor,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), shape: RoundedRectangleBorder(
borderRadius: CustomTheme.standardBorderRadiusAll,
),
), ),
child: Text( child: Text(
widget.text, widget.text,

View File

@@ -1,12 +1,13 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart';
/// A navigation bar item widget that represents a single tab in a navigation bar.
/// - [index]: The index of the tab.
/// - [isSelected]: A boolean indicating whether the tab is currently selected.
/// - [icon]: The icon to display for the tab.
/// - [label]: The label to display for the tab.
/// - [onTabTapped]: The callback to be invoked when the tab is tapped.
class NavbarItem extends StatefulWidget { class NavbarItem extends StatefulWidget {
final int index;
final bool isSelected;
final IconData icon;
final String label;
final Function(int) onTabTapped;
const NavbarItem({ const NavbarItem({
super.key, super.key,
required this.index, required this.index,
@@ -16,11 +17,64 @@ class NavbarItem extends StatefulWidget {
required this.onTabTapped, required this.onTabTapped,
}); });
/// The index of the tab.
final int index;
/// A boolean indicating whether the tab is currently selected.
final bool isSelected;
/// The icon to display for the tab.
final IconData icon;
/// The label to display for the tab.
final String label;
/// The callback to be invoked when the tab is tapped.
final Function(int) onTabTapped;
@override @override
State<NavbarItem> createState() => _NavbarItemState(); State<NavbarItem> createState() => _NavbarItemState();
} }
class _NavbarItemState extends State<NavbarItem> { class _NavbarItemState extends State<NavbarItem>
with SingleTickerProviderStateMixin {
/// Animation controller for the scale animation
late AnimationController _animationController;
/// Scale animation for the icon when selected
late Animation<double> _scaleAnimation;
@override
void initState() {
super.initState();
_animationController = AnimationController(
duration: const Duration(milliseconds: 300),
vsync: this,
);
_scaleAnimation = Tween<double>(begin: 1.0, end: 1.2).animate(
CurvedAnimation(
parent: _animationController,
curve: Curves.easeInOutBack,
),
);
if (widget.isSelected) {
_animationController.forward();
}
}
// Retrigger animation on selection change
@override
void didUpdateWidget(NavbarItem oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.isSelected && !oldWidget.isSelected) {
_animationController.forward();
} else if (!widget.isSelected && oldWidget.isSelected) {
_animationController.reverse();
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Expanded( return Expanded(
@@ -33,19 +87,29 @@ class _NavbarItemState extends State<NavbarItem> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Icon( ScaleTransition(
scale: widget.isSelected
? _scaleAnimation
: const AlwaysStoppedAnimation(1.0),
child: Icon(
widget.icon, widget.icon,
color: widget.isSelected ? Colors.white : Colors.black, color: widget.isSelected
? CustomTheme.navBarItemSelectedColor
: CustomTheme.navBarItemUnselectedColor,
size: 26,
),
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
Text( Text(
widget.label, widget.label,
style: TextStyle( style: TextStyle(
color: widget.isSelected ? Colors.white : Colors.black, color: widget.isSelected
fontSize: 12, ? CustomTheme.navBarItemSelectedColor
: CustomTheme.navBarItemUnselectedColor,
fontSize: widget.isSelected ? 12 : 11,
fontWeight: widget.isSelected fontWeight: widget.isSelected
? FontWeight.bold ? FontWeight.bold
: FontWeight.normal, : FontWeight.w500,
), ),
), ),
], ],
@@ -54,4 +118,10 @@ class _NavbarItemState extends State<NavbarItem> {
), ),
); );
} }
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
} }

View File

@@ -3,6 +3,7 @@ import 'package:game_tracker/core/constants.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/data/db/database.dart'; import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/data/dto/player.dart'; import 'package:game_tracker/data/dto/player.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/app_skeleton.dart'; import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
import 'package:game_tracker/presentation/widgets/text_input/custom_search_bar.dart'; import 'package:game_tracker/presentation/widgets/text_input/custom_search_bar.dart';
import 'package:game_tracker/presentation/widgets/tiles/text_icon_list_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/text_icon_list_tile.dart';
@@ -10,31 +11,55 @@ import 'package:game_tracker/presentation/widgets/tiles/text_icon_tile.dart';
import 'package:game_tracker/presentation/widgets/top_centered_message.dart'; import 'package:game_tracker/presentation/widgets/top_centered_message.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
/// A widget that allows users to select players from a list,
/// with search functionality and the ability to add new players.
/// - [availablePlayers]: An optional list of players to choose from. If null, all
/// players from the database are used.
/// - [initialSelectedPlayers]: An optional list of players that should be pre-selected.
/// - [onChanged]: A callback function that is invoked whenever the selection changes,
/// providing the updated list of selected players.
class PlayerSelection extends StatefulWidget { class PlayerSelection extends StatefulWidget {
final Function(List<Player> value) onChanged;
final List<Player> availablePlayers;
final List<Player>? initialSelectedPlayers;
const PlayerSelection({ const PlayerSelection({
super.key, super.key,
required this.onChanged, this.availablePlayers,
this.availablePlayers = const [],
this.initialSelectedPlayers, this.initialSelectedPlayers,
required this.onChanged,
}); });
/// An optional list of players to choose from. If null, all players from the database are used.
final List<Player>? availablePlayers;
/// An optional list of players that should be pre-selected.
final List<Player>? initialSelectedPlayers;
/// A callback function that is invoked whenever the selection changes,
final Function(List<Player> value) onChanged;
@override @override
State<PlayerSelection> createState() => _PlayerSelectionState(); State<PlayerSelection> createState() => _PlayerSelectionState();
} }
class _PlayerSelectionState extends State<PlayerSelection> { class _PlayerSelectionState extends State<PlayerSelection> {
List<Player> selectedPlayers = []; late final AppDatabase db;
List<Player> suggestedPlayers = [];
List<Player> allPlayers = [];
bool isLoading = true; bool isLoading = true;
/// Future that loads all players from the database.
late Future<List<Player>> _allPlayersFuture;
/// The complete list of all available players.
List<Player> allPlayers = [];
/// The list of players suggested based on the search input.
List<Player> suggestedPlayers = [];
/// The list of currently selected players.
List<Player> selectedPlayers = [];
/// Controller for the search bar input.
late final TextEditingController _searchBarController = late final TextEditingController _searchBarController =
TextEditingController(); TextEditingController();
late final AppDatabase db;
late Future<List<Player>> _allPlayersFuture; /// Skeleton data used while loading players.
late final List<Player> skeletonData = List.filled( late final List<Player> skeletonData = List.filled(
7, 7,
Player(name: 'Player 0'), Player(name: 'Player 0'),
@@ -48,46 +73,11 @@ class _PlayerSelectionState extends State<PlayerSelection> {
loadPlayerList(); loadPlayerList();
} }
void loadPlayerList() {
_allPlayersFuture = Future.wait([
db.playerDao.getAllPlayers(),
Future.delayed(minimumSkeletonDuration),
]).then((results) => results[0] as List<Player>);
if (mounted) {
_allPlayersFuture.then((loadedPlayers) {
setState(() {
// If a list of available players is provided, use that list.
if (widget.availablePlayers.isNotEmpty) {
widget.availablePlayers.sort((a, b) => a.name.compareTo(b.name));
allPlayers = [...widget.availablePlayers];
suggestedPlayers = [...allPlayers];
if (widget.initialSelectedPlayers != null) {
// Ensures that only players available for selection are pre-selected.
selectedPlayers = widget.initialSelectedPlayers!
.where(
(p) => widget.availablePlayers.any(
(available) => available.id == p.id,
),
)
.toList();
}
} else {
// Otherwise, use the loaded players from the database.
loadedPlayers.sort((a, b) => a.name.compareTo(b.name));
allPlayers = [...loadedPlayers];
suggestedPlayers = [...loadedPlayers];
}
isLoading = false;
});
});
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return Container( return Container(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), margin: CustomTheme.standardMargin,
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
decoration: CustomTheme.standardBoxDecoration, decoration: CustomTheme.standardBoxDecoration,
child: Column( child: Column(
@@ -96,7 +86,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
CustomSearchBar( CustomSearchBar(
controller: _searchBarController, controller: _searchBarController,
constraints: const BoxConstraints(maxHeight: 45, minHeight: 45), constraints: const BoxConstraints(maxHeight: 45, minHeight: 45),
hintText: 'Search for players', hintText: loc.search_for_players,
trailingButtonShown: true, trailingButtonShown: true,
trailingButtonicon: Icons.add_circle, trailingButtonicon: Icons.add_circle,
trailingButtonEnabled: _searchBarController.text.trim().isNotEmpty, trailingButtonEnabled: _searchBarController.text.trim().isNotEmpty,
@@ -129,47 +119,59 @@ class _PlayerSelectionState extends State<PlayerSelection> {
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
Text( Text(
'Selected players: (${selectedPlayers.length})', loc.selected_players,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
Wrap( SizedBox(
alignment: WrapAlignment.start, height: 50,
crossAxisAlignment: WrapCrossAlignment.start, child: selectedPlayers.isEmpty
spacing: 8.0, ? Center(child: Text(loc.no_players_selected))
runSpacing: 8.0, : SingleChildScrollView(
children: <Widget>[ scrollDirection: Axis.horizontal,
// Generates a TextIconTile for each selected player. child: Row(
children: [
for (var player in selectedPlayers) for (var player in selectedPlayers)
TextIconTile( Padding(
padding: const EdgeInsets.only(right: 8.0),
child: TextIconTile(
text: player.name, text: player.name,
onIconTap: () { onIconTap: () {
setState(() { setState(() {
// Removes the player from the selection and notifies the parent. // Removes the player from the selection and notifies the parent.
final currentSearch = _searchBarController.text
.toLowerCase();
selectedPlayers.remove(player); selectedPlayers.remove(player);
widget.onChanged([...selectedPlayers]); widget.onChanged([...selectedPlayers]);
// Get the current search query
final currentSearch = _searchBarController
.text
.toLowerCase();
// If the player matches the current search query (or search is empty), // If the player matches the current search query (or search is empty),
// they are added back to the suggestions and the list is re-sorted. // they are added back to the `suggestedPlayers` and the list is re-sorted.
if (currentSearch.isEmpty || if (currentSearch.isEmpty ||
player.name.toLowerCase().contains(currentSearch)) { player.name.toLowerCase().contains(
currentSearch,
)) {
suggestedPlayers.add(player); suggestedPlayers.add(player);
suggestedPlayers.sort(
(a, b) => a.name.compareTo(b.name),
);
} }
}); });
}, },
), ),
),
], ],
), ),
const SizedBox(height: 10), ),
const Text( ),
'All players:', const SizedBox(height: 10),
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), Text(
loc.all_players,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
/*
*/
Expanded( Expanded(
child: AppSkeleton( child: AppSkeleton(
enabled: isLoading, enabled: isLoading,
@@ -177,12 +179,8 @@ class _PlayerSelectionState extends State<PlayerSelection> {
visible: suggestedPlayers.isNotEmpty, visible: suggestedPlayers.isNotEmpty,
replacement: TopCenteredMessage( replacement: TopCenteredMessage(
icon: Icons.info, icon: Icons.info,
title: 'Info', title: loc.info,
message: allPlayers.isEmpty message: _getInfoText(context),
? 'No players created yet'
: (selectedPlayers.length == allPlayers.length)
? 'No more players to add'
: 'No players found with that name',
), ),
child: ListView.builder( child: ListView.builder(
itemCount: suggestedPlayers.length, itemCount: suggestedPlayers.length,
@@ -191,11 +189,15 @@ class _PlayerSelectionState extends State<PlayerSelection> {
text: suggestedPlayers[index].name, text: suggestedPlayers[index].name,
onPressed: () { onPressed: () {
setState(() { setState(() {
// If the player is not already selected
if (!selectedPlayers.contains( if (!selectedPlayers.contains(
suggestedPlayers[index], suggestedPlayers[index],
)) { )) {
selectedPlayers.add(suggestedPlayers[index]); // Add to player to the front of the selectedPlayers
selectedPlayers.insert(0, suggestedPlayers[index]);
// Notify the parent widget of the change
widget.onChanged([...selectedPlayers]); widget.onChanged([...selectedPlayers]);
// Remove the player from the suggestedPlayers
suggestedPlayers.remove(suggestedPlayers[index]); suggestedPlayers.remove(suggestedPlayers[index]);
} }
}); });
@@ -211,47 +213,112 @@ class _PlayerSelectionState extends State<PlayerSelection> {
); );
} }
/// Loads the list of players from the database or uses the provided available players.
/// Sets the loading state and updates the player lists accordingly.
void loadPlayerList() {
_allPlayersFuture = Future.wait([
db.playerDao.getAllPlayers(),
Future.delayed(Constants.minimumSkeletonDuration),
]).then((results) => results[0] as List<Player>);
if (mounted) {
_allPlayersFuture.then((loadedPlayers) {
setState(() {
// If a list of available players is provided (even if empty), use that list.
if (widget.availablePlayers != null) {
widget.availablePlayers!.sort((a, b) => a.name.compareTo(b.name));
allPlayers = [...widget.availablePlayers!];
suggestedPlayers = [...allPlayers];
if (widget.initialSelectedPlayers != null) {
// Ensures that only players available for selection are pre-selected.
selectedPlayers = widget.initialSelectedPlayers!
.where(
(p) => widget.availablePlayers!.any(
(available) => available.id == p.id,
),
)
.toList();
}
} else {
// Otherwise, use the loaded players from the database.
loadedPlayers.sort((a, b) => a.name.compareTo(b.name));
allPlayers = [...loadedPlayers];
suggestedPlayers = [...loadedPlayers];
}
isLoading = false;
});
});
}
}
/// Adds a new player to the database from the search bar input. /// Adds a new player to the database from the search bar input.
/// Shows a snackbar indicating success or failure. /// Shows a snackbar indicating success or failure.
/// [context] - BuildContext to show the snackbar. /// [context] - BuildContext to show the snackbar.
void addNewPlayerFromSearch({required BuildContext context}) async { Future<void> addNewPlayerFromSearch({required BuildContext context}) async {
String playerName = _searchBarController.text.trim(); final loc = AppLocalizations.of(context);
Player createdPlayer = Player(name: playerName); final playerName = _searchBarController.text.trim();
bool success = await db.playerDao.addPlayer(player: createdPlayer);
final createdPlayer = Player(name: playerName);
final success = await db.playerDao.addPlayer(player: createdPlayer);
if (!context.mounted) return; if (!context.mounted) return;
if (success) { if (success) {
selectedPlayers.add(createdPlayer); _handleSuccessfulPlayerCreation(createdPlayer);
showSnackBarMessage(loc.successfully_added_player(playerName));
} else {
showSnackBarMessage(loc.could_not_add_player(playerName));
}
}
/// Updates the state after successfully adding a new player.
void _handleSuccessfulPlayerCreation(Player player) {
selectedPlayers.insert(0, player);
widget.onChanged([...selectedPlayers]); widget.onChanged([...selectedPlayers]);
allPlayers.add(createdPlayer); allPlayers.add(player);
setState(() { setState(() {
_searchBarController.clear(); _searchBarController.clear();
suggestedPlayers = allPlayers.where((player) { _updateSuggestedPlayers();
return !selectedPlayers.contains(player);
}).toList();
}); });
}
/// Updates the suggested players list based on current selection.
void _updateSuggestedPlayers() {
suggestedPlayers = allPlayers
.where((player) => !selectedPlayers.contains(player))
.toList();
}
/// Displays a snackbar message at the bottom of the screen.
/// [message] - The message to display in the snackbar.
void showSnackBarMessage(String message) {
if (!context.mounted) return;
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
backgroundColor: CustomTheme.boxColor, backgroundColor: CustomTheme.boxColor,
content: Center( content: Center(
child: Text( child: Text(message, style: const TextStyle(color: Colors.white)),
'Successfully added player $playerName.',
style: const TextStyle(color: Colors.white),
),
), ),
), ),
); );
}
/// Determines the appropriate info text to display when no players
/// are available in the suggested players list.
String _getInfoText(BuildContext context) {
final loc = AppLocalizations.of(context);
if (allPlayers.isEmpty) {
// No players exist in the database
return loc.no_players_created_yet;
} else if (selectedPlayers.length == allPlayers.length ||
widget.availablePlayers?.isEmpty == true) {
// All players have been selected or
// available players list is provided but empty
return loc.all_players_selected;
} else { } else {
ScaffoldMessenger.of(context).showSnackBar( // No players match the search query
SnackBar( return loc.no_players_found_with_that_name;
backgroundColor: CustomTheme.boxColor,
content: Center(
child: Text(
'Could not add player $playerName.',
style: const TextStyle(color: Colors.white),
),
),
),
);
} }
} }
} }

View File

@@ -1,16 +1,16 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
/// A custom search bar widget that encapsulates a [SearchBar] with additional customization options.
/// - [controller]: The controller for the search bar's text input.
/// - [hintText]: The hint text displayed in the search bar when it is empty.
/// - [trailingButtonShown]: Whether to show the trailing button.
/// - [trailingButtonicon]: The icon for the trailing button.
/// - [trailingButtonEnabled]: Whether the trailing button is in enabled state.
/// - [onTrailingButtonPressed]: The callback invoked when the trailing button is pressed.
/// - [onChanged]: The callback invoked when the text in the search bar changes.
/// - [constraints]: The constraints for the search bar.
class CustomSearchBar extends StatelessWidget { class CustomSearchBar extends StatelessWidget {
final TextEditingController controller;
final String hintText;
final ValueChanged<String>? onChanged;
final BoxConstraints? constraints;
final bool trailingButtonShown;
final bool trailingButtonEnabled;
final VoidCallback? onTrailingButtonPressed;
final IconData trailingButtonicon;
const CustomSearchBar({ const CustomSearchBar({
super.key, super.key,
required this.controller, required this.controller,
@@ -23,6 +23,30 @@ class CustomSearchBar extends StatelessWidget {
this.constraints, this.constraints,
}); });
/// The controller for the search bar's text input.
final TextEditingController controller;
/// The hint text displayed in the search bar when it is empty.
final String hintText;
/// Whether to show the trailing button.
final bool trailingButtonShown;
/// The icon for the trailing button.
final IconData trailingButtonicon;
/// Whether the trailing button is in enabled state.
final bool trailingButtonEnabled;
/// The callback invoked when the trailing button is pressed.
final VoidCallback? onTrailingButtonPressed;
/// The callback invoked when the text in the search bar changes.
final ValueChanged<String>? onChanged;
/// The constraints for the search bar.
final BoxConstraints? constraints;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SearchBar( return SearchBar(

View File

@@ -1,11 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
/// A custom text input field widget that encapsulates a [TextField] with specific styling.
/// - [controller]: The controller for the text input field.
/// - [onChanged]: The callback invoked when the text in the field changes.
/// - [hintText]: The hint text displayed in the text input field when it is empty
class TextInputField extends StatelessWidget { class TextInputField extends StatelessWidget {
final TextEditingController controller;
final ValueChanged<String>? onChanged;
final String hintText;
const TextInputField({ const TextInputField({
super.key, super.key,
required this.controller, required this.controller,
@@ -13,6 +13,15 @@ class TextInputField extends StatelessWidget {
this.onChanged, this.onChanged,
}); });
/// The controller for the text input field.
final TextEditingController controller;
/// The callback invoked when the text in the field changes.
final ValueChanged<String>? onChanged;
/// The hint text displayed in the text input field when it is empty.
final String hintText;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return TextField( return TextField(

View File

@@ -1,10 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
/// A tile widget that allows users to choose an option by tapping on it.
/// - [title]: The title text displayed on the tile.
/// - [trailingText]: Optional trailing text displayed on the tile.
/// - [onPressed]: The callback invoked when the tile is tapped.
class ChooseTile extends StatefulWidget { class ChooseTile extends StatefulWidget {
final String title;
final VoidCallback? onPressed;
final String? trailingText;
const ChooseTile({ const ChooseTile({
super.key, super.key,
required this.title, required this.title,
@@ -12,6 +13,15 @@ class ChooseTile extends StatefulWidget {
this.onPressed, this.onPressed,
}); });
/// The title text displayed on the tile.
final String title;
/// The callback invoked when the tile is tapped.
final VoidCallback? onPressed;
/// Optional trailing text displayed on the tile.
final String? trailingText;
@override @override
State<ChooseTile> createState() => _ChooseTileState(); State<ChooseTile> createState() => _ChooseTileState();
} }
@@ -22,8 +32,8 @@ class _ChooseTileState extends State<ChooseTile> {
return GestureDetector( return GestureDetector(
onTap: widget.onPressed, onTap: widget.onPressed,
child: Container( child: Container(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 5), margin: CustomTheme.tileMargin,
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: CustomTheme.standardBoxDecoration, decoration: CustomTheme.standardBoxDecoration,
child: Row( child: Row(
children: [ children: [

View File

@@ -1,11 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
/// A custom radio list tile widget that encapsulates a [Radio] button with additional styling and functionality.
/// - [text]: The text to display next to the radio button.
/// - [value]: The value associated with the radio button.
/// - [onContainerTap]: The callback invoked when the container is tapped.
class CustomRadioListTile<T> extends StatelessWidget { class CustomRadioListTile<T> extends StatelessWidget {
final String text;
final T value;
final ValueChanged<T> onContainerTap;
const CustomRadioListTile({ const CustomRadioListTile({
super.key, super.key,
required this.text, required this.text,
@@ -13,6 +13,15 @@ class CustomRadioListTile<T> extends StatelessWidget {
required this.onContainerTap, required this.onContainerTap,
}); });
/// The text to display next to the radio button.
final String text;
/// The value associated with the radio button.
final T value;
/// The callback invoked when the container is tapped.
final ValueChanged<T> onContainerTap;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
@@ -23,7 +32,7 @@ class CustomRadioListTile<T> extends StatelessWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
color: CustomTheme.boxColor, color: CustomTheme.boxColor,
border: Border.all(color: CustomTheme.boxBorder), border: Border.all(color: CustomTheme.boxBorder),
borderRadius: BorderRadius.circular(12), borderRadius: CustomTheme.standardBorderRadiusAll,
), ),
child: Row( child: Row(
children: [ children: [

View File

@@ -1,180 +0,0 @@
import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/data/dto/match.dart';
import 'package:game_tracker/presentation/widgets/tiles/text_icon_tile.dart';
import 'package:intl/intl.dart';
class GameHistoryTile extends StatefulWidget {
final Match match;
final VoidCallback onTap;
const GameHistoryTile({super.key, required this.match, required this.onTap});
@override
State<GameHistoryTile> createState() => _GameHistoryTileState();
}
class _GameHistoryTileState extends State<GameHistoryTile> {
@override
Widget build(BuildContext context) {
final group = widget.match.group;
final winner = widget.match.winner;
final allPlayers = _getAllPlayers();
return GestureDetector(
onTap: widget.onTap,
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
padding: const EdgeInsets.all(16),
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: [
Expanded(
child: Text(
widget.match.name,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
overflow: TextOverflow.ellipsis,
),
),
Text(
_formatDate(widget.match.createdAt),
style: const TextStyle(fontSize: 12, color: Colors.grey),
),
],
),
const SizedBox(height: 8),
if (group != null) ...[
Row(
children: [
const Icon(Icons.group, size: 16, color: Colors.grey),
const SizedBox(width: 6),
Expanded(
child: Text(
group.name,
style: const TextStyle(fontSize: 14, color: Colors.grey),
overflow: TextOverflow.ellipsis,
),
),
],
),
const SizedBox(height: 12),
],
if (winner != null) ...[
Container(
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 12,
),
decoration: BoxDecoration(
color: Colors.green.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Colors.green.withValues(alpha: 0.3),
width: 1,
),
),
child: Row(
children: [
const Icon(
Icons.emoji_events,
size: 20,
color: Colors.amber,
),
const SizedBox(width: 8),
Expanded(
child: Text(
'Winner: ${winner.name}',
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Colors.white,
),
overflow: TextOverflow.ellipsis,
),
),
],
),
),
const SizedBox(height: 12),
],
if (allPlayers.isNotEmpty) ...[
const Text(
'Players',
style: TextStyle(
fontSize: 13,
color: Colors.grey,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 6),
Wrap(
spacing: 6,
runSpacing: 6,
children: allPlayers.map((player) {
return TextIconTile(text: player.name, iconEnabled: false);
}).toList(),
),
],
],
),
),
);
}
String _formatDate(DateTime dateTime) {
final now = DateTime.now();
final difference = now.difference(dateTime);
if (difference.inDays == 0) {
return 'Today at ${DateFormat('HH:mm').format(dateTime)}';
} else if (difference.inDays == 1) {
return 'Yesterday at ${DateFormat('HH:mm').format(dateTime)}';
} else if (difference.inDays < 7) {
return '${difference.inDays} days ago';
} else {
return DateFormat('MMM d, yyyy').format(dateTime);
}
}
List<dynamic> _getAllPlayers() {
final allPlayers = <dynamic>[];
final playerIds = <String>{};
// Add players from game.players
if (widget.match.players != null) {
for (var player in widget.match.players!) {
if (!playerIds.contains(player.id)) {
allPlayers.add(player);
playerIds.add(player.id);
}
}
}
// Add players from game.group.players
if (widget.match.group?.members != null) {
for (var player in widget.match.group!.members) {
if (!playerIds.contains(player.id)) {
allPlayers.add(player);
playerIds.add(player.id);
}
}
}
return allPlayers;
}
}

View File

@@ -3,16 +3,22 @@ import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/data/dto/group.dart';
import 'package:game_tracker/presentation/widgets/tiles/text_icon_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/text_icon_tile.dart';
/// A tile widget that displays information about a group, including its name and members.
/// - [group]: The group data to be displayed.
/// - [isHighlighted]: Whether the tile should be highlighted.
class GroupTile extends StatelessWidget { class GroupTile extends StatelessWidget {
const GroupTile({super.key, required this.group, this.isHighlighted = false}); const GroupTile({super.key, required this.group, this.isHighlighted = false});
/// The group data to be displayed.
final Group group; final Group group;
/// Whether the tile should be highlighted.
final bool isHighlighted; final bool isHighlighted;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AnimatedContainer( return AnimatedContainer(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), margin: CustomTheme.standardMargin,
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10), padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
decoration: isHighlighted decoration: isHighlighted
? CustomTheme.highlightedBoxDecoration ? CustomTheme.highlightedBoxDecoration
@@ -56,7 +62,9 @@ class GroupTile extends StatelessWidget {
spacing: 12.0, spacing: 12.0,
runSpacing: 8.0, runSpacing: 8.0,
children: <Widget>[ children: <Widget>[
for (var member in group.members) for (var member in [
...group.members,
]..sort((a, b) => a.name.compareTo(b.name)))
TextIconTile(text: member.name, iconEnabled: false), TextIconTile(text: member.name, iconEnabled: false),
], ],
), ),

View File

@@ -1,13 +1,14 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
/// A tile widget that displays a title with an icon and some content below it.
/// - [title]: The title text displayed on the tile.
/// - [icon]: The icon displayed next to the title.
/// - [content]: The content widget displayed below the title.
/// - [padding]: Optional padding for the tile content.
/// - [height]: Optional height for the tile.
/// - [width]: Optional width for the tile.
class InfoTile extends StatefulWidget { class InfoTile extends StatefulWidget {
final String title;
final IconData icon;
final Widget content;
final EdgeInsets? padding;
final double? height;
final double? width;
const InfoTile({ const InfoTile({
super.key, super.key,
required this.title, required this.title,
@@ -18,6 +19,24 @@ class InfoTile extends StatefulWidget {
this.width, this.width,
}); });
/// The title text displayed on the tile.
final String title;
/// The icon displayed next to the title.
final IconData icon;
/// The content widget displayed below the title.
final Widget content;
/// Optional padding for the tile content.
final EdgeInsets? padding;
/// Optional height for the tile.
final double? height;
/// Optional width for the tile.
final double? width;
@override @override
State<InfoTile> createState() => _InfoTileState(); State<InfoTile> createState() => _InfoTileState();
} }

View File

@@ -2,14 +2,14 @@ import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
import 'package:skeletonizer/skeletonizer.dart'; import 'package:skeletonizer/skeletonizer.dart';
class MatchTile extends StatefulWidget { class MatchSummaryTile extends StatefulWidget {
final String matchTitle; final String matchTitle;
final String game; final String game;
final String ruleset; final String ruleset;
final String players; final String players;
final String winner; final String winner;
const MatchTile({ const MatchSummaryTile({
super.key, super.key,
required this.matchTitle, required this.matchTitle,
required this.game, required this.game,
@@ -19,10 +19,10 @@ class MatchTile extends StatefulWidget {
}); });
@override @override
State<MatchTile> createState() => _MatchTileState(); State<MatchSummaryTile> createState() => _MatchSummaryTileState();
} }
class _MatchTileState extends State<MatchTile> { class _MatchSummaryTileState extends State<MatchSummaryTile> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(

View File

@@ -0,0 +1,266 @@
import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/data/dto/match.dart';
import 'package:game_tracker/data/dto/player.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/tiles/text_icon_tile.dart';
import 'package:intl/intl.dart';
/// A tile widget that displays information about a match, including its name,
/// creation date, associated group, winner, and players.
/// - [match]: The match data to be displayed.
/// - [onTap]: The callback invoked when the tile is tapped.
/// - [width]: Optional width for the tile.
/// - [compact]: Whether to display the tile in a compact mode
class MatchTile extends StatefulWidget {
const MatchTile({
super.key,
required this.match,
required this.onTap,
this.width,
this.compact = false,
});
/// The match data to be displayed.
final Match match;
/// The callback invoked when the tile is tapped.
final VoidCallback onTap;
/// Optional width for the tile.
final double? width;
/// Whether to display the tile in a compact mode
final bool compact;
@override
State<MatchTile> createState() => _MatchTileState();
}
class _MatchTileState extends State<MatchTile> {
late final List<Player> _allPlayers;
@override
void initState() {
super.initState();
_allPlayers = _getCombinedPlayers();
}
@override
Widget build(BuildContext context) {
final group = widget.match.group;
final winner = widget.match.winner;
final loc = AppLocalizations.of(context);
return GestureDetector(
onTap: widget.onTap,
child: Container(
margin: EdgeInsets.zero,
width: widget.width,
padding: const EdgeInsets.all(12),
decoration: CustomTheme.standardBoxDecoration,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
widget.match.name,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
overflow: TextOverflow.ellipsis,
),
),
Text(
_formatDate(widget.match.createdAt, context),
style: const TextStyle(fontSize: 12, color: Colors.grey),
),
],
),
const SizedBox(height: 8),
if (group != null) ...[
Row(
children: [
const Icon(Icons.group, size: 16, color: Colors.grey),
const SizedBox(width: 6),
Expanded(
child: Text(
'${group.name}${widget.match.players != null ? ' + ${widget.match.players?.length}' : ''}',
style: const TextStyle(fontSize: 14, color: Colors.grey),
overflow: TextOverflow.ellipsis,
),
),
],
),
const SizedBox(height: 12),
] else if (widget.compact) ...[
Row(
children: [
const Icon(Icons.person, size: 16, color: Colors.grey),
const SizedBox(width: 6),
Expanded(
child: Text(
'${widget.match.players!.length} ${loc.players}',
style: const TextStyle(fontSize: 14, color: Colors.grey),
overflow: TextOverflow.ellipsis,
),
),
],
),
const SizedBox(height: 12),
],
if (winner != null) ...[
Container(
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 12,
),
decoration: BoxDecoration(
color: Colors.green.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Colors.green.withValues(alpha: 0.3),
width: 1,
),
),
child: Row(
children: [
const Icon(
Icons.emoji_events,
size: 20,
color: Colors.amber,
),
const SizedBox(width: 8),
Expanded(
child: Text(
'${loc.winner}: ${winner.name}',
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: CustomTheme.textColor,
),
overflow: TextOverflow.ellipsis,
),
),
],
),
),
const SizedBox(height: 12),
] else ...[
Container(
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 12,
),
decoration: BoxDecoration(
color: Colors.amber.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Colors.amber.withValues(alpha: 0.3),
width: 1,
),
),
child: Row(
children: [
const Icon(
Icons.watch_later,
size: 20,
color: Colors.amber,
),
const SizedBox(width: 8),
Expanded(
child: Text(
loc.match_in_progress,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: CustomTheme.textColor,
),
overflow: TextOverflow.ellipsis,
),
),
],
),
),
const SizedBox(height: 12),
],
if (_allPlayers.isNotEmpty && widget.compact == false) ...[
Text(
loc.players,
style: const TextStyle(
fontSize: 13,
color: Colors.grey,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 6),
Wrap(
spacing: 6,
runSpacing: 6,
children: _allPlayers.map((player) {
return TextIconTile(text: player.name, iconEnabled: false);
}).toList(),
),
],
],
),
),
);
}
/// Formats the given [dateTime] into a human-readable string based on its
/// difference from the current date.
String _formatDate(DateTime dateTime, BuildContext context) {
final now = DateTime.now();
final difference = now.difference(dateTime);
final loc = AppLocalizations.of(context);
if (difference.inDays == 0) {
return "${loc.today_at} ${DateFormat('HH:mm').format(dateTime)}";
} else if (difference.inDays == 1) {
return "${loc.yesterday_at} ${DateFormat('HH:mm').format(dateTime)}";
} else if (difference.inDays < 7) {
return loc.days_ago(difference.inDays);
} else {
return DateFormat('MMM d, yyyy').format(dateTime);
}
}
/// Retrieves all unique players associated with the match,
/// combining players from both the match and its group.
List<Player> _getCombinedPlayers() {
final allPlayers = <Player>[];
final playerIds = <String>{};
// Add players from game.players
if (widget.match.players != null) {
for (var player in widget.match.players!) {
if (!playerIds.contains(player.id)) {
allPlayers.add(player);
playerIds.add(player.id);
}
}
}
// Add players from game.group.players
if (widget.match.group?.members != null) {
for (var player in widget.match.group!.members) {
if (!playerIds.contains(player.id)) {
allPlayers.add(player);
playerIds.add(player.id);
}
}
}
allPlayers.sort((a, b) => a.name.compareTo(b.name));
return allPlayers;
}
}

View File

@@ -1,13 +1,14 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
/// A tile widget that displays a title with an icon and a numeric value below it.
/// - [title]: The title text displayed on the tile.
/// - [icon]: The icon displayed next to the title.
/// - [value]: The numeric value displayed below the title.
/// - [height]: Optional height for the tile.
/// - [width]: Optional width for the tile.
/// - [padding]: Optional padding for the tile content.
class QuickInfoTile extends StatefulWidget { class QuickInfoTile extends StatefulWidget {
final String title;
final IconData icon;
final int value;
final double? height;
final double? width;
final EdgeInsets? padding;
const QuickInfoTile({ const QuickInfoTile({
super.key, super.key,
required this.title, required this.title,
@@ -18,6 +19,24 @@ class QuickInfoTile extends StatefulWidget {
this.padding, this.padding,
}); });
/// The title text displayed on the tile.
final String title;
/// The icon displayed next to the title.
final IconData icon;
/// The numeric value displayed below the title.
final int value;
/// Optional height for the tile.
final double? height;
/// Optional width for the tile.
final double? width;
/// Optional padding for the tile content.
final EdgeInsets? padding;
@override @override
State<QuickInfoTile> createState() => _QuickInfoTileState(); State<QuickInfoTile> createState() => _QuickInfoTileState();
} }

View File

@@ -1,19 +1,32 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
/// A customizable settings list tile widget that displays an icon, title, and an optional suffix widget.
/// - [icon]: The icon displayed on the left side of the tile.
/// - [title]: The title text displayed next to the icon.
/// - [suffixWidget]: An optional widget displayed on the right side of the tile.
/// - [onPressed]: The callback invoked when the tile is tapped.
class SettingsListTile extends StatelessWidget { class SettingsListTile extends StatelessWidget {
final VoidCallback? onPressed;
final IconData icon;
final String title;
final Widget? suffixWidget;
const SettingsListTile({ const SettingsListTile({
super.key, super.key,
required this.title,
required this.icon, required this.icon,
required this.title,
this.suffixWidget, this.suffixWidget,
this.onPressed, this.onPressed,
}); });
/// The icon displayed on the left side of the tile.
final IconData icon;
/// The title text displayed next to the icon.
final String title;
/// An optional widget displayed on the right side of the tile.
final Widget? suffixWidget;
/// The callback invoked when the tile is tapped.
final VoidCallback? onPressed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Padding(

View File

@@ -1,8 +1,16 @@
import 'dart:math'; import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/l10n/generated/app_localizations.dart';
import 'package:game_tracker/presentation/widgets/tiles/info_tile.dart'; import 'package:game_tracker/presentation/widgets/tiles/info_tile.dart';
/// A tile widget that displays statistical data using horizontal bars.
/// - [icon]: The icon displayed next to the title.
/// - [title]: The title text displayed on the tile.
/// - [width]: The width of the tile.
/// - [values]: A list of tuples containing labels and their corresponding numeric values.
/// - [itemCount]: The maximum number of items to display.
/// - [barColor]: The color of the bars representing the values.
class StatisticsTile extends StatelessWidget { class StatisticsTile extends StatelessWidget {
const StatisticsTile({ const StatisticsTile({
super.key, super.key,
@@ -14,16 +22,27 @@ class StatisticsTile extends StatelessWidget {
required this.barColor, required this.barColor,
}); });
/// The icon displayed next to the title.
final IconData icon; final IconData icon;
/// The title text displayed on the tile.
final String title; final String title;
/// The width of the tile.
final double width; final double width;
/// A list of tuples containing labels and their corresponding numeric values.
final List<(String, num)> values; final List<(String, num)> values;
/// The maximum number of items to display.
final int itemCount; final int itemCount;
/// The color of the bars representing the values.
final Color barColor; final Color barColor;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final maxBarWidth = MediaQuery.of(context).size.width * 0.65; final loc = AppLocalizations.of(context);
return InfoTile( return InfoTile(
width: width, width: width,
@@ -33,11 +52,14 @@ class StatisticsTile extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 20.0), padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Visibility( child: Visibility(
visible: values.isNotEmpty, visible: values.isNotEmpty,
replacement: const Center( replacement: Center(
heightFactor: 4, heightFactor: 4,
child: Text('No data available.'), child: Text(loc.no_data_available),
), ),
child: Column( child: LayoutBuilder(
builder: (context, constraints) {
final maxBarWidth = constraints.maxWidth * 0.65;
return Column(
children: List.generate(min(values.length, itemCount), (index) { children: List.generate(min(values.length, itemCount), (index) {
/// The maximum wins among all players /// The maximum wins among all players
final maxMatches = values.isNotEmpty ? values[0].$2 : 0; final maxMatches = values.isNotEmpty ? values[0].$2 : 0;
@@ -94,6 +116,8 @@ class StatisticsTile extends StatelessWidget {
), ),
); );
}), }),
);
},
), ),
), ),
), ),

View File

@@ -1,18 +1,27 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
/// A list tile widget that displays text with an optional icon button.
/// - [text]: The text to display in the tile.
/// - [onPressed]: The callback to be invoked when the icon is pressed.
/// - [iconEnabled]: A boolean to determine if the icon should be displayed.
class TextIconListTile extends StatelessWidget { class TextIconListTile extends StatelessWidget {
final String text;
final VoidCallback? onPressed;
final bool iconEnabled;
const TextIconListTile({ const TextIconListTile({
super.key, super.key,
required this.text, required this.text,
this.onPressed,
this.iconEnabled = true, this.iconEnabled = true,
this.onPressed,
}); });
/// The text to display in the tile.
final String text;
/// A boolean to determine if the icon should be displayed.
final bool iconEnabled;
/// The callback to be invoked when the icon is pressed.
final VoidCallback? onPressed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(

View File

@@ -1,18 +1,27 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
/// A tile widget that displays text with an optional icon that can be tapped.
/// - [text]: The text to display in the tile.
/// - [iconEnabled]: A boolean to determine if the icon should be displayed.
/// - [onIconTap]: The callback to be invoked when the icon is tapped.
class TextIconTile extends StatelessWidget { class TextIconTile extends StatelessWidget {
final String text;
final bool iconEnabled;
final VoidCallback? onIconTap;
const TextIconTile({ const TextIconTile({
super.key, super.key,
required this.text, required this.text,
this.onIconTap,
this.iconEnabled = true, this.iconEnabled = true,
this.onIconTap,
}); });
/// The text to display in the tile.
final String text;
/// A boolean to determine if the icon should be displayed.
final bool iconEnabled;
/// The callback to be invoked when the icon is tapped.
final VoidCallback? onIconTap;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(

View File

@@ -1,14 +1,14 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/custom_theme.dart';
/// A list tile widget that displays a title and description, with optional highlighting and badge.
/// - [title]: The title text displayed on the tile.
/// - [description]: The description text displayed below the title.
/// - [onPressed]: The callback invoked when the tile is tapped.
/// - [isHighlighted]: A boolean to determine if the tile should be highlighted.
/// - [badgeText]: Optional text to display in a badge on the right side of the title.
/// - [badgeColor]: Optional color for the badge background.
class TitleDescriptionListTile extends StatelessWidget { class TitleDescriptionListTile extends StatelessWidget {
final String title;
final String description;
final VoidCallback? onPressed;
final bool isHighlighted;
final String? badgeText;
final Color? badgeColor;
const TitleDescriptionListTile({ const TitleDescriptionListTile({
super.key, super.key,
required this.title, required this.title,
@@ -19,6 +19,24 @@ class TitleDescriptionListTile extends StatelessWidget {
this.badgeColor, this.badgeColor,
}); });
/// The title text displayed on the tile.
final String title;
/// The description text displayed below the title.
final String description;
/// The callback invoked when the tile is tapped.
final VoidCallback? onPressed;
/// A boolean to determine if the tile should be highlighted.
final bool isHighlighted;
/// Optional text to display in a badge on the right side of the title.
final String? badgeText;
/// Optional color for the badge background.
final Color? badgeColor;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
@@ -54,7 +72,7 @@ class TitleDescriptionListTile extends StatelessWidget {
if (badgeText != null) ...[ if (badgeText != null) ...[
const Spacer(), const Spacer(),
Container( Container(
constraints: const BoxConstraints(maxWidth: 100), constraints: const BoxConstraints(maxWidth: 115),
margin: const EdgeInsets.only(top: 4), margin: const EdgeInsets.only(top: 4),
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 2, vertical: 2,

View File

@@ -1,5 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// A widget that displays a message centered at the top of the screen with an icon, title, and message.
/// - [icon]: The icon to display above the title.
/// - [title]: The title text to display.
/// - [message]: The message text to display below the title.
class TopCenteredMessage extends StatelessWidget { class TopCenteredMessage extends StatelessWidget {
const TopCenteredMessage({ const TopCenteredMessage({
super.key, super.key,
@@ -8,10 +12,15 @@ class TopCenteredMessage extends StatelessWidget {
required this.message, required this.message,
}); });
final String title; /// The icon to display above the title.
final String message;
final IconData icon; final IconData icon;
/// The title text to display.
final String title;
/// The message text to display below the title.
final String message;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(

View File

@@ -31,9 +31,25 @@ class DataTransferService {
// Construct a JSON representation of the data // Construct a JSON representation of the data
final Map<String, dynamic> jsonMap = { final Map<String, dynamic> jsonMap = {
'matches': matches.map((match) => match.toJson()).toList(), 'players': players.map((p) => p.toJson()).toList(),
'groups': groups.map((group) => group.toJson()).toList(),
'players': players.map((player) => player.toJson()).toList(), 'groups': groups
.map((g) => {
'id': g.id,
'name': g.name,
'createdAt': g.createdAt.toIso8601String(),
'memberIds': (g.members).map((m) => m.id).toList(),
}).toList(),
'matches': matches
.map((m) => {
'id': m.id,
'name': m.name,
'createdAt': m.createdAt.toIso8601String(),
'groupId': m.group?.id,
'playerIds': (m.players ?? []).map((p) => p.id).toList(),
'winnerId': m.winner?.id,
}).toList(),
}; };
return json.encode(jsonMap); return json.encode(jsonMap);
@@ -46,7 +62,7 @@ class DataTransferService {
/// [fileName] The desired name for the exported file (without extension). /// [fileName] The desired name for the exported file (without extension).
static Future<ExportResult> exportData( static Future<ExportResult> exportData(
String jsonString, String jsonString,
String fileName, String fileName
) async { ) async {
try { try {
final bytes = Uint8List.fromList(utf8.encode(jsonString)); final bytes = Uint8List.fromList(utf8.encode(jsonString));
@@ -54,11 +70,13 @@ class DataTransferService {
fileName: '$fileName.json', fileName: '$fileName.json',
bytes: bytes, bytes: bytes,
); );
if (path == null) { if (path == null) {
return ExportResult.canceled; return ExportResult.canceled;
} else { } else {
return ExportResult.success; return ExportResult.success;
} }
} catch (e, stack) { } catch (e, stack) {
print('[exportData] $e'); print('[exportData] $e');
print(stack); print(stack);
@@ -81,42 +99,77 @@ class DataTransferService {
try { try {
final jsonString = await _readFileContent(path.files.single); final jsonString = await _readFileContent(path.files.single);
if (jsonString == null) { if (jsonString == null) return ImportResult.fileReadError;
return ImportResult.fileReadError;
}
if (await _validateJsonSchema(jsonString)) { final isValid = await _validateJsonSchema(jsonString);
final Map<String, dynamic> jsonData = if (!isValid) return ImportResult.invalidSchema;
json.decode(jsonString) as Map<String, dynamic>;
final List<dynamic>? matchesJson = final Map<String, dynamic> decoded = json.decode(jsonString) as Map<String, dynamic>;
jsonData['matches'] as List<dynamic>?;
final List<dynamic>? groupsJson = jsonData['groups'] as List<dynamic>?;
final List<dynamic>? playersJson =
jsonData['players'] as List<dynamic>?;
final List<Match> importedMatches = final List<dynamic> playersJson = (decoded['players'] as List<dynamic>?) ?? [];
matchesJson final List<dynamic> groupsJson = (decoded['groups'] as List<dynamic>?) ?? [];
?.map((g) => Match.fromJson(g as Map<String, dynamic>)) final List<dynamic> matchesJson = (decoded['matches'] as List<dynamic>?) ?? [];
.toList() ??
[]; // Players
final List<Group> importedGroups = final List<Player> importedPlayers = playersJson
groupsJson .map((p) => Player.fromJson(p as Map<String, dynamic>))
?.map((g) => Group.fromJson(g as Map<String, dynamic>)) .toList();
.toList() ??
[]; final Map<String, Player> playerById = {
final List<Player> importedPlayers = for (final p in importedPlayers) p.id: p,
playersJson };
?.map((p) => Player.fromJson(p as Map<String, dynamic>))
.toList() ?? // Groups
[]; final List<Group> importedGroups = groupsJson.map((g) {
final map = g as Map<String, dynamic>;
final memberIds = (map['memberIds'] as List<dynamic>? ?? []).cast<String>();
final members = memberIds
.map((id) => playerById[id])
.whereType<Player>()
.toList();
return Group(
id: map['id'] as String,
name: map['name'] as String,
members: members,
createdAt: DateTime.parse(map['createdAt'] as String),
);
}).toList();
final Map<String, Group> groupById = {
for (final g in importedGroups) g.id: g,
};
// Matches
final List<Match> importedMatches = matchesJson.map((m) {
final map = m as Map<String, dynamic>;
final String? groupId = map['groupId'] as String?;
final List<String> playerIds = (map['playerIds'] as List<dynamic>? ?? []).cast<String>();
final String? winnerId = map['winnerId'] as String?;
final group = (groupId == null) ? null : groupById[groupId];
final players = playerIds
.map((id) => playerById[id])
.whereType<Player>()
.toList();
final winner = (winnerId == null) ? null : playerById[winnerId];
return Match(
id: map['id'] as String,
name: map['name'] as String,
group: group,
players: players,
createdAt: DateTime.parse(map['createdAt'] as String),
winner: winner,
);
}).toList();
await db.playerDao.addPlayersAsList(players: importedPlayers); await db.playerDao.addPlayersAsList(players: importedPlayers);
await db.groupDao.addGroupsAsList(groups: importedGroups); await db.groupDao.addGroupsAsList(groups: importedGroups);
await db.matchDao.addMatchAsList(matches: importedMatches); await db.matchDao.addMatchAsList(matches: importedMatches);
} else {
return ImportResult.invalidSchema;
}
return ImportResult.success; return ImportResult.success;
} on FormatException catch (e, stack) { } on FormatException catch (e, stack) {
print('[importData] FormatException'); print('[importData] FormatException');

View File

@@ -1,7 +1,7 @@
name: game_tracker name: game_tracker
description: "Game Tracking App for Card Games" description: "Game Tracking App for Card Games"
publish_to: 'none' publish_to: 'none'
version: 0.0.1+21 version: 0.0.1+149
environment: environment:
sdk: ^3.8.1 sdk: ^3.8.1
@@ -9,11 +9,6 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
material_symbols_icons: ^4.2815.1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
drift: ^2.27.0 drift: ^2.27.0
drift_flutter: ^0.2.4 drift_flutter: ^0.2.4
path_provider: ^2.1.5 path_provider: ^2.1.5
@@ -24,7 +19,10 @@ dependencies:
json_schema: ^5.2.2 json_schema: ^5.2.2
file_saver: ^0.3.1 file_saver: ^0.3.1
clock: ^1.1.2 clock: ^1.1.2
intl: ^0.18.0 intl: any
flutter_localizations:
sdk: flutter
package_info_plus: ^9.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
@@ -35,5 +33,6 @@ dev_dependencies:
flutter: flutter:
uses-material-design: true uses-material-design: true
generate: true
assets: assets:
- assets/schema.json - assets/schema.json

View File

@@ -23,7 +23,7 @@ void main() {
final fixedDate = DateTime(2025, 19, 11, 00, 11, 23); final fixedDate = DateTime(2025, 19, 11, 00, 11, 23);
final fakeClock = Clock(() => fixedDate); final fakeClock = Clock(() => fixedDate);
setUp(() { setUp(() async {
database = AppDatabase( database = AppDatabase(
DatabaseConnection( DatabaseConnection(
NativeDatabase.memory(), NativeDatabase.memory(),
@@ -68,6 +68,16 @@ void main() {
group: testGroup2, group: testGroup2,
); );
}); });
await database.playerDao.addPlayersAsList(
players: [
testPlayer1,
testPlayer2,
testPlayer3,
testPlayer4,
testPlayer5,
],
);
await database.groupDao.addGroupsAsList(groups: [testGroup1, testGroup2]);
}); });
tearDown(() async { tearDown(() async {
await database.close(); await database.close();
@@ -253,7 +263,7 @@ void main() {
expect(matchCount, 0); expect(matchCount, 0);
}); });
test('Checking if match has winner works correclty', () async { test('Checking if match has winner works correctly', () async {
await database.matchDao.addMatch(match: testMatch1); await database.matchDao.addMatch(match: testMatch1);
await database.matchDao.addMatch(match: testMatchOnlyGroup); await database.matchDao.addMatch(match: testMatchOnlyGroup);

View File

@@ -1,5 +1,5 @@
import 'package:clock/clock.dart'; import 'package:clock/clock.dart';
import 'package:drift/drift.dart'; import 'package:drift/drift.dart' hide isNotNull;
import 'package:drift/native.dart'; import 'package:drift/native.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:game_tracker/data/db/database.dart'; import 'package:game_tracker/data/db/database.dart';
@@ -21,7 +21,7 @@ void main() {
final fixedDate = DateTime(2025, 19, 11, 00, 11, 23); final fixedDate = DateTime(2025, 19, 11, 00, 11, 23);
final fakeClock = Clock(() => fixedDate); final fakeClock = Clock(() => fixedDate);
setUp(() { setUp(() async {
database = AppDatabase( database = AppDatabase(
DatabaseConnection( DatabaseConnection(
NativeDatabase.memory(), NativeDatabase.memory(),
@@ -53,6 +53,16 @@ void main() {
group: testGroup1, group: testGroup1,
); );
}); });
await database.playerDao.addPlayersAsList(
players: [
testPlayer1,
testPlayer2,
testPlayer3,
testPlayer4,
testPlayer5,
],
);
await database.groupDao.addGroupsAsList(groups: [testGroup1, testGroup2]);
}); });
tearDown(() async { tearDown(() async {
await database.close(); await database.close();
@@ -179,5 +189,33 @@ void main() {
} }
} }
}); });
test('Adding the same group to seperate matches works correctly', () async {
final match1 = Match(name: 'Match 1', group: testGroup1);
final match2 = Match(name: 'Match 2', group: testGroup1);
await Future.wait([
database.matchDao.addMatch(match: match1),
database.matchDao.addMatch(match: match2),
]);
final group1 = await database.groupMatchDao.getGroupOfMatch(
matchId: match1.id,
);
final group2 = await database.groupMatchDao.getGroupOfMatch(
matchId: match2.id,
);
expect(group1, isNotNull);
expect(group2, isNotNull);
final groups = [group1!, group2!];
for (final group in groups) {
expect(group.members.length, testGroup1.members.length);
expect(group.id, testGroup1.id);
expect(group.name, testGroup1.name);
expect(group.createdAt, testGroup1.createdAt);
}
});
}); });
} }

View File

@@ -1,5 +1,5 @@
import 'package:clock/clock.dart'; import 'package:clock/clock.dart';
import 'package:drift/drift.dart'; import 'package:drift/drift.dart' hide isNotNull;
import 'package:drift/native.dart'; import 'package:drift/native.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:game_tracker/data/db/database.dart'; import 'package:game_tracker/data/db/database.dart';
@@ -21,7 +21,7 @@ void main() {
final fixedDate = DateTime(2025, 19, 11, 00, 11, 23); final fixedDate = DateTime(2025, 19, 11, 00, 11, 23);
final fakeClock = Clock(() => fixedDate); final fakeClock = Clock(() => fixedDate);
setUp(() { setUp(() async {
database = AppDatabase( database = AppDatabase(
DatabaseConnection( DatabaseConnection(
NativeDatabase.memory(), NativeDatabase.memory(),
@@ -50,6 +50,17 @@ void main() {
players: [testPlayer4, testPlayer5, testPlayer6], players: [testPlayer4, testPlayer5, testPlayer6],
); );
}); });
await database.playerDao.addPlayersAsList(
players: [
testPlayer1,
testPlayer2,
testPlayer3,
testPlayer4,
testPlayer5,
testPlayer6,
],
);
await database.groupDao.addGroup(group: testgroup);
}); });
tearDown(() async { tearDown(() async {
await database.close(); await database.close();
@@ -185,5 +196,42 @@ void main() {
expect(player.createdAt, testPlayer.createdAt); expect(player.createdAt, testPlayer.createdAt);
} }
}); });
test(
'Adding the same player to seperate matches works correctly',
() async {
final playersList = [testPlayer1, testPlayer2, testPlayer3];
final match1 = Match(name: 'Match 1', players: playersList);
final match2 = Match(name: 'Match 2', players: playersList);
await Future.wait([
database.matchDao.addMatch(match: match1),
database.matchDao.addMatch(match: match2),
]);
final players1 = await database.playerMatchDao.getPlayersOfMatch(
matchId: match1.id,
);
final players2 = await database.playerMatchDao.getPlayersOfMatch(
matchId: match2.id,
);
expect(players1, isNotNull);
expect(players2, isNotNull);
expect(
players1!.map((p) => p.id).toList(),
equals(players2!.map((p) => p.id).toList()),
);
expect(
players1.map((p) => p.name).toList(),
equals(players2.map((p) => p.name).toList()),
);
expect(
players1.map((p) => p.createdAt).toList(),
equals(players2.map((p) => p.createdAt).toList()),
);
},
);
}); });
} }