Compare commits
177 Commits
ed9e3af768
...
enhancemen
| Author | SHA1 | Date | |
|---|---|---|---|
| 5da12939cb | |||
| 0d20b5847f | |||
| 973e327232 | |||
| 70f570489a | |||
| 80e601c10e | |||
| 2124c523bc | |||
| 7d0da81cf5 | |||
| cd3a5c2a49 | |||
| 4628e96456 | |||
| 6d42d59bad | |||
| 46118c274c | |||
| ec5a686f90 | |||
| f0c6dd8401 | |||
| 7bdad57cc8 | |||
| 5da1b6eecb | |||
| cdafd4bb6f | |||
| 6aee055df2 | |||
| 6d9871a5f0 | |||
| 4bbbcdd93f | |||
| fed5c55dd4 | |||
| c157644b44 | |||
| 5a5898787f | |||
| 9d3a45c01d | |||
| 485ac87fdb | |||
| 758f1e6c3a | |||
| 7fc4bbfb13 | |||
| 857e05127d | |||
| 86982ada0f | |||
| e51bf3eabb | |||
| d7f08c5f50 | |||
| 9248284292 | |||
| 9a00e543d7 | |||
| 5ea7797b3e | |||
| c8b76ae0ea | |||
| c5fa540c5f | |||
| e384230a0b | |||
| 1e4fd2a164 | |||
| a491427a1d | |||
| 906c8d8450 | |||
| 000bdc8cbc | |||
| 497f30421d | |||
| adedb85eb2 | |||
| 2a72332bcd | |||
| 7aa41abe61 | |||
| e1263d51ad | |||
| 8791b5296e | |||
| f2a4327166 | |||
| d34990ed50 | |||
| 2ef671884d | |||
| 2ef8eb6534 | |||
| 6f0e5ba5c2 | |||
| 1c07346aaf | |||
| 830a64b5dd | |||
| 9221f64fa5 | |||
| c4f6749882 | |||
| 14a043785e | |||
| 9eb9c0eb7f | |||
| 54ec865f04 | |||
| d5e7a17127 | |||
| 275f64b296 | |||
| 97ca62b083 | |||
| 32fb1550ff | |||
| d67972624e | |||
| 595cf6ead0 | |||
| 6faafe9fab | |||
| 66b90aac25 | |||
| d22855fc1a | |||
| 1be86bc3c5 | |||
| db3e8215fa | |||
| 2c4cef76d8 | |||
| a4ef9705f9 | |||
| 799c849570 | |||
| 644728a9df | |||
| afb7a5f1d4 | |||
| 3d510d5b3d | |||
| a9d2325eee | |||
| 349ff948de | |||
| c2394c3733 | |||
| 88766652b9 | |||
| 2a1573ee2d | |||
| cfb07bfe28 | |||
| d741990f2f | |||
| 76121eb4fb | |||
| d5ee6449b0 | |||
| 7d9757abb6 | |||
| d94d51c6ea | |||
|
|
803cf8a972 | ||
|
|
13be75a65b | ||
| aef12bd65a | |||
| 02d79574dd | |||
| fdd0e7579a | |||
| cd2770be26 | |||
| e196d6e5ef | |||
| bc3beac866 | |||
| aa936a938d | |||
| 2811ea892e | |||
| 4b1d3923a0 | |||
| 0f824bb30a | |||
| 21c74b74bc | |||
| 6e45e9435b | |||
| a78614851b | |||
| 8df9a27dc7 | |||
| 52180eeb6d | |||
| 0893667e41 | |||
| 1dc5286c6b | |||
|
|
f140ebae2e | ||
| a487e4071f | |||
|
|
99044c0ea0 | ||
| 69effa2b7d | |||
| 5db008c274 | |||
| feaa0709a7 | |||
|
|
2fea3597fe | ||
|
|
7b2314a25e | ||
|
|
7f6c1cb9a6 | ||
| dcfed75a93 | |||
| 7fa434782c | |||
| bdcee85eb9 | |||
| 072dba1cde | |||
| 3c7c4598ff | |||
| 1a20d7b64c | |||
| ec94e12ed7 | |||
| 9fc308554c | |||
| 42cef337aa | |||
|
|
d9980edf0e | ||
|
|
4c084cae4a | ||
|
|
cecfd5da4e | ||
| 5289660327 | |||
| 16e1f542f5 | |||
| e4ae526d93 | |||
| 2f65316a51 | |||
| 31abb7f1e4 | |||
| 132966f3d2 | |||
| 77095725de | |||
| d081a597db | |||
| bdc3453d7f | |||
| 678ab90af3 | |||
| a038c22ba6 | |||
| 22fcff73bd | |||
|
|
4a67dae456 | ||
| 3c22b084d6 | |||
| 7f923f6dff | |||
| 87856e6548 | |||
| cb7804cf55 | |||
| 304fa82a93 | |||
| f84a645e61 | |||
| b0073addf8 | |||
| b5c17ac5a9 | |||
| 4451f9e2a9 | |||
| 1d4fdae84b | |||
| 60862de4c4 | |||
| 6899bb0c3c | |||
| 55a22b292f | |||
| db30b0fd5a | |||
| 5ee0d59377 | |||
| f22595e678 | |||
| 25fe10eb9a | |||
| 5a318f9760 | |||
| 0051990168 | |||
| 7e21c65026 | |||
| cc23c03f6b | |||
| d77b5f20f9 | |||
| 3c3bf506cb | |||
| 8afba5680b | |||
| 7103765054 | |||
| bc01a6de9a | |||
| ad87dca674 | |||
| 633a21d829 | |||
| 81f63c1c07 | |||
| fc6c74b377 | |||
| 15d09f381a | |||
| f97c341b81 | |||
| 7bf03ec388 | |||
| 0bfaba4225 | |||
| bbb7914fc5 | |||
| 86dbc9afb0 | |||
| 73aea0d0f5 | |||
| 0f79495775 |
@@ -1,35 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Erstelle eine Meldung für etwas, das nicht Funktioniert, wie es soll.
|
||||
title: ''
|
||||
labels: 'Task/Bug'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
# Bug Report
|
||||
|
||||
## Beschreibung
|
||||
[Eine klare und prägnante Beschreibung des Bugs]
|
||||
|
||||
## Schritte zur Reproduktion
|
||||
1. Schritt 1
|
||||
2. Schritt 2
|
||||
3. ...
|
||||
|
||||
## Erwartetes Verhalten
|
||||
[Was hätte passieren sollen]
|
||||
|
||||
## Tatsächliches Verhalten
|
||||
[Was tatsächlich passiert ist]
|
||||
|
||||
## Screenshots/Protokolle
|
||||
[Falls zutreffend, füge Screenshots, Error Logs oder Stack Traces hinzu]
|
||||
|
||||
## Umgebung
|
||||
- Plattform: Android, iOS, Web
|
||||
- OS: [z. B. iOS 18.5, Android 14]
|
||||
- Flutter Version: [z.B. 3.35.6]
|
||||
|
||||
## Verwandte Issues
|
||||
[Verweisen Sie auf ähnliche Issues oder PRs]
|
||||
@@ -1,22 +0,0 @@
|
||||
---
|
||||
name: Enhancement
|
||||
about: Enhancements for current features
|
||||
title: ''
|
||||
labels: 'Task\Enhancement'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
# Enhancement
|
||||
|
||||
## Aktuelles Verhalten
|
||||
[Beschreibe die bestehende Funktionalität]
|
||||
|
||||
## Einschränkungen/Probleme
|
||||
[Was sind die aktuellen Mängel?]
|
||||
|
||||
## Vorgeschlagene Verbesserung
|
||||
[Wie kann das Problem bzw. die Einschränkung verbessert werden?]
|
||||
|
||||
## Zugehörige Issues
|
||||
[Links zu verwandten oder blockierenden Issues]
|
||||
@@ -1,19 +0,0 @@
|
||||
---
|
||||
name: Feature
|
||||
about: Neues Feature für die App
|
||||
title: ''
|
||||
labels: 'Task\Feature'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
# Feature
|
||||
|
||||
## Beschreibung
|
||||
[Ausführliche Erläuterung der vorgeschlagenen Funktion]
|
||||
|
||||
## Vorgeschlagene Lösung
|
||||
[Beschreibe, wie die Feature funktionieren soll]
|
||||
|
||||
## Zugehörige Issues
|
||||
[Links zu verwandten oder blockierenden Issues]
|
||||
@@ -1,16 +0,0 @@
|
||||
# [PR Titel]
|
||||
|
||||
**Zugehörige Issue(s):**
|
||||
Closes `<issue-no>`
|
||||
|
||||
## Beschreibung
|
||||
*Eine klare und prägnante Übersicht über die vorgenommenen Änderungen. Erläutere nicht nur das was gemacht wurde, sondern auch warum.*
|
||||
|
||||
## Änderungen
|
||||
- [ ] Neue Funktion X hinzugefügt
|
||||
- [ ] Bug in Komponente Y behoben
|
||||
- [ ] Modul Z für bessere Leistung refactored
|
||||
- [ ] Dependencies aktualisiert
|
||||
|
||||
## Zusätzliche Anmerkungen
|
||||
*Gibt es zusätzlichen Kontext, Einschränkungen oder Informationen, die Reviewer wissen sollten?*
|
||||
53
.gitea/issue_template/bug.yaml
Normal file
53
.gitea/issue_template/bug.yaml
Normal file
@@ -0,0 +1,53 @@
|
||||
name: Bug Report
|
||||
about: Erstelle eine Bug Report
|
||||
labels: 'Task/Bug'
|
||||
title: ''
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Beschreibung
|
||||
description: Beschreibe klar und pregnant das Fehlerverhalten
|
||||
placeholder: |
|
||||
- Was genau ist das unerwünschte Verhalten?
|
||||
- Welche Auswirkungen hat der Fehler?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: Schritte zur Reproduktion
|
||||
description: Beschreibe, wie der Fehler reproduziert werden kann
|
||||
placeholder: |
|
||||
- 1. Schritt 1
|
||||
- 2. Schritt 2
|
||||
- 3. ...
|
||||
|
||||
- type: dropdown
|
||||
id: enviroment
|
||||
attributes:
|
||||
label: Umgebung
|
||||
description: Gebe an, auf welchen Platformen dieser Fehler auftritt
|
||||
list: false
|
||||
multiple: true
|
||||
options: ['Android', 'iOS']
|
||||
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Lösungsidee
|
||||
description: Beschreibe, wie das Problem bzw. gelöst werden kann
|
||||
placeholder: |
|
||||
- Button X ändern, sodass ...
|
||||
- Funktion X so erweitern, dass ...
|
||||
- Design anpassen, sodass ...
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Verwandte Issues
|
||||
description: Verweise auf ähnliche Issues oder PRs
|
||||
placeholder: |
|
||||
- Knüpft an Issue #35 an
|
||||
- Ersetzt Issue #12
|
||||
- Brauch Implementierung von #43
|
||||
36
.gitea/issue_template/enhancement.yaml
Normal file
36
.gitea/issue_template/enhancement.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
name: Enhancement
|
||||
about: Erstelle ein Enhancement-Ticket
|
||||
labels: 'Task/Enhancement'
|
||||
title: ''
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Aktuelles Verhalten
|
||||
description: Beschreibe, wie die Funktionalität aktuell gestaltet ist
|
||||
placeholder: |
|
||||
- Aktuell macht Button X folgendes ...
|
||||
- Das Problem ist, dass ...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Vorgeschlagene Verbesserung
|
||||
description: Beschreibe, wie das Problem bzw. die Einschränkung verbessert werden kann
|
||||
placeholder: |
|
||||
- Button X ändern, sodass ...
|
||||
- Funktion X so erweitern, dass ...
|
||||
- Design anpassen, sodass ...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Zugehörige Issues
|
||||
description: Links zu verwandten oder blockierenden Issues
|
||||
placeholder: |
|
||||
- Knüpft an Issue #35 an
|
||||
- Ersetzt Issue #12
|
||||
- Brauch Implementierung von #43
|
||||
36
.gitea/issue_template/feature.yaml
Normal file
36
.gitea/issue_template/feature.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
name: Feature
|
||||
about: Erstelle ein Feature-Ticket
|
||||
labels: 'Task/Feature'
|
||||
title: ''
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Beschreibung
|
||||
description: Ausführliche Erläuterung der vorgeschlagenen Funktion
|
||||
placeholder: |
|
||||
- Welchen Zweck erfüllt das Feature?
|
||||
- Welches Problem löst das Feature?
|
||||
- Wer profitiert davon?
|
||||
- Warum ist es wichtig?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Vorgeschlagene Lösung
|
||||
description: Beschreibe, wie das Feature funktionieren soll
|
||||
placeholder: |
|
||||
- Neues Widget, das folgendermaßen aussieht ...
|
||||
- Neue Ansicht, die folgende Inhalte hat
|
||||
- Neue Funktionsweise von Komponente XY
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Zugehörige Issues
|
||||
description: Links zu verwandten oder blockierenden Issues
|
||||
placeholder: |
|
||||
- Knüpft an Issue #35 an
|
||||
- Ersetzt Issue #12
|
||||
- Brauch Implementierung von #43
|
||||
47
.gitea/pull_request_template.yaml
Normal file
47
.gitea/pull_request_template.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Pull Request
|
||||
about: Vorlage für Pull Requests
|
||||
title: "WIP: [Name des Issues]"
|
||||
|
||||
body:
|
||||
- type: input
|
||||
id: related_issue
|
||||
attributes:
|
||||
label: Zugehörige Issue(s)
|
||||
description: Issues welche mit diesem Pull Request geschlossen werden sollen
|
||||
placeholder: "Closes #123"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Beschreibung
|
||||
description: |
|
||||
Eine klare und prägnante Zusammenfassung aller vorgenommenen Änderungen.
|
||||
placeholder: |
|
||||
Was wurde geändert?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: changes
|
||||
attributes:
|
||||
label: Änderungen
|
||||
description: Liste alle Änderungen detailiert auf, die in diesem Pull Request vorgenommen wurden.
|
||||
placeholder: |
|
||||
- Neue Funktion X hinzugefügt
|
||||
- Bug in Komponente X behoben
|
||||
- Modul X für bessere Leistung refactored
|
||||
- Dependencies aktualisiert
|
||||
|
||||
- type: textarea
|
||||
id: additional_notes
|
||||
attributes:
|
||||
label: Zusätzliche Anmerkungen
|
||||
description: |
|
||||
Gibt es zusätzlichen Kontext, Einschränkungen oder Informationen,
|
||||
die Reviewer wissen sollten?
|
||||
placeholder: |
|
||||
- Bekannte Einschränkungen
|
||||
- Offene TODOs
|
||||
- Hinweise für Reviewer
|
||||
28
.gitignore
vendored
28
.gitignore
vendored
@@ -150,25 +150,9 @@ app.*.symbols
|
||||
.gclient_previous_custom_vars
|
||||
.gclient_previous_sync_commits
|
||||
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.build/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
.swiftpm/
|
||||
migrate_working_dir/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
@@ -176,17 +160,8 @@ migrate_working_dir/
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
**/ios/Flutter/.last_build_id
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
.pub-cache/
|
||||
.pub/
|
||||
/build/
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
||||
# Obfuscation related
|
||||
app.*.map.json
|
||||
@@ -195,3 +170,6 @@ app.*.map.json
|
||||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
/devtools_options.yaml
|
||||
|
||||
untranslated_messages.json
|
||||
14
README.md
14
README.md
@@ -1,7 +1,15 @@
|
||||
# Game Tracker
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
### Versions Supported
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
A all-in-one app to track card- and board games, manage players and groups and get statistics about your played games.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<application
|
||||
android:label="game_tracker"
|
||||
android:name="${applicationName}"
|
||||
@@ -42,5 +43,14 @@
|
||||
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent>
|
||||
<!-- Required for url_launcher to open URLs in external browser -->
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:scheme="http" />
|
||||
</intent>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:scheme="https" />
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
||||
|
||||
@@ -18,7 +18,7 @@ pluginManagement {
|
||||
|
||||
plugins {
|
||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
||||
id("com.android.application") version "8.7.3" apply false
|
||||
id("com.android.application") version "8.9.1" apply false
|
||||
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
|
||||
}
|
||||
|
||||
|
||||
@@ -2,178 +2,103 @@
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"games": {
|
||||
"players": {
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"players": {
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"createdAt",
|
||||
"name"
|
||||
]
|
||||
}
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"group": {
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"members": {
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"createdAt",
|
||||
"name"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"createdAt",
|
||||
"name",
|
||||
"members"
|
||||
]
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"winner": {
|
||||
"type": ["object","null"]
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"createdAt",
|
||||
"name"
|
||||
]
|
||||
}
|
||||
]
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"createdAt",
|
||||
"name"
|
||||
]
|
||||
}
|
||||
},
|
||||
"groups": {
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"members": {
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"createdAt",
|
||||
"name"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"createdAt",
|
||||
"name",
|
||||
"members"
|
||||
]
|
||||
}
|
||||
]
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"memberIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"createdAt",
|
||||
"memberIds"
|
||||
]
|
||||
}
|
||||
},
|
||||
"players": {
|
||||
"matches": {
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"groupId": {
|
||||
"anyOf": [
|
||||
{"type": "string"},
|
||||
{"type": "null"}
|
||||
]
|
||||
},
|
||||
"playerIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"createdAt",
|
||||
"name"
|
||||
]
|
||||
}
|
||||
]
|
||||
"winnerId": {
|
||||
"anyOf": [
|
||||
{"type": "string"},
|
||||
{"type": "null"}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"createdAt",
|
||||
"groupId",
|
||||
"playerIds"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
"required": [
|
||||
"players",
|
||||
"groups",
|
||||
"matches"
|
||||
]
|
||||
}
|
||||
@@ -24,6 +24,11 @@
|
||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
<string>https</string>
|
||||
<string>http</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
@@ -44,4 +49,4 @@
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
</plist>
|
||||
@@ -1,4 +1,6 @@
|
||||
arb-dir: lib/l10n/arb
|
||||
template-arb-file: app_en.arb
|
||||
output-localization-file: app_localizations.dart
|
||||
output-dir: lib/l10n/generated
|
||||
output-dir: lib/l10n/generated
|
||||
nullable-getter: false
|
||||
untranslated-messages-file: lib/l10n/untranslated_messages.json
|
||||
19
lib/core/adaptive_page_route.dart
Normal file
19
lib/core/adaptive_page_route.dart
Normal 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,
|
||||
);
|
||||
}
|
||||
@@ -1,2 +1,6 @@
|
||||
/// Minimum duration of all app skeletons
|
||||
Duration minimumSkeletonDuration = const Duration(milliseconds: 250);
|
||||
class Constants {
|
||||
Constants._(); // Private constructor to prevent instantiation
|
||||
|
||||
/// Minimum duration of all app skeletons
|
||||
static Duration minimumSkeletonDuration = const Duration(milliseconds: 250);
|
||||
}
|
||||
|
||||
@@ -1,35 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CustomTheme {
|
||||
CustomTheme._(); // Private constructor to prevent instantiation
|
||||
|
||||
// ==================== Colors ====================
|
||||
static Color primaryColor = const Color(0xFF7505E4);
|
||||
static Color secondaryColor = const Color(0xFFAFA2FF);
|
||||
static Color backgroundColor = const Color(0xFF0B0B0B);
|
||||
static Color boxColor = const Color(0xFF101010);
|
||||
static Color onBoxColor = const Color(0xFF181818);
|
||||
static Color boxBorder = const Color(0xFF272727);
|
||||
static const Color textColor = Colors.white;
|
||||
|
||||
// ==================== 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(
|
||||
color: boxColor,
|
||||
border: Border.all(color: boxBorder),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: standardBorderRadiusAll,
|
||||
);
|
||||
|
||||
static BoxDecoration highlightedBoxDecoration = BoxDecoration(
|
||||
color: boxColor,
|
||||
border: Border.all(color: primaryColor),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: standardBorderRadiusAll,
|
||||
boxShadow: [BoxShadow(color: primaryColor.withAlpha(120), blurRadius: 12)],
|
||||
);
|
||||
|
||||
// ==================== App Bar Theme ====================
|
||||
static AppBarTheme appBarTheme = AppBarTheme(
|
||||
backgroundColor: backgroundColor,
|
||||
foregroundColor: Colors.white,
|
||||
foregroundColor: textColor,
|
||||
elevation: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
centerTitle: true,
|
||||
titleTextStyle: const TextStyle(
|
||||
color: Colors.white,
|
||||
color: textColor,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
iconTheme: const IconThemeData(color: Colors.white),
|
||||
iconTheme: const IconThemeData(color: textColor),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||
|
||||
/// 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 }
|
||||
|
||||
/// Result types for import operations in the [SettingsView]
|
||||
@@ -35,14 +38,15 @@ enum Ruleset { singleWinner, singleLoser, mostPoints, leastPoints }
|
||||
|
||||
/// Translates a [Ruleset] enum value to its corresponding localized string.
|
||||
String translateRulesetToString(Ruleset ruleset, BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
switch (ruleset) {
|
||||
case Ruleset.singleWinner:
|
||||
return AppLocalizations.of(context)!.single_winner;
|
||||
return loc.single_winner;
|
||||
case Ruleset.singleLoser:
|
||||
return AppLocalizations.of(context)!.single_loser;
|
||||
return loc.single_loser;
|
||||
case Ruleset.mostPoints:
|
||||
return AppLocalizations.of(context)!.most_points;
|
||||
return loc.most_points;
|
||||
case Ruleset.leastPoints:
|
||||
return AppLocalizations.of(context)!.least_points;
|
||||
return loc.least_points;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +95,8 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
|
||||
}
|
||||
|
||||
// Insert unique groups in batch
|
||||
// Using insertOrIgnore to avoid triggering cascade deletes on
|
||||
// player_group associations when groups already exist
|
||||
await db.batch(
|
||||
(b) => b.insertAll(
|
||||
groupTable,
|
||||
@@ -107,7 +109,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
mode: InsertMode.insertOrIgnore,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -120,6 +122,8 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
|
||||
}
|
||||
|
||||
if (uniquePlayers.isNotEmpty) {
|
||||
// Using insertOrIgnore to avoid triggering cascade deletes on
|
||||
// player_group associations when players already exist
|
||||
await db.batch(
|
||||
(b) => b.insertAll(
|
||||
db.playerTable,
|
||||
@@ -132,7 +136,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
mode: InsertMode.insertOrIgnore,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,6 +124,8 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
);
|
||||
|
||||
// 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(
|
||||
(b) => b.insertAll(
|
||||
db.groupTable,
|
||||
@@ -137,7 +139,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
mode: InsertMode.insertOrIgnore,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -158,6 +160,8 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
}
|
||||
|
||||
if (uniquePlayers.isNotEmpty) {
|
||||
// Using insertOrIgnore to avoid triggering cascade deletes on
|
||||
// player_group/player_match associations when players already exist
|
||||
await db.batch(
|
||||
(b) => b.insertAll(
|
||||
db.playerTable,
|
||||
@@ -170,7 +174,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
mode: InsertMode.insertOrIgnore,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
if (players.isEmpty) return false;
|
||||
|
||||
@@ -65,7 +67,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
mode: InsertMode.insertOrIgnore,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class Match {
|
||||
final String name;
|
||||
final List<Player>? players;
|
||||
final Group? group;
|
||||
final Player? winner;
|
||||
Player? winner;
|
||||
|
||||
Match({
|
||||
String? id,
|
||||
|
||||
@@ -1,84 +1,90 @@
|
||||
{
|
||||
"@@locale": "de",
|
||||
"choose_group": "Gruppe wählen",
|
||||
"create_new_match": "Neues Match erstellen",
|
||||
"choose_ruleset": "Regelwerk wählen",
|
||||
"choose_game": "Spiel wählen",
|
||||
"select_winner": "Gewinner wählen:",
|
||||
"no_recent_matches_available": "Keine letzten Matches verfügbar",
|
||||
"no_second_match_available": "Kein zweites Match verfügbar",
|
||||
"delete_all_data": "Alle Daten löschen?",
|
||||
"all_players": "Alle Spieler:innen",
|
||||
"all_players_selected": "Alle Spieler:innen ausgewählt",
|
||||
"amount_of_matches": "Anzahl der Spiele",
|
||||
"app_name": "Game Tracker",
|
||||
"cancel": "Abbrechen",
|
||||
"delete": "Löschen",
|
||||
"create_new_group": "Neue Gruppe erstellen",
|
||||
"error_while_creating_group_please_try_again": "Fehler beim Erstellen der Gruppe, bitte erneut versuchen",
|
||||
"selected_players": "Ausgewählte Spieler: {count}",
|
||||
"no_players_selected": "Keine Spieler ausgewählt",
|
||||
"all_players": "Alle Spieler:",
|
||||
"successfully_added_player": "Spieler {playerName} erfolgreich hinzugefügt.",
|
||||
"could_not_add_player": "Spieler {playerName} konnte nicht hinzugefügt werden.",
|
||||
"winner": "Gewinner: {winnerName}",
|
||||
"players": "Spieler",
|
||||
"player_name": "Spielername",
|
||||
"no_data_available": "Keine Daten verfügbar.",
|
||||
"matches": "Matches",
|
||||
"groups": "Gruppen",
|
||||
"recent_matches": "Letzte Matches",
|
||||
"quick_create": "Schnellzugriff",
|
||||
"winner_label": "Gewinner",
|
||||
"ruleset_label": "Regelwerk",
|
||||
"match_in_progress": "Match läuft...",
|
||||
"menu": "Menü",
|
||||
"settings": "Einstellungen",
|
||||
"export_data": "Daten exportieren",
|
||||
"import_data": "Daten importieren",
|
||||
"this_cannot_be_undone": "Dies kann nicht rückgängig gemacht werden",
|
||||
"data_successfully_deleted": "Daten erfolgreich gelöscht",
|
||||
"data_successfully_imported": "Daten erfolgreich importiert",
|
||||
"invalid_schema": "Ungültiges Schema",
|
||||
"error_reading_file": "Fehler beim Lesen der Datei",
|
||||
"import_canceled": "Import abgebrochen",
|
||||
"format_exception": "Formatfehler (siehe Konsole)",
|
||||
"unknown_exception": "Unbekannter Fehler (siehe Konsole)",
|
||||
"data_successfully_exported": "Daten erfolgreich exportiert",
|
||||
"export_canceled": "Export abgebrochen",
|
||||
"undo": "Rückgängig",
|
||||
"wins": "Siege",
|
||||
"winrate": "Siegquote",
|
||||
"amount_of_matches": "Anzahl der Matches",
|
||||
"info": "Info",
|
||||
"no_groups_created_yet": "Noch keine Gruppen erstellt",
|
||||
"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",
|
||||
"group_name": "Gruppenname",
|
||||
"no_matches_created_yet": "Noch keine Matches erstellt",
|
||||
"create_game": "Match erstellen",
|
||||
"match_name": "Matchname",
|
||||
"game": "Spiel",
|
||||
"ruleset": "Regelwerk",
|
||||
"group": "Gruppe",
|
||||
"none": "Keine",
|
||||
"create_match": "Match erstellen",
|
||||
"search_for_players": "Nach Spielern suchen",
|
||||
"search_for_groups": "Nach Gruppen suchen",
|
||||
"no_players_created_yet": "Noch keine Spieler erstellt",
|
||||
"all_players_selected": "Alle Spieler ausgewählt",
|
||||
"no_players_found_with_that_name": "Keine Spieler mit diesem Namen gefunden",
|
||||
"today_at": "Heute um {time}",
|
||||
"yesterday_at": "Gestern um {time}",
|
||||
"create_match": "Spiel erstellen",
|
||||
"create_new_group": "Neue Gruppe erstellen",
|
||||
"create_new_match": "Neues Spiel erstellen",
|
||||
"data": "Daten",
|
||||
"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",
|
||||
"legal": "Rechtliches",
|
||||
"legal_notice": "Impressum",
|
||||
"licenses": "Lizenzen",
|
||||
"match_in_progress": "Spiel läuft...",
|
||||
"match_name": "Spieltitel",
|
||||
"matches": "Spiele",
|
||||
"most_points": "Höchste Punkte",
|
||||
"no_data_available": "Keine Daten verfügbar",
|
||||
"no_groups_created_yet": "Noch keine Gruppen erstellt",
|
||||
"no_licenses_found": "Keine Lizenzen gefunden",
|
||||
"no_license_text_available": "Kein Lizenztext verfügbar",
|
||||
"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",
|
||||
"privacy_policy": "Datenschutzerklärung",
|
||||
"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",
|
||||
"players_count": "{count} Spieler",
|
||||
"you_have_no_groups_created_yet": "Du hast noch keine Gruppen erstellt",
|
||||
"successfully_added_player": "Spieler:in {playerName} erfolgreich hinzugefügt",
|
||||
"there_is_no_group_matching_your_search": "Es gibt keine Gruppe, die deiner Suche entspricht",
|
||||
"game_name": "Spielname",
|
||||
"ruleset_single_winner_desc": "Genau ein Gewinner wird gewählt; Unentschieden werden durch einen vordefinierten Tie-Breaker aufgelöst.",
|
||||
"ruleset_single_loser_desc": "Genau ein Verlierer wird bestimmt; der letzte Platz erhält die Strafe oder Konsequenz.",
|
||||
"ruleset_most_points_desc": "Traditionelles Regelwerk: Der Spieler mit den meisten Punkten gewinnt.",
|
||||
"ruleset_least_points_desc": "Umgekehrte Wertung: Der Spieler mit den wenigsten Punkten gewinnt.",
|
||||
"single_winner": "Ein Gewinner",
|
||||
"single_loser": "Ein Verlierer",
|
||||
"most_points": "Höchste Punkte",
|
||||
"least_points": "Niedrigste Punkte"
|
||||
}
|
||||
"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"
|
||||
}
|
||||
@@ -1,72 +1,246 @@
|
||||
{
|
||||
"@@locale": "en",
|
||||
"choose_group": "Choose Group",
|
||||
"@choose_group": {
|
||||
"description": "Label for choosing a group"
|
||||
},
|
||||
"create_new_match": "Create new match",
|
||||
"@create_new_match": {
|
||||
"description": "Button text to create a new match"
|
||||
},
|
||||
"choose_ruleset": "Choose Ruleset",
|
||||
"@choose_ruleset": {
|
||||
"description": "Label for choosing a ruleset"
|
||||
},
|
||||
"choose_game": "Choose Game",
|
||||
"@choose_game": {
|
||||
"description": "Label for choosing a game"
|
||||
},
|
||||
"select_winner": "Select Winner:",
|
||||
"@select_winner": {
|
||||
"description": "Label to select the winner"
|
||||
},
|
||||
"no_recent_matches_available": "No recent matches available",
|
||||
"@no_recent_matches_available": {
|
||||
"description": "Message when no recent matches exist"
|
||||
},
|
||||
"no_second_match_available": "No second match available",
|
||||
"@no_second_matcb_available": {
|
||||
"description": "Message when no second match exists"
|
||||
},
|
||||
"delete_all_data": "Delete all data?",
|
||||
"@delete_all_data": {
|
||||
"description": "Confirmation dialog for deleting all data"
|
||||
},
|
||||
"cancel": "Cancel",
|
||||
"@cancel": {
|
||||
"description": "Cancel button text"
|
||||
},
|
||||
"delete": "Delete",
|
||||
"@delete": {
|
||||
"description": "Delete button text"
|
||||
},
|
||||
"create_new_group": "Create new group",
|
||||
"@create_new_group": {
|
||||
"description": "Button text to create a new group"
|
||||
},
|
||||
"error_while_creating_group_please_try_again": "Error while creating group, please try again",
|
||||
"@error_while_creating_group_please_try_again": {
|
||||
"description": "Error message when group creation fails"
|
||||
},
|
||||
"selected_players": "Selected players: {count}",
|
||||
"@selected_players": {
|
||||
"description": "Shows the number of selected players",
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"type": "int",
|
||||
"format": "compact"
|
||||
}
|
||||
}
|
||||
},
|
||||
"no_players_selected": "No players selected",
|
||||
"@no_players_selected": {
|
||||
"description": "Message when no players are selected"
|
||||
},
|
||||
"all_players": "All players:",
|
||||
"@all_players": {
|
||||
"description": "Label for all players list"
|
||||
},
|
||||
"successfully_added_player": "Successfully added player {playerName}.",
|
||||
"@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": {
|
||||
"description": "Data label"
|
||||
},
|
||||
"@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"
|
||||
},
|
||||
"@legal": {
|
||||
"description": "Legal section header"
|
||||
},
|
||||
"@legal_notice": {
|
||||
"description": "Legal notice menu item"
|
||||
},
|
||||
"@licenses": {
|
||||
"description": "Licenses menu item"
|
||||
},
|
||||
"@match_in_progress": {
|
||||
"description": "Message when match is in progress"
|
||||
},
|
||||
"@match_name": {
|
||||
"description": "Placeholder for match name input"
|
||||
},
|
||||
"@matches": {
|
||||
"description": "Label for matches"
|
||||
},
|
||||
"@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_licenses_found": {
|
||||
"description": "Message when no licenses are found"
|
||||
},
|
||||
"@no_license_text_available": {
|
||||
"description": "Message when no license text is available"
|
||||
},
|
||||
"@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"
|
||||
}
|
||||
}
|
||||
},
|
||||
"@privacy_policy": {
|
||||
"description": "Privacy policy menu item"
|
||||
},
|
||||
"@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": "Label for the App Settings"
|
||||
},
|
||||
"@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": {
|
||||
@@ -76,282 +250,118 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"could_not_add_player": "Could not add player {playerName}.",
|
||||
"@could_not_add_player": {
|
||||
"description": "Error message when adding a player fails",
|
||||
"placeholders": {
|
||||
"playerName": {
|
||||
"type": "String",
|
||||
"example": "John"
|
||||
}
|
||||
}
|
||||
},
|
||||
"winner": "Winner: {winnerName}",
|
||||
"@winner": {
|
||||
"description": "Shows the winner's name",
|
||||
"placeholders": {
|
||||
"winnerName": {
|
||||
"type": "String",
|
||||
"example": "John"
|
||||
}
|
||||
}
|
||||
},
|
||||
"players": "Players",
|
||||
"@players": {
|
||||
"description": "Players label"
|
||||
},
|
||||
"no_data_available": "No data available.",
|
||||
"@no_data_available": {
|
||||
"description": "Message when no data is available"
|
||||
},
|
||||
"matches": "Matches",
|
||||
"@matches": {
|
||||
"description": "Label for matches"
|
||||
},
|
||||
"groups": "Groups",
|
||||
"@groups": {
|
||||
"description": "Label for groups"
|
||||
},
|
||||
"recent_matches": "Recent Matches",
|
||||
"@recent_matches": {
|
||||
"description": "Title for recent matches section"
|
||||
},
|
||||
"quick_create": "Quick Create",
|
||||
"@quick_create": {
|
||||
"description": "Title for quick create section"
|
||||
},
|
||||
"winner_label": "Winner",
|
||||
"@winner_label": {
|
||||
"description": "Label for winner field"
|
||||
},
|
||||
"ruleset_label": "Ruleset",
|
||||
"@ruleset_label": {
|
||||
"description": "Label for ruleset field"
|
||||
},
|
||||
"match_in_progress": "Match in progress...",
|
||||
"@match_in_progress": {
|
||||
"description": "Message when match is in progress"
|
||||
},
|
||||
"menu": "Menu",
|
||||
"@menu": {
|
||||
"description": "Menu label"
|
||||
},
|
||||
"settings": "Settings",
|
||||
"@settings": {
|
||||
"description": "Settings label"
|
||||
},
|
||||
"export_data": "Export data",
|
||||
"@export_data": {
|
||||
"description": "Export data menu item"
|
||||
},
|
||||
"import_data": "Import data",
|
||||
"@import_data": {
|
||||
"description": "Import data menu item"
|
||||
},
|
||||
"this_cannot_be_undone": "This can't be undone",
|
||||
"@this_cannot_be_undone": {
|
||||
"description": "Warning message for irreversible actions"
|
||||
},
|
||||
"data_successfully_deleted": "Data successfully deleted",
|
||||
"@data_successfully_deleted": {
|
||||
"description": "Success message after deleting data"
|
||||
},
|
||||
"data_successfully_imported": "Data successfully imported",
|
||||
"@data_successfully_imported": {
|
||||
"description": "Success message after importing data"
|
||||
},
|
||||
"invalid_schema": "Invalid Schema",
|
||||
"@invalid_schema": {
|
||||
"description": "Error message for invalid schema"
|
||||
},
|
||||
"error_reading_file": "Error reading file",
|
||||
"@error_reading_file": {
|
||||
"description": "Error message when file cannot be read"
|
||||
},
|
||||
"import_canceled": "Import canceled",
|
||||
"@import_canceled": {
|
||||
"description": "Message when import is canceled"
|
||||
},
|
||||
"format_exception": "Format Exception (see console)",
|
||||
"@format_exception": {
|
||||
"description": "Error message for format exceptions"
|
||||
},
|
||||
"unknown_exception": "Unknown Exception (see console)",
|
||||
"@unknown_exception": {
|
||||
"description": "Error message for unknown exceptions"
|
||||
},
|
||||
"data_successfully_exported": "Data successfully exported",
|
||||
"@data_successfully_exported": {
|
||||
"description": "Success message after exporting data"
|
||||
},
|
||||
"export_canceled": "Export canceled",
|
||||
"@export_canceled": {
|
||||
"description": "Message when export is canceled"
|
||||
},
|
||||
"undo": "Undo",
|
||||
"@undo": {
|
||||
"description": "Undo button text"
|
||||
},
|
||||
"wins": "Wins",
|
||||
"@wins": {
|
||||
"description": "Label for wins statistic"
|
||||
},
|
||||
"winrate": "Winrate",
|
||||
"@winrate": {
|
||||
"description": "Label for winrate statistic"
|
||||
},
|
||||
"amount_of_matches": "Amount of Matches",
|
||||
"@amount_of_matches": {
|
||||
"description": "Label for amount of matches statistic"
|
||||
},
|
||||
"info": "Info",
|
||||
"@info": {
|
||||
"description": "Info label"
|
||||
},
|
||||
"no_groups_created_yet": "No groups created yet",
|
||||
"@no_groups_created_yet": {
|
||||
"description": "Message when no groups exist"
|
||||
},
|
||||
"no_players_created_yet": "No players created yet",
|
||||
"@no_players_created_yet": {
|
||||
"description": "Message when no players exist"
|
||||
},
|
||||
"create_group": "Create Group",
|
||||
"@create_group": {
|
||||
"description": "Button text to create a group"
|
||||
},
|
||||
"group_name": "Group name",
|
||||
"@group_name": {
|
||||
"description": "Placeholder for group name input"
|
||||
},
|
||||
"player_name": "Player name",
|
||||
"@player_name": {
|
||||
"description": "Placeholder for player name input"
|
||||
},
|
||||
"no_matches_created_yet": "No matches created yet",
|
||||
"@no_matches_created_yet": {
|
||||
"description": "Message when no matches exist"
|
||||
},
|
||||
"match_name": "Match name",
|
||||
"@match_name": {
|
||||
"description": "Placeholder for match name input"
|
||||
},
|
||||
"game": "Game",
|
||||
"@game": {
|
||||
"description": "Game label"
|
||||
},
|
||||
"ruleset": "Ruleset",
|
||||
"@ruleset": {
|
||||
"description": "Ruleset label"
|
||||
},
|
||||
"group": "Group",
|
||||
"@group": {
|
||||
"description": "Group label"
|
||||
},
|
||||
"none": "None",
|
||||
"@none": {
|
||||
"description": "None option label"
|
||||
},
|
||||
"create_match": "Create match",
|
||||
"@create_match": {
|
||||
"description": "Button text to create a match"
|
||||
},
|
||||
"no_players_found_with_that_name": "No players found with that name",
|
||||
"@no_players_found_with_that_name": {
|
||||
"description": "Message when search returns no results"
|
||||
},
|
||||
"all_players_selected": "All players selected",
|
||||
"@all_players_selected": {
|
||||
"description": "Message when all players are added to selection"
|
||||
},
|
||||
"today_at": "Today at {time}",
|
||||
"@today_at": {
|
||||
"description": "Date format for today",
|
||||
"placeholders": {
|
||||
"time": {
|
||||
"type": "String",
|
||||
"example": "14:30"
|
||||
}
|
||||
}
|
||||
},
|
||||
"yesterday_at": "Yesterday at {time}",
|
||||
"@yesterday_at": {
|
||||
"description": "Date format for yesterday",
|
||||
"placeholders": {
|
||||
"time": {
|
||||
"type": "String",
|
||||
"example": "14:30"
|
||||
}
|
||||
}
|
||||
},
|
||||
"days_ago": "{count} days ago",
|
||||
"@days_ago": {
|
||||
"description": "Date format for days ago",
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
},
|
||||
"home": "Home",
|
||||
"@home": {
|
||||
"description": "Home tab label"
|
||||
},
|
||||
"statistics": "Statistics",
|
||||
"@statistics": {
|
||||
"description": "Statistics tab label"
|
||||
},
|
||||
"stats": "Stats",
|
||||
"@stats": {
|
||||
"description": "Stats tab label (short)"
|
||||
},
|
||||
"players_count": "{count} Players",
|
||||
"@players_count": {
|
||||
"description": "Shows the number of players",
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
},
|
||||
"there_is_no_group_matching_your_search": "There is no group matching your search",
|
||||
"@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": "Data",
|
||||
"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",
|
||||
"@game_name": {
|
||||
"description": "Placeholder for game name search"
|
||||
},
|
||||
"ruleset_single_winner_desc": "Exactly one winner is chosen; ties are resolved by a predefined tiebreaker.",
|
||||
"@ruleset_single_winner_desc": {
|
||||
"description": "Description for single winner ruleset"
|
||||
},
|
||||
"ruleset_single_loser_desc": "Exactly one loser is determined; last place receives the penalty or consequence.",
|
||||
"@ruleset_single_loser_desc": {
|
||||
"description": "Description for single loser ruleset"
|
||||
},
|
||||
"ruleset_most_points_desc": "Traditional ruleset: the player with the most points wins.",
|
||||
"@ruleset_most_points_desc": {
|
||||
"description": "Description for most points ruleset"
|
||||
},
|
||||
"ruleset_least_points_desc": "Inverse scoring: the player with the fewest points wins.",
|
||||
"@ruleset_least_points_desc": {
|
||||
"description": "Description for least points ruleset"
|
||||
},
|
||||
"single_winner": "Single Winner",
|
||||
"@single_winner": {
|
||||
"description": "Title for single winner ruleset"
|
||||
},
|
||||
"single_loser": "Single Loser",
|
||||
"@single_loser": {
|
||||
"description": "Title for single loser ruleset"
|
||||
},
|
||||
"most_points": "Most Points",
|
||||
"@most_points": {
|
||||
"description": "Title for most points ruleset"
|
||||
},
|
||||
"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",
|
||||
"@least_points": {
|
||||
"description": "Title for least points ruleset"
|
||||
}
|
||||
}
|
||||
"legal": "Legal",
|
||||
"legal_notice": "Legal Notice",
|
||||
"licenses": "Licenses",
|
||||
"match_in_progress": "Match in progress...",
|
||||
"match_name": "Match name",
|
||||
"matches": "Matches",
|
||||
"most_points": "Most Points",
|
||||
"no_data_available": "No data available",
|
||||
"no_groups_created_yet": "No groups created yet",
|
||||
"no_licenses_found": "No licenses found",
|
||||
"no_license_text_available": "No license text available",
|
||||
"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",
|
||||
"privacy_policy": "Privacy Policy",
|
||||
"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"
|
||||
}
|
||||
656
lib/l10n/generated/app_localizations.dart
Normal file
656
lib/l10n/generated/app_localizations.dart
Normal file
@@ -0,0 +1,656 @@
|
||||
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, you’ll need to edit this
|
||||
/// file.
|
||||
///
|
||||
/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file.
|
||||
/// Then, in the Project Navigator, open the Info.plist file under the Runner
|
||||
/// project’s 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;
|
||||
|
||||
/// Data label
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Data'**
|
||||
String get data;
|
||||
|
||||
/// 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;
|
||||
|
||||
/// Legal section header
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Legal'**
|
||||
String get legal;
|
||||
|
||||
/// Legal notice menu item
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Legal Notice'**
|
||||
String get legal_notice;
|
||||
|
||||
/// Licenses menu item
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Licenses'**
|
||||
String get licenses;
|
||||
|
||||
/// 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;
|
||||
|
||||
/// 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 licenses are found
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'No licenses found'**
|
||||
String get no_licenses_found;
|
||||
|
||||
/// Message when no license text is available
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'No license text available'**
|
||||
String get no_license_text_available;
|
||||
|
||||
/// 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);
|
||||
|
||||
/// Privacy policy menu item
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Privacy Policy'**
|
||||
String get privacy_policy;
|
||||
|
||||
/// 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;
|
||||
|
||||
/// Label for the App Settings
|
||||
///
|
||||
/// 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.',
|
||||
);
|
||||
}
|
||||
287
lib/l10n/generated/app_localizations_de.dart
Normal file
287
lib/l10n/generated/app_localizations_de.dart
Normal file
@@ -0,0 +1,287 @@
|
||||
// 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 => 'Daten';
|
||||
|
||||
@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 legal => 'Rechtliches';
|
||||
|
||||
@override
|
||||
String get legal_notice => 'Impressum';
|
||||
|
||||
@override
|
||||
String get licenses => 'Lizenzen';
|
||||
|
||||
@override
|
||||
String get match_in_progress => 'Spiel läuft...';
|
||||
|
||||
@override
|
||||
String get match_name => 'Spieltitel';
|
||||
|
||||
@override
|
||||
String get matches => 'Spiele';
|
||||
|
||||
@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_licenses_found => 'Keine Lizenzen gefunden';
|
||||
|
||||
@override
|
||||
String get no_license_text_available => 'Kein Lizenztext verfügbar';
|
||||
|
||||
@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 privacy_policy => 'Datenschutzerklärung';
|
||||
|
||||
@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';
|
||||
}
|
||||
286
lib/l10n/generated/app_localizations_en.dart
Normal file
286
lib/l10n/generated/app_localizations_en.dart
Normal file
@@ -0,0 +1,286 @@
|
||||
// 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 => 'Data';
|
||||
|
||||
@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 legal => 'Legal';
|
||||
|
||||
@override
|
||||
String get legal_notice => 'Legal Notice';
|
||||
|
||||
@override
|
||||
String get licenses => 'Licenses';
|
||||
|
||||
@override
|
||||
String get match_in_progress => 'Match in progress...';
|
||||
|
||||
@override
|
||||
String get match_name => 'Match name';
|
||||
|
||||
@override
|
||||
String get matches => 'Matches';
|
||||
|
||||
@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_licenses_found => 'No licenses found';
|
||||
|
||||
@override
|
||||
String get no_license_text_available => 'No license text available';
|
||||
|
||||
@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 privacy_policy => 'Privacy Policy';
|
||||
|
||||
@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';
|
||||
}
|
||||
@@ -23,22 +23,34 @@ class GameTracker extends StatelessWidget {
|
||||
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,
|
||||
title: 'Game Tracker',
|
||||
darkTheme: ThemeData.dark(),
|
||||
|
||||
onGenerateTitle: (context) => AppLocalizations.of(context).app_name,
|
||||
themeMode: ThemeMode.dark, // forces dark mode
|
||||
theme: ThemeData(
|
||||
primaryColor: CustomTheme.primaryColor,
|
||||
scaffoldBackgroundColor: CustomTheme.backgroundColor,
|
||||
appBarTheme: CustomTheme.appBarTheme,
|
||||
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: CustomTheme.primaryColor,
|
||||
brightness: Brightness.dark,
|
||||
).copyWith(surface: CustomTheme.backgroundColor),
|
||||
pageTransitionsTheme: const PageTransitionsTheme(
|
||||
builders: {
|
||||
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
|
||||
TargetPlatform.android: PredictiveBackPageTransitionsBuilder(),
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
home: const CustomNavigationBar(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
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/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/home_view.dart';
|
||||
import 'package:game_tracker/presentation/views/main_menu/match_view/match_view.dart';
|
||||
import 'package:game_tracker/presentation/views/main_menu/settings_view.dart';
|
||||
import 'package:game_tracker/presentation/views/main_menu/settings_view/settings_view.dart';
|
||||
import 'package:game_tracker/presentation/views/main_menu/statistics_view.dart';
|
||||
import 'package:game_tracker/presentation/widgets/navbar_item.dart';
|
||||
|
||||
@@ -17,16 +18,15 @@ class CustomNavigationBar extends StatefulWidget {
|
||||
|
||||
class _CustomNavigationBarState extends State<CustomNavigationBar>
|
||||
with SingleTickerProviderStateMixin {
|
||||
/// Currently selected tab index
|
||||
int currentIndex = 0;
|
||||
|
||||
/// Key count to force rebuild of tab views
|
||||
int tabKeyCount = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
// Pretty ugly but works
|
||||
final List<Widget> tabs = [
|
||||
KeyedSubtree(key: ValueKey('home_$tabKeyCount'), child: const HomeView()),
|
||||
@@ -47,7 +47,7 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text(
|
||||
_currentTabTitle(),
|
||||
_currentTabTitle(context),
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
@@ -57,7 +57,7 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
|
||||
onPressed: () async {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const SettingsView()),
|
||||
adaptivePageRoute(builder: (_) => const SettingsView()),
|
||||
);
|
||||
setState(() {
|
||||
tabKeyCount++;
|
||||
@@ -90,28 +90,28 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
|
||||
index: 0,
|
||||
isSelected: currentIndex == 0,
|
||||
icon: Icons.home_rounded,
|
||||
label: AppLocalizations.of(context)!.home,
|
||||
label: loc.home,
|
||||
onTabTapped: onTabTapped,
|
||||
),
|
||||
NavbarItem(
|
||||
index: 1,
|
||||
isSelected: currentIndex == 1,
|
||||
icon: Icons.gamepad_rounded,
|
||||
label: AppLocalizations.of(context)!.matches,
|
||||
label: loc.matches,
|
||||
onTabTapped: onTabTapped,
|
||||
),
|
||||
NavbarItem(
|
||||
index: 2,
|
||||
isSelected: currentIndex == 2,
|
||||
icon: Icons.group_rounded,
|
||||
label: AppLocalizations.of(context)!.groups,
|
||||
label: loc.groups,
|
||||
onTabTapped: onTabTapped,
|
||||
),
|
||||
NavbarItem(
|
||||
index: 3,
|
||||
isSelected: currentIndex == 3,
|
||||
icon: Icons.bar_chart_rounded,
|
||||
label: AppLocalizations.of(context)!.statistics,
|
||||
label: loc.statistics,
|
||||
onTabTapped: onTabTapped,
|
||||
),
|
||||
],
|
||||
@@ -123,22 +123,25 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
|
||||
);
|
||||
}
|
||||
|
||||
/// Handles tab tap events. Updates the current [index] state.
|
||||
void onTabTapped(int index) {
|
||||
setState(() {
|
||||
currentIndex = index;
|
||||
});
|
||||
}
|
||||
|
||||
String _currentTabTitle() {
|
||||
/// Returns the title of the current tab based on [currentIndex].
|
||||
String _currentTabTitle(context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
switch (currentIndex) {
|
||||
case 0:
|
||||
return AppLocalizations.of(context)!.home;
|
||||
return loc.home;
|
||||
case 1:
|
||||
return AppLocalizations.of(context)!.matches;
|
||||
return loc.matches;
|
||||
case 2:
|
||||
return AppLocalizations.of(context)!.groups;
|
||||
return loc.groups;
|
||||
case 3:
|
||||
return AppLocalizations.of(context)!.statistics;
|
||||
return loc.statistics;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -18,8 +18,12 @@ class CreateGroupView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CreateGroupViewState extends State<CreateGroupView> {
|
||||
final _groupNameController = TextEditingController();
|
||||
late final AppDatabase db;
|
||||
|
||||
/// Controller for the group name input field
|
||||
final _groupNameController = TextEditingController();
|
||||
|
||||
/// List of currently selected players
|
||||
List<Player> selectedPlayers = [];
|
||||
|
||||
@override
|
||||
@@ -39,78 +43,69 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
appBar: AppBar(
|
||||
final loc = AppLocalizations.of(context);
|
||||
return ScaffoldMessenger(
|
||||
child: Scaffold(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
scrolledUnderElevation: 0,
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.create_new_group,
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
child: TextInputField(
|
||||
controller: _groupNameController,
|
||||
hintText: AppLocalizations.of(context)!.group_name,
|
||||
onChanged: (value) {
|
||||
setState(() {});
|
||||
},
|
||||
appBar: AppBar(title: Text(loc.create_new_group)),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: CustomTheme.standardMargin,
|
||||
child: TextInputField(
|
||||
controller: _groupNameController,
|
||||
hintText: loc.group_name,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: PlayerSelection(
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectedPlayers = [...value];
|
||||
});
|
||||
},
|
||||
Expanded(
|
||||
child: PlayerSelection(
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectedPlayers = [...value];
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
CustomWidthButton(
|
||||
text: AppLocalizations.of(context)!.create_group,
|
||||
sizeRelativeToWidth: 0.95,
|
||||
buttonType: ButtonType.primary,
|
||||
onPressed:
|
||||
(_groupNameController.text.isEmpty ||
|
||||
(selectedPlayers.length < 2))
|
||||
? null
|
||||
: () async {
|
||||
bool success = await db.groupDao.addGroup(
|
||||
group: Group(
|
||||
name: _groupNameController.text.trim(),
|
||||
members: selectedPlayers,
|
||||
),
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
if (success) {
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: CustomTheme.boxColor,
|
||||
content: Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
)!.error_while_creating_group_please_try_again,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
CustomWidthButton(
|
||||
text: loc.create_group,
|
||||
sizeRelativeToWidth: 0.95,
|
||||
buttonType: ButtonType.primary,
|
||||
onPressed:
|
||||
(_groupNameController.text.isEmpty ||
|
||||
(selectedPlayers.length < 2))
|
||||
? null
|
||||
: () async {
|
||||
bool success = await db.groupDao.addGroup(
|
||||
group: Group(
|
||||
name: _groupNameController.text.trim(),
|
||||
members: selectedPlayers,
|
||||
),
|
||||
);
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
if (!context.mounted) return;
|
||||
if (success) {
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: CustomTheme.boxColor,
|
||||
content: Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).error_creating_group,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
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/custom_theme.dart';
|
||||
import 'package:game_tracker/data/db/database.dart';
|
||||
@@ -21,7 +22,11 @@ class GroupsView extends StatefulWidget {
|
||||
|
||||
class _GroupsViewState extends State<GroupsView> {
|
||||
late final AppDatabase db;
|
||||
|
||||
/// Loaded groups from the database
|
||||
late List<Group> loadedGroups;
|
||||
|
||||
/// Loading state
|
||||
bool isLoading = true;
|
||||
|
||||
List<Group> groups = List.filled(
|
||||
@@ -35,12 +40,14 @@ class _GroupsViewState extends State<GroupsView> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
db = Provider.of<AppDatabase>(context, listen: false);
|
||||
loadGroups();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Scaffold(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
body: Stack(
|
||||
@@ -53,8 +60,8 @@ class _GroupsViewState extends State<GroupsView> {
|
||||
replacement: Center(
|
||||
child: TopCenteredMessage(
|
||||
icon: Icons.info,
|
||||
title: AppLocalizations.of(context)!.info,
|
||||
message: AppLocalizations.of(context)!.no_groups_created_yet,
|
||||
title: loc.info,
|
||||
message: loc.no_groups_created_yet,
|
||||
),
|
||||
),
|
||||
child: ListView.builder(
|
||||
@@ -74,12 +81,12 @@ class _GroupsViewState extends State<GroupsView> {
|
||||
Positioned(
|
||||
bottom: MediaQuery.paddingOf(context).bottom,
|
||||
child: CustomWidthButton(
|
||||
text: AppLocalizations.of(context)!.create_group,
|
||||
text: loc.create_group,
|
||||
sizeRelativeToWidth: 0.90,
|
||||
onPressed: () async {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
adaptivePageRoute(
|
||||
builder: (context) {
|
||||
return const CreateGroupView();
|
||||
},
|
||||
@@ -99,7 +106,7 @@ class _GroupsViewState extends State<GroupsView> {
|
||||
void loadGroups() {
|
||||
Future.wait([
|
||||
db.groupDao.getAllGroups(),
|
||||
Future.delayed(minimumSkeletonDuration),
|
||||
Future.delayed(Constants.minimumSkeletonDuration),
|
||||
]).then((results) {
|
||||
loadedGroups = results[0] as List<Group>;
|
||||
setState(() {
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
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/data/db/database.dart';
|
||||
import 'package:game_tracker/data/dto/group.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/views/main_menu/match_view/match_result_view.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/tiles/game_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:provider/provider.dart';
|
||||
|
||||
@@ -21,9 +23,17 @@ class HomeView extends StatefulWidget {
|
||||
|
||||
class _HomeViewState extends State<HomeView> {
|
||||
bool isLoading = true;
|
||||
|
||||
/// Amount of matches in the database
|
||||
int matchCount = 0;
|
||||
|
||||
/// Amount of groups in the database
|
||||
int groupCount = 0;
|
||||
|
||||
/// Loaded recent matches from the database
|
||||
List<Match> loadedRecentMatches = [];
|
||||
|
||||
/// Recent matches to display, initially filled with skeleton matches
|
||||
List<Match> recentMatches = List.filled(
|
||||
2,
|
||||
Match(
|
||||
@@ -35,43 +45,18 @@ class _HomeViewState extends State<HomeView> {
|
||||
Player(name: 'Skeleton Player 2'),
|
||||
],
|
||||
),
|
||||
winner: Player(name: 'Skeleton Player 1'),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final db = Provider.of<AppDatabase>(context, listen: false);
|
||||
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;
|
||||
});
|
||||
}
|
||||
});
|
||||
loadHomeViewData();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
return AppSkeleton(
|
||||
@@ -87,7 +72,7 @@ class _HomeViewState extends State<HomeView> {
|
||||
QuickInfoTile(
|
||||
width: constraints.maxWidth * 0.45,
|
||||
height: constraints.maxHeight * 0.15,
|
||||
title: AppLocalizations.of(context)!.matches,
|
||||
title: loc.matches,
|
||||
icon: Icons.groups_rounded,
|
||||
value: matchCount,
|
||||
),
|
||||
@@ -95,7 +80,7 @@ class _HomeViewState extends State<HomeView> {
|
||||
QuickInfoTile(
|
||||
width: constraints.maxWidth * 0.45,
|
||||
height: constraints.maxHeight * 0.15,
|
||||
title: AppLocalizations.of(context)!.groups,
|
||||
title: loc.groups,
|
||||
icon: Icons.groups_rounded,
|
||||
value: groupCount,
|
||||
),
|
||||
@@ -105,122 +90,93 @@ class _HomeViewState extends State<HomeView> {
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: InfoTile(
|
||||
width: constraints.maxWidth * 0.95,
|
||||
title: AppLocalizations.of(context)!.recent_matches,
|
||||
icon: Icons.timer,
|
||||
content: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 40.0),
|
||||
child: Visibility(
|
||||
visible: !isLoading && loadedRecentMatches.isNotEmpty,
|
||||
replacement: Center(
|
||||
heightFactor: 12,
|
||||
child: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
)!.no_recent_matches_available,
|
||||
title: loc.recent_matches,
|
||||
icon: Icons.history_rounded,
|
||||
content: Column(
|
||||
children: [
|
||||
if (recentMatches.isNotEmpty)
|
||||
for (Match match in recentMatches)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 6.0,
|
||||
),
|
||||
child: MatchTile(
|
||||
compact: true,
|
||||
width: constraints.maxWidth * 0.9,
|
||||
match: match,
|
||||
onTap: () async {
|
||||
await Navigator.of(context).push(
|
||||
adaptivePageRoute(
|
||||
fullscreenDialog: true,
|
||||
builder: (context) =>
|
||||
MatchResultView(match: match),
|
||||
),
|
||||
);
|
||||
await updatedWinnerinRecentMatches(match.id);
|
||||
},
|
||||
),
|
||||
)
|
||||
else
|
||||
Center(
|
||||
heightFactor: 5,
|
||||
child: Text(loc.no_recent_matches_available),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
MatchTile(
|
||||
matchTitle: recentMatches[0].name,
|
||||
game: AppLocalizations.of(context)!.winner_label,
|
||||
ruleset: AppLocalizations.of(
|
||||
context,
|
||||
)!.ruleset_label,
|
||||
players: _getPlayerText(recentMatches[0]),
|
||||
winner: recentMatches[0].winner == null
|
||||
? AppLocalizations.of(
|
||||
context,
|
||||
)!.match_in_progress
|
||||
: recentMatches[0].winner!.name,
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Divider(),
|
||||
),
|
||||
if (loadedRecentMatches.length > 1) ...[
|
||||
MatchTile(
|
||||
matchTitle: recentMatches[1].name,
|
||||
game: AppLocalizations.of(
|
||||
context,
|
||||
)!.winner_label,
|
||||
ruleset: AppLocalizations.of(
|
||||
context,
|
||||
)!.ruleset_label,
|
||||
players: _getPlayerText(recentMatches[1]),
|
||||
winner: recentMatches[1].winner == null
|
||||
? AppLocalizations.of(
|
||||
context,
|
||||
)!.match_in_progress
|
||||
: recentMatches[1].winner!.name,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
] else ...[
|
||||
Center(
|
||||
heightFactor: 5.35,
|
||||
child: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
)!.no_second_match_available,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
InfoTile(
|
||||
width: constraints.maxWidth * 0.95,
|
||||
title: AppLocalizations.of(context)!.quick_create,
|
||||
icon: Icons.add_box_rounded,
|
||||
content: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
QuickCreateButton(
|
||||
text: 'Category 1',
|
||||
onPressed: () {},
|
||||
),
|
||||
QuickCreateButton(
|
||||
text: 'Category 2',
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
QuickCreateButton(
|
||||
text: 'Category 3',
|
||||
onPressed: () {},
|
||||
),
|
||||
QuickCreateButton(
|
||||
text: 'Category 4',
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
QuickCreateButton(
|
||||
text: 'Category 5',
|
||||
onPressed: () {},
|
||||
),
|
||||
QuickCreateButton(
|
||||
text: 'Category 6',
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
Padding(
|
||||
padding: EdgeInsets.zero,
|
||||
child: InfoTile(
|
||||
width: constraints.maxWidth * 0.95,
|
||||
title: loc.quick_create,
|
||||
icon: Icons.add_box_rounded,
|
||||
content: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
QuickCreateButton(
|
||||
text: 'Category 1',
|
||||
onPressed: () {},
|
||||
),
|
||||
QuickCreateButton(
|
||||
text: 'Category 2',
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
QuickCreateButton(
|
||||
text: 'Category 3',
|
||||
onPressed: () {},
|
||||
),
|
||||
QuickCreateButton(
|
||||
text: 'Category 4',
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
QuickCreateButton(
|
||||
text: 'Category 5',
|
||||
onPressed: () {},
|
||||
),
|
||||
QuickCreateButton(
|
||||
text: 'Category 6',
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: MediaQuery.paddingOf(context).bottom),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -229,14 +185,41 @@ class _HomeViewState extends State<HomeView> {
|
||||
);
|
||||
}
|
||||
|
||||
String _getPlayerText(Match game) {
|
||||
if (game.group == null) {
|
||||
final playerCount = game.players?.length ?? 0;
|
||||
return AppLocalizations.of(context)!.players_count(playerCount);
|
||||
/// Loads the data for the HomeView from the database.
|
||||
/// This includes the match count, group count, and recent matches.
|
||||
Future<void> loadHomeViewData() async {
|
||||
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;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// 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;
|
||||
});
|
||||
}
|
||||
if (game.players == null || game.players!.isEmpty) {
|
||||
return game.group!.name;
|
||||
}
|
||||
return '${game.group!.name} + ${game.players!.length}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,12 @@ class ChooseGameView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ChooseGameViewState extends State<ChooseGameView> {
|
||||
late int selectedGameIndex;
|
||||
/// Controller for the search bar
|
||||
final TextEditingController searchBarController = TextEditingController();
|
||||
|
||||
/// Currently selected game index
|
||||
late int selectedGameIndex;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
selectedGameIndex = widget.initialGameIndex;
|
||||
@@ -31,58 +34,65 @@ class _ChooseGameViewState extends State<ChooseGameView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Scaffold(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
appBar: AppBar(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
scrolledUnderElevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back_ios),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(selectedGameIndex);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.choose_game,
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
centerTitle: true,
|
||||
title: Text(loc.choose_game),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: CustomSearchBar(
|
||||
controller: searchBarController,
|
||||
hintText: AppLocalizations.of(context)!.game_name,
|
||||
body: PopScope(
|
||||
// This fixes that the Android Back Gesture didn't return the
|
||||
// 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: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: CustomSearchBar(
|
||||
controller: searchBarController,
|
||||
hintText: loc.game_name,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: widget.games.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return TitleDescriptionListTile(
|
||||
title: widget.games[index].$1,
|
||||
description: widget.games[index].$2,
|
||||
badgeText: translateRulesetToString(
|
||||
widget.games[index].$3,
|
||||
context,
|
||||
),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
if (selectedGameIndex == index) {
|
||||
selectedGameIndex = -1;
|
||||
} else {
|
||||
selectedGameIndex = index;
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
const SizedBox(height: 5),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: widget.games.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return TitleDescriptionListTile(
|
||||
title: widget.games[index].$1,
|
||||
description: widget.games[index].$2,
|
||||
badgeText: translateRulesetToString(
|
||||
widget.games[index].$3,
|
||||
context,
|
||||
),
|
||||
isHighlighted: selectedGameIndex == index,
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
if (selectedGameIndex == index) {
|
||||
selectedGameIndex = -1;
|
||||
} else {
|
||||
selectedGameIndex = index;
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -34,11 +34,10 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Scaffold(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
appBar: AppBar(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
scrolledUnderElevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back_ios),
|
||||
onPressed: () {
|
||||
@@ -51,75 +50,87 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
|
||||
);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.choose_group,
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
centerTitle: true,
|
||||
title: Text(loc.choose_group),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: CustomSearchBar(
|
||||
controller: controller,
|
||||
hintText: AppLocalizations.of(context)!.group_name,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
filterGroups(value);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Visibility(
|
||||
visible: filteredGroups.isNotEmpty,
|
||||
replacement: Visibility(
|
||||
visible: widget.groups.isNotEmpty,
|
||||
replacement: TopCenteredMessage(
|
||||
icon: Icons.info,
|
||||
title: AppLocalizations.of(context)!.info,
|
||||
message: AppLocalizations.of(context)!.no_groups_created_yet,
|
||||
),
|
||||
child: TopCenteredMessage(
|
||||
icon: Icons.info,
|
||||
title: AppLocalizations.of(context)!.info,
|
||||
message: AppLocalizations.of(
|
||||
context,
|
||||
)!.there_is_no_group_matching_your_search,
|
||||
),
|
||||
),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.only(bottom: 85),
|
||||
itemCount: filteredGroups.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
if (selectedGroupId != filteredGroups[index].id) {
|
||||
selectedGroupId = filteredGroups[index].id;
|
||||
} else {
|
||||
selectedGroupId = '';
|
||||
}
|
||||
});
|
||||
},
|
||||
child: GroupTile(
|
||||
group: filteredGroups[index],
|
||||
isHighlighted:
|
||||
selectedGroupId == filteredGroups[index].id,
|
||||
),
|
||||
);
|
||||
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,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: CustomSearchBar(
|
||||
controller: controller,
|
||||
hintText: loc.search_for_groups,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
filterGroups(value);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
Expanded(
|
||||
child: Visibility(
|
||||
visible: filteredGroups.isNotEmpty,
|
||||
replacement: Visibility(
|
||||
visible: widget.groups.isNotEmpty,
|
||||
replacement: TopCenteredMessage(
|
||||
icon: Icons.info,
|
||||
title: loc.info,
|
||||
message: loc.no_groups_created_yet,
|
||||
),
|
||||
child: TopCenteredMessage(
|
||||
icon: Icons.info,
|
||||
title: loc.info,
|
||||
message: AppLocalizations.of(
|
||||
context,
|
||||
).there_is_no_group_matching_your_search,
|
||||
),
|
||||
),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.only(bottom: 85),
|
||||
itemCount: filteredGroups.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
if (selectedGroupId != filteredGroups[index].id) {
|
||||
selectedGroupId = filteredGroups[index].id;
|
||||
} else {
|
||||
selectedGroupId = '';
|
||||
}
|
||||
});
|
||||
},
|
||||
child: GroupTile(
|
||||
group: filteredGroups[index],
|
||||
isHighlighted:
|
||||
selectedGroupId == filteredGroups[index].id,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Filters the groups based on the search query.
|
||||
/// TODO: Maybe implement also targetting player names?
|
||||
/// Filters the groups based on the search [query].
|
||||
void filterGroups(String query) {
|
||||
setState(() {
|
||||
if (query.isEmpty) {
|
||||
@@ -129,7 +140,11 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
|
||||
filteredGroups.clear();
|
||||
filteredGroups.addAll(
|
||||
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()),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ class ChooseRulesetView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ChooseRulesetViewState extends State<ChooseRulesetView> {
|
||||
/// Currently selected ruleset index
|
||||
late int selectedRulesetIndex;
|
||||
|
||||
@override
|
||||
@@ -29,14 +30,13 @@ class _ChooseRulesetViewState extends State<ChooseRulesetView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return DefaultTabController(
|
||||
length: 2,
|
||||
initialIndex: 0,
|
||||
child: Scaffold(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
appBar: AppBar(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
scrolledUnderElevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back_ios),
|
||||
onPressed: () {
|
||||
@@ -47,34 +47,45 @@ class _ChooseRulesetViewState extends State<ChooseRulesetView> {
|
||||
);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.choose_ruleset,
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
centerTitle: true,
|
||||
title: Text(loc.choose_ruleset),
|
||||
),
|
||||
body: ListView.builder(
|
||||
padding: const EdgeInsets.only(bottom: 85),
|
||||
itemCount: widget.rulesets.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return TitleDescriptionListTile(
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
if (selectedRulesetIndex == index) {
|
||||
selectedRulesetIndex = -1;
|
||||
} else {
|
||||
selectedRulesetIndex = index;
|
||||
}
|
||||
});
|
||||
},
|
||||
title: translateRulesetToString(
|
||||
widget.rulesets[index].$1,
|
||||
context,
|
||||
),
|
||||
description: widget.rulesets[index].$2,
|
||||
isHighlighted: selectedRulesetIndex == index,
|
||||
body: PopScope(
|
||||
// This fixes that the Android Back Gesture didn't return the
|
||||
// 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),
|
||||
itemCount: widget.rulesets.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return TitleDescriptionListTile(
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
if (selectedRulesetIndex == index) {
|
||||
selectedRulesetIndex = -1;
|
||||
} else {
|
||||
selectedRulesetIndex = index;
|
||||
}
|
||||
});
|
||||
},
|
||||
title: translateRulesetToString(
|
||||
widget.rulesets[index].$1,
|
||||
context,
|
||||
),
|
||||
description: widget.rulesets[index].$2,
|
||||
isHighlighted: selectedRulesetIndex == index,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/cupertino.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/enums.dart';
|
||||
import 'package:game_tracker/data/db/database.dart';
|
||||
@@ -26,12 +26,14 @@ class CreateMatchView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CreateMatchViewState extends State<CreateMatchView> {
|
||||
/// Reference to the app database
|
||||
late final AppDatabase db;
|
||||
|
||||
/// Controller for the match name input field
|
||||
final TextEditingController _matchNameController = TextEditingController();
|
||||
|
||||
/// Hint text for the match name input field
|
||||
String? hintText;
|
||||
|
||||
/// List of all groups from the database
|
||||
List<Group> groupsList = [];
|
||||
|
||||
@@ -65,6 +67,9 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
||||
/// The currently selected players
|
||||
List<Player>? selectedPlayers;
|
||||
|
||||
/// List of available rulesets with their localized string representations
|
||||
late final List<(Ruleset, String)> _rulesets;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -80,28 +85,28 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
||||
]).then((result) async {
|
||||
groupsList = result[0] as List<Group>;
|
||||
playerList = result[1] as List<Player>;
|
||||
setState(() {
|
||||
filteredPlayerList = List.from(playerList);
|
||||
});
|
||||
});
|
||||
filteredPlayerList = List.from(playerList);
|
||||
}
|
||||
|
||||
List<(Ruleset, String)> _getRulesets(BuildContext context) {
|
||||
return [
|
||||
(
|
||||
Ruleset.singleWinner,
|
||||
AppLocalizations.of(context)!.ruleset_single_winner_desc,
|
||||
),
|
||||
(
|
||||
Ruleset.singleLoser,
|
||||
AppLocalizations.of(context)!.ruleset_single_loser_desc,
|
||||
),
|
||||
(
|
||||
Ruleset.mostPoints,
|
||||
AppLocalizations.of(context)!.ruleset_most_points_desc,
|
||||
),
|
||||
(
|
||||
Ruleset.leastPoints,
|
||||
AppLocalizations.of(context)!.ruleset_least_points_desc,
|
||||
),
|
||||
@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),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -113,153 +118,155 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
appBar: AppBar(
|
||||
final loc = AppLocalizations.of(context);
|
||||
return ScaffoldMessenger(
|
||||
child: Scaffold(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
scrolledUnderElevation: 0,
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.create_new_match,
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 5),
|
||||
child: TextInputField(
|
||||
controller: _matchNameController,
|
||||
hintText: AppLocalizations.of(context)!.match_name,
|
||||
appBar: AppBar(title: Text(loc.create_new_match)),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: CustomTheme.tileMargin,
|
||||
child: TextInputField(
|
||||
controller: _matchNameController,
|
||||
hintText: hintText ?? '',
|
||||
),
|
||||
),
|
||||
),
|
||||
ChooseTile(
|
||||
title: AppLocalizations.of(context)!.game,
|
||||
trailingText: selectedGameIndex == -1
|
||||
? AppLocalizations.of(context)!.none
|
||||
: games[selectedGameIndex].$1,
|
||||
onPressed: () async {
|
||||
selectedGameIndex = await Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChooseGameView(
|
||||
games: games,
|
||||
initialGameIndex: selectedGameIndex,
|
||||
ChooseTile(
|
||||
title: loc.game,
|
||||
trailingText: selectedGameIndex == -1
|
||||
? loc.none
|
||||
: games[selectedGameIndex].$1,
|
||||
onPressed: () async {
|
||||
selectedGameIndex = await Navigator.of(context).push(
|
||||
adaptivePageRoute(
|
||||
builder: (context) => ChooseGameView(
|
||||
games: games,
|
||||
initialGameIndex: selectedGameIndex,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
if (selectedGameIndex != -1) {
|
||||
selectedRuleset = games[selectedGameIndex].$3;
|
||||
selectedRulesetIndex = _getRulesets(
|
||||
context,
|
||||
).indexWhere((r) => r.$1 == selectedRuleset);
|
||||
} else {
|
||||
selectedRuleset = null;
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
ChooseTile(
|
||||
title: AppLocalizations.of(context)!.ruleset,
|
||||
trailingText: selectedRuleset == null
|
||||
? AppLocalizations.of(context)!.none
|
||||
: translateRulesetToString(selectedRuleset!, context),
|
||||
onPressed: () async {
|
||||
selectedRuleset = await Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChooseRulesetView(
|
||||
rulesets: _getRulesets(context),
|
||||
initialRulesetIndex: selectedRulesetIndex,
|
||||
),
|
||||
),
|
||||
);
|
||||
selectedRulesetIndex = _getRulesets(
|
||||
context,
|
||||
).indexWhere((r) => r.$1 == selectedRuleset);
|
||||
selectedGameIndex = -1;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
ChooseTile(
|
||||
title: AppLocalizations.of(context)!.group,
|
||||
trailingText: selectedGroup == null
|
||||
? AppLocalizations.of(context)!.none
|
||||
: selectedGroup!.name,
|
||||
onPressed: () async {
|
||||
selectedGroup = await Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChooseGroupView(
|
||||
groups: groupsList,
|
||||
initialGroupId: selectedGroupId,
|
||||
),
|
||||
),
|
||||
);
|
||||
selectedGroupId = selectedGroup?.id ?? '';
|
||||
if (selectedGroup != null) {
|
||||
filteredPlayerList = playerList
|
||||
.where(
|
||||
(p) => !selectedGroup!.members.any((m) => m.id == p.id),
|
||||
)
|
||||
.toList();
|
||||
} else {
|
||||
filteredPlayerList = List.from(playerList);
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: PlayerSelection(
|
||||
key: ValueKey(selectedGroup?.id ?? 'no_group'),
|
||||
initialSelectedPlayers: selectedPlayers ?? [],
|
||||
availablePlayers: filteredPlayerList,
|
||||
onChanged: (value) {
|
||||
);
|
||||
setState(() {
|
||||
selectedPlayers = value;
|
||||
if (selectedGameIndex != -1) {
|
||||
hintText = games[selectedGameIndex].$1;
|
||||
selectedRuleset = games[selectedGameIndex].$3;
|
||||
selectedRulesetIndex = _rulesets.indexWhere(
|
||||
(r) => r.$1 == selectedRuleset,
|
||||
);
|
||||
} else {
|
||||
hintText = loc.match_name;
|
||||
selectedRuleset = null;
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
CustomWidthButton(
|
||||
text: AppLocalizations.of(context)!.create_match,
|
||||
sizeRelativeToWidth: 0.95,
|
||||
buttonType: ButtonType.primary,
|
||||
onPressed: _enableCreateGameButton()
|
||||
? () async {
|
||||
Match match = Match(
|
||||
name: _matchNameController.text.trim(),
|
||||
createdAt: DateTime.now(),
|
||||
group: selectedGroup,
|
||||
players: selectedPlayers,
|
||||
);
|
||||
await db.matchDao.addMatch(match: match);
|
||||
if (context.mounted) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
fullscreenDialog: true,
|
||||
builder: (context) => MatchResultView(
|
||||
match: match,
|
||||
onWinnerChanged: widget.onWinnerChanged,
|
||||
),
|
||||
),
|
||||
ChooseTile(
|
||||
title: loc.ruleset,
|
||||
trailingText: selectedRuleset == null
|
||||
? loc.none
|
||||
: translateRulesetToString(selectedRuleset!, context),
|
||||
onPressed: () async {
|
||||
selectedRuleset = await Navigator.of(context).push(
|
||||
adaptivePageRoute(
|
||||
builder: (context) => ChooseRulesetView(
|
||||
rulesets: _rulesets,
|
||||
initialRulesetIndex: selectedRulesetIndex,
|
||||
),
|
||||
),
|
||||
);
|
||||
if (!mounted) return;
|
||||
selectedRulesetIndex = _rulesets.indexWhere(
|
||||
(r) => r.$1 == selectedRuleset,
|
||||
);
|
||||
selectedGameIndex = -1;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
ChooseTile(
|
||||
title: loc.group,
|
||||
trailingText: selectedGroup == null
|
||||
? loc.none_group
|
||||
: selectedGroup!.name,
|
||||
onPressed: () async {
|
||||
selectedGroup = await Navigator.of(context).push(
|
||||
adaptivePageRoute(
|
||||
builder: (context) => ChooseGroupView(
|
||||
groups: groupsList,
|
||||
initialGroupId: selectedGroupId,
|
||||
),
|
||||
),
|
||||
);
|
||||
selectedGroupId = selectedGroup?.id ?? '';
|
||||
if (selectedGroup != null) {
|
||||
filteredPlayerList = playerList
|
||||
.where(
|
||||
(p) => !selectedGroup!.members.any((m) => m.id == p.id),
|
||||
)
|
||||
.toList();
|
||||
} else {
|
||||
filteredPlayerList = List.from(playerList);
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: PlayerSelection(
|
||||
key: ValueKey(selectedGroup?.id ?? 'no_group'),
|
||||
initialSelectedPlayers: selectedPlayers ?? [],
|
||||
availablePlayers: filteredPlayerList,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectedPlayers = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
CustomWidthButton(
|
||||
text: loc.create_match,
|
||||
sizeRelativeToWidth: 0.95,
|
||||
buttonType: ButtonType.primary,
|
||||
onPressed: _enableCreateGameButton()
|
||||
? () async {
|
||||
Match match = Match(
|
||||
name: _matchNameController.text.isEmpty
|
||||
? (hintText ?? '')
|
||||
: _matchNameController.text.trim(),
|
||||
createdAt: DateTime.now(),
|
||||
group: selectedGroup,
|
||||
players: selectedPlayers,
|
||||
);
|
||||
await db.matchDao.addMatch(match: match);
|
||||
if (context.mounted) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
adaptivePageRoute(
|
||||
fullscreenDialog: true,
|
||||
builder: (context) => MatchResultView(
|
||||
match: match,
|
||||
onWinnerChanged: widget.onWinnerChanged,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
: null,
|
||||
),
|
||||
],
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Determines whether the "Create Game" button should be enabled based on
|
||||
/// the current state of the input fields.
|
||||
/// Determines whether the "Create Match" button should be enabled.
|
||||
///
|
||||
/// Returns `true` if:
|
||||
/// - A ruleset is selected AND
|
||||
/// - Either a group is selected OR at least 2 players are selected
|
||||
bool _enableCreateGameButton() {
|
||||
return _matchNameController.text.isNotEmpty &&
|
||||
(selectedGroup != null ||
|
||||
return (selectedGroup != null ||
|
||||
(selectedPlayers != null && selectedPlayers!.length > 1)) &&
|
||||
selectedRuleset != null;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,12 @@ class MatchResultView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MatchResultViewState extends State<MatchResultView> {
|
||||
late final List<Player> allPlayers;
|
||||
late final AppDatabase db;
|
||||
|
||||
/// List of all players who participated in the match
|
||||
late final List<Player> allPlayers;
|
||||
|
||||
/// Currently selected winner player
|
||||
Player? _selectedPlayer;
|
||||
|
||||
@override
|
||||
@@ -36,6 +40,7 @@ class _MatchResultViewState extends State<MatchResultView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Scaffold(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
appBar: AppBar(
|
||||
@@ -46,17 +51,7 @@ class _MatchResultViewState extends State<MatchResultView> {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
scrolledUnderElevation: 0,
|
||||
title: Text(
|
||||
widget.match.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
title: Text(widget.match.name),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
@@ -81,8 +76,8 @@ class _MatchResultViewState extends State<MatchResultView> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.select_winner,
|
||||
style: TextStyle(
|
||||
loc.select_winner,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -131,6 +126,8 @@ class _MatchResultViewState extends State<MatchResultView> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Handles saving or removing the winner in the database
|
||||
/// based on the current selection.
|
||||
Future<void> _handleWinnerSaving() async {
|
||||
if (_selectedPlayer == null) {
|
||||
await db.matchDao.removeWinner(matchId: widget.match.id);
|
||||
@@ -143,12 +140,22 @@ class _MatchResultViewState extends State<MatchResultView> {
|
||||
widget.onWinnerChanged?.call();
|
||||
}
|
||||
|
||||
/// Retrieves all players associated with the given [match].
|
||||
/// This includes players directly assigned to the match
|
||||
/// as well as members of the group (if any).
|
||||
/// The returned list is sorted alphabetically by player name.
|
||||
List<Player> getAllPlayers(Match match) {
|
||||
List<Player> players = [];
|
||||
|
||||
if (match.group == null && match.players != null) {
|
||||
return [...match.players!];
|
||||
players = [...match.players!];
|
||||
} else if (match.group != null && match.players != null) {
|
||||
return [...match.players!, ...match.group!.members];
|
||||
players = [...match.players!, ...match.group!.members];
|
||||
} else {
|
||||
players = [...match.group!.members];
|
||||
}
|
||||
return [...match.group!.members];
|
||||
|
||||
players.sort((a, b) => a.name.compareTo(b.name));
|
||||
return players;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:core' hide Match;
|
||||
|
||||
import 'package:flutter/cupertino.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/custom_theme.dart';
|
||||
import 'package:game_tracker/data/db/database.dart';
|
||||
@@ -13,7 +13,7 @@ import 'package:game_tracker/presentation/views/main_menu/match_view/create_matc
|
||||
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/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:provider/provider.dart';
|
||||
|
||||
@@ -28,12 +28,14 @@ class _MatchViewState extends State<MatchView> {
|
||||
late final AppDatabase db;
|
||||
bool isLoading = true;
|
||||
|
||||
/// Loaded matches from the database,
|
||||
/// initially filled with skeleton matches
|
||||
List<Match> matches = List.filled(
|
||||
4,
|
||||
Match(
|
||||
name: 'Skeleton Gamename',
|
||||
name: 'Skeleton match name',
|
||||
group: Group(
|
||||
name: 'Groupname',
|
||||
name: 'Group name',
|
||||
members: List.filled(5, Player(name: 'Player')),
|
||||
),
|
||||
winner: Player(name: 'Player'),
|
||||
@@ -50,6 +52,7 @@ class _MatchViewState extends State<MatchView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Scaffold(
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
body: Stack(
|
||||
@@ -62,8 +65,8 @@ class _MatchViewState extends State<MatchView> {
|
||||
replacement: Center(
|
||||
child: TopCenteredMessage(
|
||||
icon: Icons.report,
|
||||
title: AppLocalizations.of(context)!.info,
|
||||
message: AppLocalizations.of(context)!.no_matches_created_yet,
|
||||
title: loc.info,
|
||||
message: loc.no_matches_created_yet,
|
||||
),
|
||||
),
|
||||
child: ListView.builder(
|
||||
@@ -72,23 +75,29 @@ class _MatchViewState extends State<MatchView> {
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (index == matches.length) {
|
||||
return SizedBox(
|
||||
height: MediaQuery.paddingOf(context).bottom - 80,
|
||||
height: MediaQuery.paddingOf(context).bottom - 20,
|
||||
);
|
||||
}
|
||||
return GameHistoryTile(
|
||||
onTap: () async {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
fullscreenDialog: true,
|
||||
builder: (context) => MatchResultView(
|
||||
match: matches[index],
|
||||
onWinnerChanged: loadGames,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
match: matches[index],
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12.0),
|
||||
child: MatchTile(
|
||||
width: MediaQuery.sizeOf(context).width * 0.95,
|
||||
onTap: () async {
|
||||
Navigator.push(
|
||||
context,
|
||||
adaptivePageRoute(
|
||||
fullscreenDialog: true,
|
||||
builder: (context) => MatchResultView(
|
||||
match: matches[index],
|
||||
onWinnerChanged: loadGames,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
match: matches[index],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -97,12 +106,12 @@ class _MatchViewState extends State<MatchView> {
|
||||
Positioned(
|
||||
bottom: MediaQuery.paddingOf(context).bottom,
|
||||
child: CustomWidthButton(
|
||||
text: AppLocalizations.of(context)!.create_match,
|
||||
text: loc.create_match,
|
||||
sizeRelativeToWidth: 0.90,
|
||||
onPressed: () async {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
adaptivePageRoute(
|
||||
builder: (context) =>
|
||||
CreateMatchView(onWinnerChanged: loadGames),
|
||||
),
|
||||
@@ -115,10 +124,11 @@ class _MatchViewState extends State<MatchView> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Loads the games from the database and sorts them by creation date.
|
||||
void loadGames() {
|
||||
Future.wait([
|
||||
db.matchDao.getAllMatches(),
|
||||
Future.delayed(minimumSkeletonDuration),
|
||||
Future.delayed(Constants.minimumSkeletonDuration),
|
||||
]).then((results) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/core/custom_theme.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/services/data_transfer_service.dart';
|
||||
|
||||
class SettingsView extends StatefulWidget {
|
||||
const SettingsView({super.key});
|
||||
|
||||
@override
|
||||
State<SettingsView> createState() => _SettingsViewState();
|
||||
}
|
||||
|
||||
class _SettingsViewState extends State<SettingsView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(backgroundColor: CustomTheme.backgroundColor),
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
body: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) =>
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(24, 0, 24, 10),
|
||||
child: Text(
|
||||
textAlign: TextAlign.start,
|
||||
AppLocalizations.of(context)!.menu,
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24,
|
||||
vertical: 10,
|
||||
),
|
||||
child: Text(
|
||||
textAlign: TextAlign.start,
|
||||
AppLocalizations.of(context)!.settings,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SettingsListTile(
|
||||
title: AppLocalizations.of(context)!.export_data,
|
||||
icon: Icons.upload_outlined,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () async {
|
||||
final String json =
|
||||
await DataTransferService.getAppDataAsJson(context);
|
||||
final result = await DataTransferService.exportData(
|
||||
json,
|
||||
'game_tracker-data',
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showExportSnackBar(context: context, result: result);
|
||||
},
|
||||
),
|
||||
SettingsListTile(
|
||||
title: AppLocalizations.of(context)!.import_data,
|
||||
icon: Icons.download_outlined,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () async {
|
||||
final result = await DataTransferService.importData(
|
||||
context,
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showImportSnackBar(context: context, result: result);
|
||||
},
|
||||
),
|
||||
SettingsListTile(
|
||||
title: AppLocalizations.of(context)!.delete_all_data,
|
||||
icon: Icons.download_outlined,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () {
|
||||
showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.delete_all_data,
|
||||
),
|
||||
content: Text(
|
||||
AppLocalizations.of(context)!.this_cannot_be_undone,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: Text(AppLocalizations.of(context)!.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text(AppLocalizations.of(context)!.delete),
|
||||
),
|
||||
],
|
||||
),
|
||||
).then((confirmed) {
|
||||
if (confirmed == true && context.mounted) {
|
||||
DataTransferService.deleteAllData(context);
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(
|
||||
context,
|
||||
)!.data_successfully_deleted,
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Displays a snackbar based on the import result.
|
||||
///
|
||||
/// [context] The BuildContext to show the snackbar in.
|
||||
/// [result] The result of the import operation.
|
||||
void showImportSnackBar({
|
||||
required BuildContext context,
|
||||
required ImportResult result,
|
||||
}) {
|
||||
switch (result) {
|
||||
case ImportResult.success:
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(context)!.data_successfully_imported,
|
||||
);
|
||||
case ImportResult.invalidSchema:
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(context)!.invalid_schema,
|
||||
);
|
||||
case ImportResult.fileReadError:
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(context)!.error_reading_file,
|
||||
);
|
||||
case ImportResult.canceled:
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(context)!.import_canceled,
|
||||
);
|
||||
case ImportResult.formatException:
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(context)!.format_exception,
|
||||
);
|
||||
case ImportResult.unknownException:
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(context)!.unknown_exception,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Displays a snackbar based on the export result.
|
||||
///
|
||||
/// [context] The BuildContext to show the snackbar in.
|
||||
/// [result] The result of the export operation.
|
||||
void showExportSnackBar({
|
||||
required BuildContext context,
|
||||
required ExportResult result,
|
||||
}) {
|
||||
switch (result) {
|
||||
case ExportResult.success:
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(context)!.data_successfully_exported,
|
||||
);
|
||||
case ExportResult.canceled:
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(context)!.export_canceled,
|
||||
);
|
||||
case ExportResult.unknownException:
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(context)!.unknown_exception,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Displays a snackbar with the given message and optional action.
|
||||
///
|
||||
/// [context] The BuildContext to show the snackbar in.
|
||||
/// [message] The message to display in the snackbar.
|
||||
/// [duration] The duration for which the snackbar is displayed.
|
||||
/// [action] An optional callback function to execute when the action button is pressed.
|
||||
void showSnackbar({
|
||||
required BuildContext context,
|
||||
required String message,
|
||||
Duration duration = const Duration(seconds: 3),
|
||||
VoidCallback? action,
|
||||
}) {
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
messenger.hideCurrentSnackBar();
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message, style: const TextStyle(color: Colors.white)),
|
||||
backgroundColor: CustomTheme.onBoxColor,
|
||||
duration: duration,
|
||||
action: action != null
|
||||
? SnackBarAction(
|
||||
label: AppLocalizations.of(context)!.undo,
|
||||
onPressed: action,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import 'package:flutter/material.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/settings_view/licenses/oss_licenses.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class LicenseDetailView extends StatelessWidget {
|
||||
final Package package;
|
||||
|
||||
const LicenseDetailView({super.key, required this.package});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Lizenzdetails')),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsetsGeometry.only(right: 15),
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: CustomTheme.primaryColor.withAlpha(40),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.description,
|
||||
color: CustomTheme.primaryColor,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
package.name,
|
||||
textAlign: TextAlign.left,
|
||||
style: const TextStyle(
|
||||
height: 0,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
if (package.version != null) ...[
|
||||
Text(
|
||||
'Version ${package.version}',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey.shade300,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
if (package.authors.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
SelectableText(
|
||||
package.authors.join(', '),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey.shade500,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (package.homepage != null &&
|
||||
package.homepage!.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
final uri = Uri.parse(package.homepage!);
|
||||
await launchUrl(uri, mode: LaunchMode.platformDefault);
|
||||
},
|
||||
child: SizedBox(
|
||||
width: 300,
|
||||
child: Text(
|
||||
package.homepage!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: CustomTheme.secondaryColor,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationColor: CustomTheme.secondaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||
decoration: CustomTheme.standardBoxDecoration,
|
||||
child: (package.license != null && package.license!.isNotEmpty)
|
||||
? SelectableText(
|
||||
package.license!,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey.shade300,
|
||||
height: 1.5,
|
||||
fontFamily: 'monospace',
|
||||
),
|
||||
)
|
||||
: Center(
|
||||
heightFactor: 25,
|
||||
child: Text(
|
||||
loc.no_license_text_available,
|
||||
style: TextStyle(color: Colors.grey.shade500),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.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/settings_view/licenses/oss_licenses.dart';
|
||||
import 'package:game_tracker/presentation/widgets/tiles/license_tile.dart';
|
||||
|
||||
class LicensesView extends StatelessWidget {
|
||||
const LicensesView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(loc.licenses),
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
),
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
body: ListView.builder(
|
||||
itemCount: allDependencies.length,
|
||||
itemBuilder: (context, index) {
|
||||
final package = allDependencies[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
||||
child: LicenseTile(package: package),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:game_tracker/core/custom_theme.dart';
|
||||
import 'package:game_tracker/core/enums.dart';
|
||||
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||
import 'package:game_tracker/presentation/views/main_menu/settings_view/licenses_view.dart';
|
||||
import 'package:game_tracker/presentation/widgets/tiles/settings_list_tile.dart';
|
||||
import 'package:game_tracker/services/data_transfer_service.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class SettingsView extends StatefulWidget {
|
||||
const SettingsView({super.key});
|
||||
|
||||
@override
|
||||
State<SettingsView> createState() => _SettingsViewState();
|
||||
}
|
||||
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return ScaffoldMessenger(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(backgroundColor: CustomTheme.backgroundColor),
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16, bottom: 10),
|
||||
child: Text(
|
||||
textAlign: TextAlign.start,
|
||||
loc.settings,
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16, top: 10, bottom: 10),
|
||||
child: Text(
|
||||
textAlign: TextAlign.start,
|
||||
loc.data,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.export_data,
|
||||
icon: Icons.upload,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () async {
|
||||
final String json =
|
||||
await DataTransferService.getAppDataAsJson(context);
|
||||
final result = await DataTransferService.exportData(
|
||||
json,
|
||||
'game_tracker-data',
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showExportSnackBar(context: context, result: result);
|
||||
},
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.import_data,
|
||||
icon: Icons.download,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () async {
|
||||
final result = await DataTransferService.importData(context);
|
||||
if (!context.mounted) return;
|
||||
showImportSnackBar(context: context, result: result);
|
||||
},
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.delete_all_data,
|
||||
icon: Icons.delete,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () {
|
||||
showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('${loc.delete_all_data}?'),
|
||||
content: Text(loc.this_cannot_be_undone),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: Text(loc.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text(loc.delete),
|
||||
),
|
||||
],
|
||||
),
|
||||
).then((confirmed) {
|
||||
if (confirmed == true && context.mounted) {
|
||||
DataTransferService.deleteAllData(context);
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(
|
||||
context,
|
||||
).data_successfully_deleted,
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16, top: 10, bottom: 10),
|
||||
child: Text(
|
||||
textAlign: TextAlign.start,
|
||||
loc.legal,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.licenses,
|
||||
icon: Icons.insert_drive_file,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const LicensesView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.legal_notice,
|
||||
icon: Icons.account_balance_sharp,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: null,
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.privacy_policy,
|
||||
icon: Icons.gpp_good_rounded,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: null,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 30, bottom: 20),
|
||||
child: Center(
|
||||
child: Column(
|
||||
spacing: 4,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 40,
|
||||
children: [
|
||||
GestureDetector(
|
||||
child: const Icon(Icons.language),
|
||||
onTap: () => {
|
||||
launchUrl(Uri.parse('https://liquid-dev.de')),
|
||||
},
|
||||
),
|
||||
GestureDetector(
|
||||
child: const FaIcon(FontAwesomeIcons.github),
|
||||
onTap: () => {
|
||||
launchUrl(
|
||||
Uri.parse(
|
||||
'https://github.com/liquiddevelopmentde',
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.mail_solid
|
||||
: Icons.email,
|
||||
),
|
||||
onTap: () => launchUrl(
|
||||
Uri.parse('mailto:hi@liquid-dev.de'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'© ${DateFormat('yyyy').format(DateTime.now())} Liquid Development',
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade600,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Version ${_packageInfo.version} (${_packageInfo.buildNumber})',
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade600,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Displays a snackbar based on the import result.
|
||||
///
|
||||
/// [context] The BuildContext to show the snackbar in.
|
||||
/// [result] The result of the import operation.
|
||||
void showImportSnackBar({
|
||||
required BuildContext context,
|
||||
required ImportResult result,
|
||||
}) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
switch (result) {
|
||||
case ImportResult.success:
|
||||
showSnackbar(context: context, message: loc.data_successfully_imported);
|
||||
case ImportResult.invalidSchema:
|
||||
showSnackbar(context: context, message: loc.invalid_schema);
|
||||
case ImportResult.fileReadError:
|
||||
showSnackbar(context: context, message: loc.error_reading_file);
|
||||
case ImportResult.canceled:
|
||||
showSnackbar(context: context, message: loc.import_canceled);
|
||||
case ImportResult.formatException:
|
||||
showSnackbar(context: context, message: loc.format_exception);
|
||||
case ImportResult.unknownException:
|
||||
showSnackbar(context: context, message: loc.unknown_exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// Displays a snackbar based on the export result.
|
||||
///
|
||||
/// [context] The BuildContext to show the snackbar in.
|
||||
/// [result] The result of the export operation.
|
||||
void showExportSnackBar({
|
||||
required BuildContext context,
|
||||
required ExportResult result,
|
||||
}) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
switch (result) {
|
||||
case ExportResult.success:
|
||||
showSnackbar(context: context, message: loc.data_successfully_exported);
|
||||
case ExportResult.canceled:
|
||||
showSnackbar(context: context, message: loc.export_canceled);
|
||||
case ExportResult.unknownException:
|
||||
showSnackbar(context: context, message: loc.unknown_exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// Displays a snackbar with the given message and optional action.
|
||||
///
|
||||
/// [context] The BuildContext to show the snackbar in.
|
||||
/// [message] The message to display in the snackbar.
|
||||
/// [duration] The duration for which the snackbar is displayed.
|
||||
/// [action] An optional callback function to execute when the action button is pressed.
|
||||
void showSnackbar({
|
||||
required BuildContext context,
|
||||
required String message,
|
||||
Duration duration = const Duration(seconds: 3),
|
||||
VoidCallback? action,
|
||||
}) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
messenger.hideCurrentSnackBar();
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message, style: const TextStyle(color: Colors.white)),
|
||||
backgroundColor: CustomTheme.onBoxColor,
|
||||
duration: duration,
|
||||
action: action != null
|
||||
? SnackBarAction(label: loc.undo, onPressed: action)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Initializes the package information.
|
||||
Future<void> _initPackageInfo() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
setState(() {
|
||||
_packageInfo = info;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -25,28 +25,12 @@ class _StatisticsViewState extends State<StatisticsView> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final db = Provider.of<AppDatabase>(context, listen: false);
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
});
|
||||
loadStatisticData();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
return SingleChildScrollView(
|
||||
@@ -69,16 +53,16 @@ class _StatisticsViewState extends State<StatisticsView> {
|
||||
children: [
|
||||
StatisticsTile(
|
||||
icon: Icons.sports_score,
|
||||
title: 'Wins',
|
||||
title: loc.wins,
|
||||
width: constraints.maxWidth * 0.95,
|
||||
values: winCounts,
|
||||
itemCount: 3,
|
||||
barColor: Colors.blue,
|
||||
barColor: Colors.green,
|
||||
),
|
||||
SizedBox(height: constraints.maxHeight * 0.02),
|
||||
StatisticsTile(
|
||||
icon: Icons.percent,
|
||||
title: 'Winrate',
|
||||
title: loc.winrate,
|
||||
width: constraints.maxWidth * 0.95,
|
||||
values: winRates,
|
||||
itemCount: 5,
|
||||
@@ -87,46 +71,22 @@ class _StatisticsViewState extends State<StatisticsView> {
|
||||
SizedBox(height: constraints.maxHeight * 0.02),
|
||||
StatisticsTile(
|
||||
icon: Icons.casino,
|
||||
title: 'Amount of Matches',
|
||||
title: loc.amount_of_matches,
|
||||
width: constraints.maxWidth * 0.95,
|
||||
values: matchCounts,
|
||||
itemCount: 10,
|
||||
barColor: Colors.green,
|
||||
barColor: Colors.blue,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const TopCenteredMessage(
|
||||
child: TopCenteredMessage(
|
||||
icon: Icons.info,
|
||||
title: 'Info',
|
||||
message: 'No statistics available',
|
||||
title: loc.info,
|
||||
message: AppLocalizations.of(
|
||||
context,
|
||||
).no_statistics_available,
|
||||
),
|
||||
),
|
||||
StatisticsTile(
|
||||
icon: Icons.sports_score,
|
||||
title: AppLocalizations.of(context)!.wins,
|
||||
width: constraints.maxWidth * 0.95,
|
||||
values: winCounts,
|
||||
itemCount: 3,
|
||||
barColor: Colors.blue,
|
||||
),
|
||||
SizedBox(height: constraints.maxHeight * 0.02),
|
||||
StatisticsTile(
|
||||
icon: Icons.percent,
|
||||
title: AppLocalizations.of(context)!.winrate,
|
||||
width: constraints.maxWidth * 0.95,
|
||||
values: winRates,
|
||||
itemCount: 5,
|
||||
barColor: Colors.orange[700]!,
|
||||
),
|
||||
SizedBox(height: constraints.maxHeight * 0.02),
|
||||
StatisticsTile(
|
||||
icon: Icons.casino,
|
||||
title: AppLocalizations.of(context)!.amount_of_matches,
|
||||
width: constraints.maxWidth * 0.95,
|
||||
values: matchCounts,
|
||||
itemCount: 10,
|
||||
barColor: Colors.green,
|
||||
),
|
||||
SizedBox(height: MediaQuery.paddingOf(context).bottom),
|
||||
],
|
||||
),
|
||||
@@ -137,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
|
||||
/// and returns a sorted list of tuples (playerName, winCount)
|
||||
List<(String, int)> _calculateWinsForAllPlayers(
|
||||
List<Match> matches,
|
||||
List<Player> players,
|
||||
) {
|
||||
List<(String, int)> _calculateWinsForAllPlayers({
|
||||
required List<Match> matches,
|
||||
required List<Player> players,
|
||||
required BuildContext context,
|
||||
}) {
|
||||
List<(String, int)> winCounts = [];
|
||||
final loc = AppLocalizations.of(context);
|
||||
|
||||
// Getting the winners
|
||||
for (var match in matches) {
|
||||
@@ -174,7 +166,7 @@ class _StatisticsViewState extends State<StatisticsView> {
|
||||
final playerId = winCounts[i].$1;
|
||||
final player = players.firstWhere(
|
||||
(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);
|
||||
}
|
||||
@@ -186,11 +178,13 @@ class _StatisticsViewState extends State<StatisticsView> {
|
||||
|
||||
/// Calculates the number of matches played for each player
|
||||
/// and returns a sorted list of tuples (playerName, matchCount)
|
||||
List<(String, int)> _calculateMatchAmountsForAllPlayers(
|
||||
List<Match> matches,
|
||||
List<Player> players,
|
||||
) {
|
||||
List<(String, int)> _calculateMatchAmountsForAllPlayers({
|
||||
required List<Match> matches,
|
||||
required List<Player> players,
|
||||
required BuildContext context,
|
||||
}) {
|
||||
List<(String, int)> matchCounts = [];
|
||||
final loc = AppLocalizations.of(context);
|
||||
|
||||
// Counting matches for each player
|
||||
for (var match in matches) {
|
||||
@@ -236,7 +230,7 @@ class _StatisticsViewState extends State<StatisticsView> {
|
||||
final playerId = matchCounts[i].$1;
|
||||
final player = players.firstWhere(
|
||||
(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);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final Widget child;
|
||||
final bool enabled;
|
||||
final bool fixLayoutBuilder;
|
||||
|
||||
const AppSkeleton({
|
||||
super.key,
|
||||
required this.child,
|
||||
@@ -13,6 +13,15 @@ class AppSkeleton extends StatefulWidget {
|
||||
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
|
||||
State<AppSkeleton> createState() => _AppSkeletonState();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/core/custom_theme.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 {
|
||||
const CustomWidthButton({
|
||||
super.key,
|
||||
@@ -11,9 +17,16 @@ class CustomWidthButton extends StatelessWidget {
|
||||
this.onPressed,
|
||||
});
|
||||
|
||||
/// The text to display on the button.
|
||||
final String text;
|
||||
|
||||
/// The size of the button relative to the width of the screen.
|
||||
final double sizeRelativeToWidth;
|
||||
|
||||
/// The callback to be invoked when the button is pressed.
|
||||
final VoidCallback? onPressed;
|
||||
|
||||
/// The type of button to display. Depends on the enum [ButtonType].
|
||||
final ButtonType buttonType;
|
||||
|
||||
@override
|
||||
@@ -47,7 +60,7 @@ class CustomWidthButton extends StatelessWidget {
|
||||
60,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: CustomTheme.standardBorderRadiusAll,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
@@ -78,7 +91,7 @@ class CustomWidthButton extends StatelessWidget {
|
||||
),
|
||||
side: BorderSide(color: borderSideColor, width: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: CustomTheme.standardBorderRadiusAll,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final String text;
|
||||
final VoidCallback? onPressed;
|
||||
const QuickCreateButton({
|
||||
super.key,
|
||||
required this.text,
|
||||
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
|
||||
State<QuickCreateButton> createState() => _QuickCreateButtonState();
|
||||
}
|
||||
@@ -22,7 +29,9 @@ class _QuickCreateButtonState extends State<QuickCreateButton> {
|
||||
style: ElevatedButton.styleFrom(
|
||||
minimumSize: const Size(140, 45),
|
||||
backgroundColor: CustomTheme.primaryColor,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: CustomTheme.standardBorderRadiusAll,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
widget.text,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final int index;
|
||||
final bool isSelected;
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final Function(int) onTabTapped;
|
||||
|
||||
const NavbarItem({
|
||||
super.key,
|
||||
required this.index,
|
||||
@@ -16,6 +16,21 @@ class NavbarItem extends StatefulWidget {
|
||||
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
|
||||
State<NavbarItem> createState() => _NavbarItemState();
|
||||
}
|
||||
|
||||
@@ -11,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: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 {
|
||||
final Function(List<Player> value) onChanged;
|
||||
final List<Player> availablePlayers;
|
||||
final List<Player>? initialSelectedPlayers;
|
||||
|
||||
const PlayerSelection({
|
||||
super.key,
|
||||
required this.onChanged,
|
||||
this.availablePlayers = const [],
|
||||
this.availablePlayers,
|
||||
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
|
||||
State<PlayerSelection> createState() => _PlayerSelectionState();
|
||||
}
|
||||
|
||||
class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
List<Player> selectedPlayers = [];
|
||||
List<Player> suggestedPlayers = [];
|
||||
List<Player> allPlayers = [];
|
||||
late final AppDatabase db;
|
||||
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 =
|
||||
TextEditingController();
|
||||
late final AppDatabase db;
|
||||
late Future<List<Player>> _allPlayersFuture;
|
||||
|
||||
/// Skeleton data used while loading players.
|
||||
late final List<Player> skeletonData = List.filled(
|
||||
7,
|
||||
Player(name: 'Player 0'),
|
||||
@@ -49,46 +73,11 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
margin: CustomTheme.standardMargin,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
||||
decoration: CustomTheme.standardBoxDecoration,
|
||||
child: Column(
|
||||
@@ -97,7 +86,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
CustomSearchBar(
|
||||
controller: _searchBarController,
|
||||
constraints: const BoxConstraints(maxHeight: 45, minHeight: 45),
|
||||
hintText: 'Search for players',
|
||||
hintText: loc.search_for_players,
|
||||
trailingButtonShown: true,
|
||||
trailingButtonicon: Icons.add_circle,
|
||||
trailingButtonEnabled: _searchBarController.text.trim().isNotEmpty,
|
||||
@@ -130,20 +119,14 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
)!.selected_players(selectedPlayers.length),
|
||||
loc.selected_players,
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
height: 50,
|
||||
child: selectedPlayers.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.no_players_selected,
|
||||
),
|
||||
)
|
||||
? Center(child: Text(loc.no_players_selected))
|
||||
: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
@@ -156,18 +139,24 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
onIconTap: () {
|
||||
setState(() {
|
||||
// Removes the player from the selection and notifies the parent.
|
||||
selectedPlayers.remove(player);
|
||||
widget.onChanged([...selectedPlayers]);
|
||||
|
||||
// Get the current search query
|
||||
final currentSearch = _searchBarController
|
||||
.text
|
||||
.toLowerCase();
|
||||
selectedPlayers.remove(player);
|
||||
widget.onChanged([...selectedPlayers]);
|
||||
|
||||
// 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 ||
|
||||
player.name.toLowerCase().contains(
|
||||
currentSearch,
|
||||
)) {
|
||||
suggestedPlayers.add(player);
|
||||
suggestedPlayers.sort(
|
||||
(a, b) => a.name.compareTo(b.name),
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -179,13 +168,10 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.all_players,
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
loc.all_players,
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
/*
|
||||
|
||||
*/
|
||||
Expanded(
|
||||
child: AppSkeleton(
|
||||
enabled: isLoading,
|
||||
@@ -193,14 +179,8 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
visible: suggestedPlayers.isNotEmpty,
|
||||
replacement: TopCenteredMessage(
|
||||
icon: Icons.info,
|
||||
title: AppLocalizations.of(context)!.info,
|
||||
message: allPlayers.isEmpty
|
||||
? AppLocalizations.of(context)!.no_players_created_yet
|
||||
: (selectedPlayers.length == allPlayers.length)
|
||||
? AppLocalizations.of(context)!.all_players_selected
|
||||
: AppLocalizations.of(
|
||||
context,
|
||||
)!.no_players_found_with_that_name,
|
||||
title: loc.info,
|
||||
message: _getInfoText(context),
|
||||
),
|
||||
child: ListView.builder(
|
||||
itemCount: suggestedPlayers.length,
|
||||
@@ -209,11 +189,15 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
text: suggestedPlayers[index].name,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
// If the player is not already selected
|
||||
if (!selectedPlayers.contains(
|
||||
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]);
|
||||
// Remove the player from the suggestedPlayers
|
||||
suggestedPlayers.remove(suggestedPlayers[index]);
|
||||
}
|
||||
});
|
||||
@@ -229,49 +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.
|
||||
/// Shows a snackbar indicating success or failure.
|
||||
/// [context] - BuildContext to show the snackbar.
|
||||
void addNewPlayerFromSearch({required BuildContext context}) async {
|
||||
String playerName = _searchBarController.text.trim();
|
||||
Player createdPlayer = Player(name: playerName);
|
||||
bool success = await db.playerDao.addPlayer(player: createdPlayer);
|
||||
Future<void> addNewPlayerFromSearch({required BuildContext context}) async {
|
||||
final loc = AppLocalizations.of(context);
|
||||
final playerName = _searchBarController.text.trim();
|
||||
|
||||
final createdPlayer = Player(name: playerName);
|
||||
final success = await db.playerDao.addPlayer(player: createdPlayer);
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
if (success) {
|
||||
selectedPlayers.add(createdPlayer);
|
||||
widget.onChanged([...selectedPlayers]);
|
||||
allPlayers.add(createdPlayer);
|
||||
setState(() {
|
||||
_searchBarController.clear();
|
||||
suggestedPlayers = allPlayers.where((player) {
|
||||
return !selectedPlayers.contains(player);
|
||||
}).toList();
|
||||
});
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: CustomTheme.boxColor,
|
||||
content: Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
)!.successfully_added_player(playerName),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
_handleSuccessfulPlayerCreation(createdPlayer);
|
||||
showSnackBarMessage(loc.successfully_added_player(playerName));
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: CustomTheme.boxColor,
|
||||
content: Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.could_not_add_player(playerName),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
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]);
|
||||
allPlayers.add(player);
|
||||
|
||||
setState(() {
|
||||
_searchBarController.clear();
|
||||
_updateSuggestedPlayers();
|
||||
});
|
||||
}
|
||||
|
||||
/// 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(
|
||||
SnackBar(
|
||||
backgroundColor: CustomTheme.boxColor,
|
||||
content: Center(
|
||||
child: Text(message, 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 {
|
||||
// No players match the search query
|
||||
return loc.no_players_found_with_that_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import 'package:flutter/material.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 {
|
||||
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({
|
||||
super.key,
|
||||
required this.controller,
|
||||
@@ -23,6 +23,30 @@ class CustomSearchBar extends StatelessWidget {
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return SearchBar(
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final TextEditingController controller;
|
||||
final ValueChanged<String>? onChanged;
|
||||
final String hintText;
|
||||
|
||||
const TextInputField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
@@ -13,6 +13,15 @@ class TextInputField extends StatelessWidget {
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return TextField(
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final String title;
|
||||
final VoidCallback? onPressed;
|
||||
final String? trailingText;
|
||||
const ChooseTile({
|
||||
super.key,
|
||||
required this.title,
|
||||
@@ -12,6 +13,15 @@ class ChooseTile extends StatefulWidget {
|
||||
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
|
||||
State<ChooseTile> createState() => _ChooseTileState();
|
||||
}
|
||||
@@ -22,8 +32,8 @@ class _ChooseTileState extends State<ChooseTile> {
|
||||
return GestureDetector(
|
||||
onTap: widget.onPressed,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 5),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
|
||||
margin: CustomTheme.tileMargin,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: CustomTheme.standardBoxDecoration,
|
||||
child: Row(
|
||||
children: [
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final String text;
|
||||
final T value;
|
||||
final ValueChanged<T> onContainerTap;
|
||||
|
||||
const CustomRadioListTile({
|
||||
super.key,
|
||||
required this.text,
|
||||
@@ -13,6 +13,15 @@ class CustomRadioListTile<T> extends StatelessWidget {
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
@@ -23,7 +32,7 @@ class CustomRadioListTile<T> extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: CustomTheme.boxColor,
|
||||
border: Border.all(color: CustomTheme.boxBorder),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: CustomTheme.standardBorderRadiusAll,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
|
||||
@@ -3,16 +3,22 @@ import 'package:game_tracker/core/custom_theme.dart';
|
||||
import 'package:game_tracker/data/dto/group.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 {
|
||||
const GroupTile({super.key, required this.group, this.isHighlighted = false});
|
||||
|
||||
/// The group data to be displayed.
|
||||
final Group group;
|
||||
|
||||
/// Whether the tile should be highlighted.
|
||||
final bool isHighlighted;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedContainer(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
margin: CustomTheme.standardMargin,
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||
decoration: isHighlighted
|
||||
? CustomTheme.highlightedBoxDecoration
|
||||
@@ -56,7 +62,9 @@ class GroupTile extends StatelessWidget {
|
||||
spacing: 12.0,
|
||||
runSpacing: 8.0,
|
||||
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),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final String title;
|
||||
final IconData icon;
|
||||
final Widget content;
|
||||
final EdgeInsets? padding;
|
||||
final double? height;
|
||||
final double? width;
|
||||
const InfoTile({
|
||||
super.key,
|
||||
required this.title,
|
||||
@@ -18,6 +19,24 @@ class InfoTile extends StatefulWidget {
|
||||
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
|
||||
State<InfoTile> createState() => _InfoTileState();
|
||||
}
|
||||
|
||||
106
lib/presentation/widgets/tiles/license_tile.dart
Normal file
106
lib/presentation/widgets/tiles/license_tile.dart
Normal file
@@ -0,0 +1,106 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/core/custom_theme.dart';
|
||||
import 'package:game_tracker/presentation/views/main_menu/settings_view/licenses/license_detail_view.dart';
|
||||
import 'package:game_tracker/presentation/views/main_menu/settings_view/licenses/oss_licenses.dart';
|
||||
|
||||
class LicenseTile extends StatelessWidget {
|
||||
final Package package;
|
||||
|
||||
const LicenseTile({super.key, required this.package});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => LicenseDetailView(package: package),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 12),
|
||||
decoration: CustomTheme.standardBoxDecoration.copyWith(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: CustomTheme.primaryColor.withAlpha(40),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.description,
|
||||
color: CustomTheme.primaryColor,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
package.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (package.version != null &&
|
||||
package.version!.isNotEmpty) ...[
|
||||
const SizedBox(width: 12),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: CustomTheme.onBoxColor,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
'v${package.version}',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Colors.grey.shade500,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
package.description,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.grey.shade400,
|
||||
height: 1.3,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// Arrow Icon
|
||||
Icon(Icons.chevron_right, color: Colors.grey.shade600, size: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,14 @@ import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/core/custom_theme.dart';
|
||||
import 'package:skeletonizer/skeletonizer.dart';
|
||||
|
||||
class MatchTile extends StatefulWidget {
|
||||
class MatchSummaryTile extends StatefulWidget {
|
||||
final String matchTitle;
|
||||
final String game;
|
||||
final String ruleset;
|
||||
final String players;
|
||||
final String winner;
|
||||
|
||||
const MatchTile({
|
||||
const MatchSummaryTile({
|
||||
super.key,
|
||||
required this.matchTitle,
|
||||
required this.game,
|
||||
@@ -19,10 +19,10 @@ class MatchTile extends StatefulWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
State<MatchTile> createState() => _MatchTileState();
|
||||
State<MatchSummaryTile> createState() => _MatchSummaryTileState();
|
||||
}
|
||||
|
||||
class _MatchTileState extends State<MatchTile> {
|
||||
class _MatchSummaryTileState extends State<MatchSummaryTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
@@ -1,37 +1,64 @@
|
||||
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';
|
||||
|
||||
class GameHistoryTile extends StatefulWidget {
|
||||
/// 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;
|
||||
|
||||
const GameHistoryTile({super.key, required this.match, required this.onTap});
|
||||
/// Optional width for the tile.
|
||||
final double? width;
|
||||
|
||||
/// Whether to display the tile in a compact mode
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
State<GameHistoryTile> createState() => _GameHistoryTileState();
|
||||
State<MatchTile> createState() => _MatchTileState();
|
||||
}
|
||||
|
||||
class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
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 allPlayers = _getAllPlayers();
|
||||
final loc = AppLocalizations.of(context);
|
||||
|
||||
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),
|
||||
),
|
||||
margin: EdgeInsets.zero,
|
||||
width: widget.width,
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: CustomTheme.standardBoxDecoration,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -49,7 +76,7 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
_formatDate(widget.match.createdAt),
|
||||
_formatDate(widget.match.createdAt, context),
|
||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
@@ -64,7 +91,22 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
group.name,
|
||||
'${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,
|
||||
),
|
||||
@@ -98,11 +140,48 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.winner(winner.name),
|
||||
'${loc.winner}: ${winner.name}',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
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,
|
||||
),
|
||||
@@ -113,10 +192,10 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
|
||||
if (allPlayers.isNotEmpty) ...[
|
||||
if (_allPlayers.isNotEmpty && widget.compact == false) ...[
|
||||
Text(
|
||||
AppLocalizations.of(context)!.players,
|
||||
style: TextStyle(
|
||||
loc.players,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -126,7 +205,7 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
Wrap(
|
||||
spacing: 6,
|
||||
runSpacing: 6,
|
||||
children: allPlayers.map((player) {
|
||||
children: _allPlayers.map((player) {
|
||||
return TextIconTile(text: player.name, iconEnabled: false);
|
||||
}).toList(),
|
||||
),
|
||||
@@ -137,27 +216,28 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
);
|
||||
}
|
||||
|
||||
String _formatDate(DateTime dateTime) {
|
||||
/// 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 AppLocalizations.of(
|
||||
context,
|
||||
)!.today_at(DateFormat('HH:mm').format(dateTime));
|
||||
return "${loc.today_at} ${DateFormat('HH:mm').format(dateTime)}";
|
||||
} else if (difference.inDays == 1) {
|
||||
return AppLocalizations.of(
|
||||
context,
|
||||
)!.yesterday_at(DateFormat('HH:mm').format(dateTime));
|
||||
return "${loc.yesterday_at} ${DateFormat('HH:mm').format(dateTime)}";
|
||||
} else if (difference.inDays < 7) {
|
||||
return AppLocalizations.of(context)!.days_ago(difference.inDays);
|
||||
return loc.days_ago(difference.inDays);
|
||||
} else {
|
||||
return DateFormat('MMM d, yyyy').format(dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
List<dynamic> _getAllPlayers() {
|
||||
final allPlayers = <dynamic>[];
|
||||
/// 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
|
||||
@@ -180,6 +260,7 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
}
|
||||
}
|
||||
|
||||
allPlayers.sort((a, b) => a.name.compareTo(b.name));
|
||||
return allPlayers;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final String title;
|
||||
final IconData icon;
|
||||
final int value;
|
||||
final double? height;
|
||||
final double? width;
|
||||
final EdgeInsets? padding;
|
||||
const QuickInfoTile({
|
||||
super.key,
|
||||
required this.title,
|
||||
@@ -18,6 +19,24 @@ class QuickInfoTile extends StatefulWidget {
|
||||
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
|
||||
State<QuickInfoTile> createState() => _QuickInfoTileState();
|
||||
}
|
||||
|
||||
@@ -1,19 +1,32 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final VoidCallback? onPressed;
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final Widget? suffixWidget;
|
||||
const SettingsListTile({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
this.suffixWidget,
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
@@ -25,7 +38,7 @@ class SettingsListTile extends StatelessWidget {
|
||||
onTap: onPressed ?? () {},
|
||||
child: Container(
|
||||
margin: EdgeInsets.zero,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
|
||||
decoration: CustomTheme.standardBoxDecoration,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@@ -34,12 +47,17 @@ class SettingsListTile extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: CustomTheme.primaryColor,
|
||||
shape: BoxShape.circle,
|
||||
color: CustomTheme.primaryColor.withAlpha(40),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
size: 28,
|
||||
color: CustomTheme.primaryColor.withGreen(40),
|
||||
),
|
||||
child: Icon(icon, size: 24),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(title, style: const TextStyle(fontSize: 18)),
|
||||
|
||||
@@ -4,6 +4,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/l10n/generated/app_localizations.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 {
|
||||
const StatisticsTile({
|
||||
super.key,
|
||||
@@ -15,16 +22,27 @@ class StatisticsTile extends StatelessWidget {
|
||||
required this.barColor,
|
||||
});
|
||||
|
||||
/// The icon displayed next to the title.
|
||||
final IconData icon;
|
||||
|
||||
/// The title text displayed on the tile.
|
||||
final String title;
|
||||
|
||||
/// The width of the tile.
|
||||
final double width;
|
||||
|
||||
/// A list of tuples containing labels and their corresponding numeric values.
|
||||
final List<(String, num)> values;
|
||||
|
||||
/// The maximum number of items to display.
|
||||
final int itemCount;
|
||||
|
||||
/// The color of the bars representing the values.
|
||||
final Color barColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final maxBarWidth = MediaQuery.of(context).size.width * 0.65;
|
||||
final loc = AppLocalizations.of(context);
|
||||
|
||||
return InfoTile(
|
||||
width: width,
|
||||
@@ -36,40 +54,58 @@ class StatisticsTile extends StatelessWidget {
|
||||
visible: values.isNotEmpty,
|
||||
replacement: Center(
|
||||
heightFactor: 4,
|
||||
child: Text(AppLocalizations.of(context)!.no_data_available),
|
||||
child: Text(loc.no_data_available),
|
||||
),
|
||||
child: Column(
|
||||
children: List.generate(min(values.length, itemCount), (index) {
|
||||
/// The maximum wins among all players
|
||||
final maxMatches = values.isNotEmpty ? values[0].$2 : 0;
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final maxBarWidth = constraints.maxWidth * 0.65;
|
||||
return Column(
|
||||
children: List.generate(min(values.length, itemCount), (index) {
|
||||
/// The maximum wins among all players
|
||||
final maxMatches = values.isNotEmpty ? values[0].$2 : 0;
|
||||
|
||||
/// Fraction of wins
|
||||
final double fraction = (maxMatches > 0)
|
||||
? (values[index].$2 / maxMatches)
|
||||
: 0.0;
|
||||
/// Fraction of wins
|
||||
final double fraction = (maxMatches > 0)
|
||||
? (values[index].$2 / maxMatches)
|
||||
: 0.0;
|
||||
|
||||
/// Calculated width for current the bar
|
||||
final double barWidth = maxBarWidth * fraction;
|
||||
/// Calculated width for current the bar
|
||||
final double barWidth = maxBarWidth * fraction;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Stack(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
height: 24,
|
||||
width: barWidth,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: barColor,
|
||||
),
|
||||
Stack(
|
||||
children: [
|
||||
Container(
|
||||
height: 24,
|
||||
width: barWidth,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: barColor,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0),
|
||||
child: Text(
|
||||
values[index].$1,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0),
|
||||
const Spacer(),
|
||||
Center(
|
||||
child: Text(
|
||||
values[index].$1,
|
||||
values[index].$2 <= 1 && values[index].$2 is double
|
||||
? values[index].$2.toStringAsFixed(2)
|
||||
: values[index].$2.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -78,23 +114,10 @@ class StatisticsTile extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
Center(
|
||||
child: Text(
|
||||
values[index].$2 <= 1 && values[index].$2 is double
|
||||
? values[index].$2.toStringAsFixed(2)
|
||||
: values[index].$2.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,18 +1,27 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final String text;
|
||||
final VoidCallback? onPressed;
|
||||
final bool iconEnabled;
|
||||
|
||||
const TextIconListTile({
|
||||
super.key,
|
||||
required this.text,
|
||||
this.onPressed,
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
||||
@@ -1,18 +1,27 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final String text;
|
||||
final bool iconEnabled;
|
||||
final VoidCallback? onIconTap;
|
||||
|
||||
const TextIconTile({
|
||||
super.key,
|
||||
required this.text,
|
||||
this.onIconTap,
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final String title;
|
||||
final String description;
|
||||
final VoidCallback? onPressed;
|
||||
final bool isHighlighted;
|
||||
final String? badgeText;
|
||||
final Color? badgeColor;
|
||||
|
||||
const TitleDescriptionListTile({
|
||||
super.key,
|
||||
required this.title,
|
||||
@@ -19,6 +19,24 @@ class TitleDescriptionListTile extends StatelessWidget {
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
@@ -54,7 +72,7 @@ class TitleDescriptionListTile extends StatelessWidget {
|
||||
if (badgeText != null) ...[
|
||||
const Spacer(),
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 100),
|
||||
constraints: const BoxConstraints(maxWidth: 115),
|
||||
margin: const EdgeInsets.only(top: 4),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
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 {
|
||||
const TopCenteredMessage({
|
||||
super.key,
|
||||
@@ -8,10 +12,15 @@ class TopCenteredMessage extends StatelessWidget {
|
||||
required this.message,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String message;
|
||||
/// The icon to display above the title.
|
||||
final IconData icon;
|
||||
|
||||
/// The title text to display.
|
||||
final String title;
|
||||
|
||||
/// The message text to display below the title.
|
||||
final String message;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
||||
@@ -31,9 +31,25 @@ class DataTransferService {
|
||||
|
||||
// Construct a JSON representation of the data
|
||||
final Map<String, dynamic> jsonMap = {
|
||||
'matches': matches.map((match) => match.toJson()).toList(),
|
||||
'groups': groups.map((group) => group.toJson()).toList(),
|
||||
'players': players.map((player) => player.toJson()).toList(),
|
||||
'players': players.map((p) => p.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);
|
||||
@@ -46,7 +62,7 @@ class DataTransferService {
|
||||
/// [fileName] The desired name for the exported file (without extension).
|
||||
static Future<ExportResult> exportData(
|
||||
String jsonString,
|
||||
String fileName,
|
||||
String fileName
|
||||
) async {
|
||||
try {
|
||||
final bytes = Uint8List.fromList(utf8.encode(jsonString));
|
||||
@@ -54,11 +70,13 @@ class DataTransferService {
|
||||
fileName: '$fileName.json',
|
||||
bytes: bytes,
|
||||
);
|
||||
|
||||
if (path == null) {
|
||||
return ExportResult.canceled;
|
||||
} else {
|
||||
return ExportResult.success;
|
||||
}
|
||||
|
||||
} catch (e, stack) {
|
||||
print('[exportData] $e');
|
||||
print(stack);
|
||||
@@ -81,42 +99,77 @@ class DataTransferService {
|
||||
|
||||
try {
|
||||
final jsonString = await _readFileContent(path.files.single);
|
||||
if (jsonString == null) {
|
||||
return ImportResult.fileReadError;
|
||||
}
|
||||
if (jsonString == null) return ImportResult.fileReadError;
|
||||
|
||||
if (await _validateJsonSchema(jsonString)) {
|
||||
final Map<String, dynamic> jsonData =
|
||||
json.decode(jsonString) as Map<String, dynamic>;
|
||||
final isValid = await _validateJsonSchema(jsonString);
|
||||
if (!isValid) return ImportResult.invalidSchema;
|
||||
|
||||
final List<dynamic>? matchesJson =
|
||||
jsonData['matches'] as List<dynamic>?;
|
||||
final List<dynamic>? groupsJson = jsonData['groups'] as List<dynamic>?;
|
||||
final List<dynamic>? playersJson =
|
||||
jsonData['players'] as List<dynamic>?;
|
||||
final Map<String, dynamic> decoded = json.decode(jsonString) as Map<String, dynamic>;
|
||||
|
||||
final List<Match> importedMatches =
|
||||
matchesJson
|
||||
?.map((g) => Match.fromJson(g as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[];
|
||||
final List<Group> importedGroups =
|
||||
groupsJson
|
||||
?.map((g) => Group.fromJson(g as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[];
|
||||
final List<Player> importedPlayers =
|
||||
playersJson
|
||||
?.map((p) => Player.fromJson(p as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[];
|
||||
final List<dynamic> playersJson = (decoded['players'] as List<dynamic>?) ?? [];
|
||||
final List<dynamic> groupsJson = (decoded['groups'] as List<dynamic>?) ?? [];
|
||||
final List<dynamic> matchesJson = (decoded['matches'] as List<dynamic>?) ?? [];
|
||||
|
||||
// Players
|
||||
final List<Player> importedPlayers = playersJson
|
||||
.map((p) => Player.fromJson(p as Map<String, dynamic>))
|
||||
.toList();
|
||||
|
||||
final Map<String, Player> playerById = {
|
||||
for (final p in importedPlayers) p.id: p,
|
||||
};
|
||||
|
||||
// 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.groupDao.addGroupsAsList(groups: importedGroups);
|
||||
await db.matchDao.addMatchAsList(matches: importedMatches);
|
||||
|
||||
await db.playerDao.addPlayersAsList(players: importedPlayers);
|
||||
await db.groupDao.addGroupsAsList(groups: importedGroups);
|
||||
await db.matchDao.addMatchAsList(matches: importedMatches);
|
||||
} else {
|
||||
return ImportResult.invalidSchema;
|
||||
}
|
||||
return ImportResult.success;
|
||||
} on FormatException catch (e, stack) {
|
||||
print('[importData] FormatException');
|
||||
@@ -159,4 +212,4 @@ class DataTransferService {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
pubspec.yaml
32
pubspec.yaml
@@ -1,7 +1,7 @@
|
||||
name: game_tracker
|
||||
description: "Game Tracking App for Card Games"
|
||||
publish_to: 'none'
|
||||
version: 0.0.1+21
|
||||
version: 0.0.5+143
|
||||
|
||||
environment:
|
||||
sdk: ^3.8.1
|
||||
@@ -9,32 +9,32 @@ environment:
|
||||
dependencies:
|
||||
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
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
clock: ^1.1.2
|
||||
cupertino_icons: ^1.0.6
|
||||
drift: ^2.27.0
|
||||
drift_flutter: ^0.2.4
|
||||
file_picker: ^10.3.6
|
||||
file_saver: ^0.3.1
|
||||
font_awesome_flutter: ^10.12.0
|
||||
intl: any
|
||||
json_schema: ^5.2.2
|
||||
package_info_plus: ^9.0.0
|
||||
path_provider: ^2.1.5
|
||||
provider: ^6.1.5
|
||||
skeletonizer: ^2.1.0+1
|
||||
url_launcher: ^6.3.2
|
||||
uuid: ^4.5.2
|
||||
file_picker: ^10.3.6
|
||||
json_schema: ^5.2.2
|
||||
file_saver: ^0.3.1
|
||||
clock: ^1.1.2
|
||||
intl: any
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
auto_localize: ^0.0.5
|
||||
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^5.0.0
|
||||
drift_dev: ^2.27.0
|
||||
build_runner: ^2.5.4
|
||||
dart_pubspec_licenses: ^3.0.14
|
||||
drift_dev: ^2.27.0
|
||||
flutter_lints: ^5.0.0
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
Reference in New Issue
Block a user