4 Commits

Author SHA1 Message Date
feb2b756bd Merge branch 'development' into feature/118-bearbeiten-und-löschen-von-gruppen
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 37s
Pull Request Pipeline / lint (pull_request) Failing after 45s
2026-03-08 08:39:24 +00:00
bfad74db22 Merge remote-tracking branch 'origin/development' into feature/118-bearbeiten-und-löschen-von-gruppen
All checks were successful
Pull Request Pipeline / lint (pull_request) Successful in 45s
Pull Request Pipeline / test (pull_request) Successful in 40s
# Conflicts:
#	lib/presentation/views/main_menu/group_view/create_group_view.dart
2026-03-08 09:29:06 +01:00
8e20fe1034 fix dart analysis issues
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 37s
Pull Request Pipeline / lint (pull_request) Successful in 46s
2026-03-07 23:34:43 +01:00
81aad9280c Merge dev & implement db
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 39s
Pull Request Pipeline / lint (pull_request) Failing after 44s
2026-03-07 23:33:25 +01:00
2 changed files with 29 additions and 11 deletions

View File

@@ -205,8 +205,6 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
return rowsAffected > 0;
}
/// Retrieves the number of groups in the database.
Future<int> getGroupCount() async {
final count =
@@ -235,10 +233,13 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
/// Replaces all players in a group with the provided list of players.
/// Removes all existing players from the group and adds the new players.
/// Also adds any new players to the player table if they don't exist.
Future<void> replaceGroupPlayers({
/// Returns `true` if the group exists and players were replaced, `false` otherwise.
Future<bool> replaceGroupPlayers({
required String groupId,
required List<Player> newPlayers,
}) async {
if (!await groupExists(groupId: groupId)) return false;
await db.transaction(() async {
// Remove all existing players from the group
final deleteQuery = delete(db.playerGroupTable)
@@ -270,5 +271,6 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
),
);
});
return true;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:tallee/core/constants.dart';
import 'package:tallee/core/custom_theme.dart';
import 'package:tallee/core/enums.dart';
import 'package:tallee/data/db/database.dart';
@@ -122,6 +123,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
child: TextInputField(
controller: _groupNameController,
hintText: loc.group_name,
maxLength: Constants.MAX_GROUP_NAME_LENGTH,
),
),
Expanded(
@@ -145,12 +147,15 @@ class _CreateGroupViewState extends State<CreateGroupView> {
(selectedPlayers.length < 2))
? null
: () async {
late Group? updatedGroup;
Group? updatedGroup;
bool successfullNameChange = true;
bool successfullMemberChange = true;
late bool success;
if (widget.groupToEdit == null) {
success = await db.groupDao.addGroup(
group: Group(
name: _groupNameController.text.trim(),
description: '',
members: selectedPlayers,
),
);
@@ -161,13 +166,24 @@ class _CreateGroupViewState extends State<CreateGroupView> {
description: '',
members: selectedPlayers,
);
//TODO: Implement group editing in database
/*
success = await db.groupDao.updateGroup(
group: updatedGroup,
);
*/
success = true;
if (widget.groupToEdit!.name !=
_groupNameController.text.trim()) {
successfullNameChange = await db.groupDao
.updateGroupName(
groupId: widget.groupToEdit!.id,
newName: _groupNameController.text.trim(),
);
}
if (widget.groupToEdit!.members != selectedPlayers) {
successfullMemberChange = await db.groupDao
.replaceGroupPlayers(
groupId: widget.groupToEdit!.id,
newPlayers: selectedPlayers,
);
}
success =
successfullNameChange && successfullMemberChange;
}
if (!context.mounted) return;
if (success) {