From ff408747cdd2611bd60fdce826e77884df71386d Mon Sep 17 00:00:00 2001 From: QIU Date: Tue, 4 Aug 2026 01:10:13 +0000 Subject: [PATCH] fix(settings): drag-reorder tracks live position; grip becomes a single dot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two drag issues from user testing: 1. Only adjacent swaps worked - the drag gesture could not move an item past multiple positions. Root cause: the pointerInput closure kept the index captured at composition; after the live swap (items.add(target, removeAt(index))) the closure's index was stale, so subsequent targets were computed from the wrong origin and the saved order got corrupted (also made previously moved items snap back). Fix: track the dragged item's live position via draggingIndex - onDragStart resolves it with items.indexOf(screen), onDrag computes the target from draggingIndex and updates it after each swap. 2. The six-dot grip icon was ugly; replaced with a single 8dp themed dot (Box + CircleShape inside the 48dp touch area, onSurfaceVariant color). ic_drag.xml removed. What's-new rewritten in en/zh/tr with ONLY this release's changes (user rule: replace, never append history). Version stays 4.4.9 (覆盖 per user). Verified: settings + app compile, check_strings.py clean. --- .../src/main/res/drawable/ic_drag.xml | 10 ------- .../src/main/res/values-tr/strings.xml | 3 +- .../src/main/res/values-zh/strings.xml | 3 +- .../src/main/res/values/strings.xml | 3 +- .../feature/settings/SettingsScreen.kt | 30 ++++++++++++------- 5 files changed, 26 insertions(+), 23 deletions(-) delete mode 100644 core/presentation/src/main/res/drawable/ic_drag.xml diff --git a/core/presentation/src/main/res/drawable/ic_drag.xml b/core/presentation/src/main/res/drawable/ic_drag.xml deleted file mode 100644 index fa9b3221..00000000 --- a/core/presentation/src/main/res/drawable/ic_drag.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - diff --git a/core/presentation/src/main/res/values-tr/strings.xml b/core/presentation/src/main/res/values-tr/strings.xml index da6bada6..3c7c4e0c 100644 --- a/core/presentation/src/main/res/values-tr/strings.xml +++ b/core/presentation/src/main/res/values-tr/strings.xml @@ -51,7 +51,8 @@ \n\nDoğru tahminler alabilmek için veritabanını en az haftada bir güncelleyin. What\'s new in Look4Sat - * Ayarlar sayfasında kaydırırken oluşan çökme düzeltildi (sayfa sırası listesi yüksekliği) + * Ayarlar sayfasında kaydırırken oluşan çökme düzeltildi + * Sayfa sırası: tek hareketle birden fazla konum atlanabilir; tutamaç tek nokta oldu Geri diff --git a/core/presentation/src/main/res/values-zh/strings.xml b/core/presentation/src/main/res/values-zh/strings.xml index 38d4b848..32e5d395 100644 --- a/core/presentation/src/main/res/values-zh/strings.xml +++ b/core/presentation/src/main/res/values-zh/strings.xml @@ -41,7 +41,8 @@ 请务必在设置中通过GPS、经纬度或QTH定位您的位置\n建议至少每周更新一次数据库,以确保预测结果的准确性 Look4Sat Pro 更新内容 - * 修复设置页滑动时闪退的问题(页面顺序列表高度) + * 修复设置页滑动时闪退的问题 + * 页面顺序:可一次拖动越过多个位置;拖拽手柄改为小圆点 后退 diff --git a/core/presentation/src/main/res/values/strings.xml b/core/presentation/src/main/res/values/strings.xml index c0f7fd64..27ca4eba 100644 --- a/core/presentation/src/main/res/values/strings.xml +++ b/core/presentation/src/main/res/values/strings.xml @@ -53,7 +53,8 @@ \n\nPlease update the database at least weekly to get accurate predictions. What\'s new in Look4Sat - * Fixed a crash when scrolling the Settings page (page-order list height) + * Fixed a crash when scrolling the Settings page + * Page order: drag a page past multiple positions in one gesture; grip is now a single dot Back diff --git a/feature/settings/src/main/java/com/rtbishop/look4sat/feature/settings/SettingsScreen.kt b/feature/settings/src/main/java/com/rtbishop/look4sat/feature/settings/SettingsScreen.kt index da43c4a0..30c0b052 100644 --- a/feature/settings/src/main/java/com/rtbishop/look4sat/feature/settings/SettingsScreen.kt +++ b/feature/settings/src/main/java/com/rtbishop/look4sat/feature/settings/SettingsScreen.kt @@ -22,15 +22,19 @@ import android.os.Build import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.clickable +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.layout.width import androidx.compose.foundation.gestures.detectDragGestures import androidx.compose.foundation.layout.height @@ -639,23 +643,22 @@ private fun DragOrderList( text = stringResource(id = screen.first), modifier = Modifier.weight(1f) ) - Icon( - painter = painterResource(id = R.drawable.ic_drag), - contentDescription = stringResource(id = R.string.prefs_ui_order_title), - tint = MaterialTheme.colorScheme.onSurfaceVariant, + Box( modifier = Modifier .size(48.dp) + .padding(20.dp) .pointerInput(screen.second) { detectDragGestures( - onDragStart = { draggingIndex = index }, + onDragStart = { draggingIndex = items.indexOf(screen) }, onDrag = { change, dragAmount -> change.consume() dragOffset += dragAmount.y - val target = (index + (dragOffset / itemHeightPx).roundToInt()) + val currentIndex = draggingIndex + val target = (currentIndex + (dragOffset / itemHeightPx).roundToInt()) .coerceIn(0, items.size - 1) - if (target != index) { - items.add(target, items.removeAt(index)) - dragOffset += (index - target) * itemHeightPx + if (target != currentIndex) { + items.add(target, items.removeAt(currentIndex)) + dragOffset += (currentIndex - target) * itemHeightPx draggingIndex = target } }, @@ -670,7 +673,14 @@ private fun DragOrderList( } ) } - ) + ) { + // 小圆点手柄(触控区 padding 20dp 居中 -> 8dp 圆点) + Box( + modifier = Modifier + .fillMaxSize() + .background(MaterialTheme.colorScheme.onSurfaceVariant, CircleShape) + ) + } } } }