fix: placing user at header 2

This commit is contained in:
2026-05-22 14:52:30 +02:00
parent a0897d4966
commit 96037e6062
2 changed files with 17 additions and 10 deletions

View File

@@ -201,13 +201,13 @@ class _ManageMembersViewState extends State<ManageMembersView> {
if (newIndex > oldIndex) targetIndex -= 1; if (newIndex > oldIndex) targetIndex -= 1;
targetIndex = targetIndex.clamp(0, allItemsCount - 1); targetIndex = targetIndex.clamp(0, allItemsCount - 1);
// Resolve target location based on the item currently at targetIndex // Resolve target location based on the item currently
// before the move. // at targetIndex before the move.
int destTeamIndex; int destTeamIndex;
int insertPositionInTeam; int insertPositionInTeam;
if (targetIndex >= allItemsCount - 1 && newIndex >= allItemsCount) { if (targetIndex >= allItemsCount - 1 && newIndex >= allItemsCount) {
// Dropped at the very end, append to the last team. // dropped at the very end, append to the last team.
destTeamIndex = teams.length - 1; destTeamIndex = teams.length - 1;
insertPositionInTeam = teams[destTeamIndex].members.length; insertPositionInTeam = teams[destTeamIndex].members.length;
} else { } else {
@@ -215,14 +215,21 @@ class _ManageMembersViewState extends State<ManageMembersView> {
final anchorMemberIndex = memberIndexForFlat(targetIndex, destTeamIndex); final anchorMemberIndex = memberIndexForFlat(targetIndex, destTeamIndex);
if (anchorMemberIndex == -1) { if (anchorMemberIndex == -1) {
// Dropped right before a header, append to the previous team. // dropped on a header, direction decides which team the player gets added
destTeamIndex = destTeamIndex - 1; // if moving down, insert as first member of that team.
if (destTeamIndex < 0) { // if moving UP, append to the previous team.
// Dropped above the very first header, stay in team 0 at top. final isMovingDown = newIndex > oldIndex;
destTeamIndex = 0; if (isMovingDown) {
insertPositionInTeam = 0; insertPositionInTeam = 0;
} else { } else {
insertPositionInTeam = teams[destTeamIndex].members.length; final previousTeamIndex = destTeamIndex - 1;
if (previousTeamIndex < 0) {
// above the very first header, stay at top of team 0.
insertPositionInTeam = 0;
} else {
destTeamIndex = previousTeamIndex;
insertPositionInTeam = teams[destTeamIndex].members.length;
}
} }
} else { } else {
insertPositionInTeam = anchorMemberIndex; insertPositionInTeam = anchorMemberIndex;

View File

@@ -1,7 +1,7 @@
name: tallee name: tallee
description: "Tracking App for Card Games" description: "Tracking App for Card Games"
publish_to: 'none' publish_to: 'none'
version: 0.0.30+333 version: 0.0.30+334
environment: environment:
sdk: ^3.8.1 sdk: ^3.8.1