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

View File

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