feat: navigate to and locate specific LUT in FilterManagementScreen
This commit is contained in:
1 parent
92e0b01e98
commit
8f067d1c3d
4 files changed
+123
-37
No files matched your search
@@ -95,7 +95,7 @@ object Routes {
|
||||
const val BURST_DETAIL = "burst_detail/{photoId}"
|
||||
const val PHOTO_EDIT = "photo_edit"
|
||||
const val SETTINGS = "settings"
|
||||
const val FILTER_MANAGEMENT = "filter_management"
|
||||
const val FILTER_MANAGEMENT = "filter_management?locateLutId={locateLutId}"
|
||||
const val FRAME_MANAGEMENT = "frame_management"
|
||||
const val FRAME_EDITOR = "frame_editor?frameId={frameId}&imageFrame={imageFrame}"
|
||||
const val LUT_CREATOR = "lut_creator"
|
||||
@@ -104,6 +104,9 @@ object Routes {
|
||||
fun photoDetail(tab: GalleryTab = GalleryTab.PHOTON, index: Int = 0, photoId: String? = null) =
|
||||
"photo_detail/$tab/$index" + (if (photoId != null) "?photoId=$photoId" else "")
|
||||
|
||||
fun filterManagement(locateLutId: String? = null) =
|
||||
"filter_management" + (if (locateLutId != null) "?locateLutId=$locateLutId" else "")
|
||||
|
||||
fun burstDetail(photoId: String) = "burst_detail/$photoId"
|
||||
|
||||
fun frameEditor(frameId: String? = null, imageFrame: Boolean = false): String {
|
||||
@@ -463,8 +466,8 @@ fun NavigationHost(
|
||||
onSettingsClick = {
|
||||
navController.navigate(Routes.SETTINGS)
|
||||
},
|
||||
onFilterManagementClick = {
|
||||
navController.navigate(Routes.FILTER_MANAGEMENT)
|
||||
onFilterManagementClick = { lutId ->
|
||||
navController.navigate(Routes.filterManagement(lutId))
|
||||
},
|
||||
onFrameManagementClick = {
|
||||
navController.navigate(Routes.FRAME_MANAGEMENT)
|
||||
@@ -498,8 +501,8 @@ fun NavigationHost(
|
||||
onSettingsClick = {
|
||||
navController.navigate(Routes.SETTINGS)
|
||||
},
|
||||
onFilterManagementClick = {
|
||||
navController.navigate(Routes.FILTER_MANAGEMENT)
|
||||
onFilterManagementClick = { lutId ->
|
||||
navController.navigate(Routes.filterManagement(lutId))
|
||||
},
|
||||
onFrameManagementClick = {
|
||||
navController.navigate(Routes.FRAME_MANAGEMENT)
|
||||
@@ -612,7 +615,17 @@ fun NavigationHost(
|
||||
)
|
||||
}
|
||||
|
||||
composable(Routes.FILTER_MANAGEMENT) {
|
||||
composable(
|
||||
route = Routes.FILTER_MANAGEMENT,
|
||||
arguments = listOf(
|
||||
navArgument("locateLutId") {
|
||||
type = NavType.StringType
|
||||
nullable = true
|
||||
defaultValue = null
|
||||
}
|
||||
)
|
||||
) { backStackEntry ->
|
||||
val locateLutId = backStackEntry.arguments?.getString("locateLutId")
|
||||
FilterManagementScreen(
|
||||
viewModel = cameraViewModel,
|
||||
onBack = {
|
||||
@@ -622,7 +635,8 @@ fun NavigationHost(
|
||||
navController.navigate(Routes.LUT_CREATOR)
|
||||
},
|
||||
pendingZipImportUris = pendingZipImportUris,
|
||||
onZipImportHandled = onZipImportHandled
|
||||
onZipImportHandled = onZipImportHandled,
|
||||
locateLutId = locateLutId
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ fun CameraScreen(
|
||||
galleryViewModel: GalleryViewModel,
|
||||
onGalleryClick: () -> Unit,
|
||||
onSettingsClick: () -> Unit,
|
||||
onFilterManagementClick: () -> Unit,
|
||||
onFilterManagementClick: (String?) -> Unit,
|
||||
onFrameManagementClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
@@ -1096,7 +1096,7 @@ fun CameraScreen(
|
||||
onMeteringModeChange = { viewModel.setMeteringMode(it) },
|
||||
onFilterManageClick = {
|
||||
activePanel = ActivePanel.NONE
|
||||
onFilterManagementClick()
|
||||
onFilterManagementClick(null)
|
||||
},
|
||||
onFrameManageClick = {
|
||||
activePanel = ActivePanel.NONE
|
||||
@@ -1213,6 +1213,10 @@ fun CameraScreen(
|
||||
onEditClick = {
|
||||
activePanel = ActivePanel.LUT_EDIT
|
||||
},
|
||||
onManageClick = { lutId ->
|
||||
activePanel = ActivePanel.NONE
|
||||
onFilterManagementClick(lutId)
|
||||
},
|
||||
categoryOrder = categoryOrder
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.FilterNone
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material.icons.filled.Tune
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
@@ -61,6 +62,7 @@ fun LutSelector(
|
||||
thumbnail: Bitmap?,
|
||||
onLutSelected: (String?) -> Unit,
|
||||
onEditClick: (() -> Unit)? = null,
|
||||
onManageClick: ((String) -> Unit)? = null,
|
||||
categoryOrder: List<String> = emptyList(),
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
@@ -152,34 +154,51 @@ fun LutSelector(
|
||||
|
||||
Column(modifier = modifier.fillMaxWidth()) {
|
||||
// 分类选择器 (小芯片样式)
|
||||
LazyRow(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 4.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
contentPadding = PaddingValues(horizontal = 8.dp)
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(bottom = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
items(categoryTabs) { category ->
|
||||
val isSelected = selectedCategory == category
|
||||
val categoryName = when (category) {
|
||||
LutCategoryTab.BuiltIn -> builtInText
|
||||
LutCategoryTab.Uncategorized -> uncategorizedText
|
||||
is LutCategoryTab.Category -> category.name
|
||||
}
|
||||
LazyRow(
|
||||
modifier = Modifier.weight(1f),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
contentPadding = PaddingValues(horizontal = 8.dp)
|
||||
) {
|
||||
items(categoryTabs) { category ->
|
||||
val isSelected = selectedCategory == category
|
||||
val categoryName = when (category) {
|
||||
LutCategoryTab.BuiltIn -> builtInText
|
||||
LutCategoryTab.Uncategorized -> uncategorizedText
|
||||
is LutCategoryTab.Category -> category.name
|
||||
}
|
||||
|
||||
Text(
|
||||
text = categoryName,
|
||||
color = if (isSelected) Color(0xFFFF6B35) else Color.White.copy(alpha = 0.5f),
|
||||
fontSize = 12.sp,
|
||||
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Medium,
|
||||
Text(
|
||||
text = categoryName,
|
||||
color = if (isSelected) Color(0xFFFF6B35) else Color.White.copy(alpha = 0.5f),
|
||||
fontSize = 12.sp,
|
||||
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Medium,
|
||||
modifier = Modifier
|
||||
.clickable(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
indication = null
|
||||
) {
|
||||
selectedCategory = category
|
||||
}
|
||||
.padding(vertical = 4.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (onManageClick != null) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Settings,
|
||||
contentDescription = "Manage Filters",
|
||||
tint = Color.White.copy(alpha = 0.6f),
|
||||
modifier = Modifier
|
||||
.clickable(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
indication = null
|
||||
) {
|
||||
selectedCategory = category
|
||||
}
|
||||
.padding(vertical = 4.dp)
|
||||
.padding(end = 12.dp)
|
||||
.size(24.dp)
|
||||
.clip(CircleShape)
|
||||
.clickable { onManageClick(currentLutId ?: "") }
|
||||
.padding(4.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -210,7 +229,10 @@ fun LutSelector(
|
||||
} else {
|
||||
onLutSelected(lut.id)
|
||||
}
|
||||
}
|
||||
},
|
||||
onManageClick = if (onManageClick != null) {
|
||||
{ onManageClick(lut.id) }
|
||||
} else null
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -229,6 +251,7 @@ private fun LutItem(
|
||||
isSelected: Boolean,
|
||||
isVip: Boolean,
|
||||
onClick: () -> Unit,
|
||||
onManageClick: (() -> Unit)? = null,
|
||||
isNone: Boolean = false,
|
||||
isCustom: Boolean = false, // 添加自定义标识参数
|
||||
modifier: Modifier = Modifier
|
||||
@@ -256,7 +279,10 @@ private fun LutItem(
|
||||
color = borderColor,
|
||||
shape = RoundedCornerShape(8.dp)
|
||||
)
|
||||
.clickable { onClick() }
|
||||
.combinedClickable(
|
||||
onClick = onClick,
|
||||
onLongClick = onManageClick
|
||||
)
|
||||
.padding(8.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
|
||||
@@ -85,6 +85,7 @@ fun FilterManagementScreen(
|
||||
onLutCreatorClick: () -> Unit = {},
|
||||
pendingZipImportUris: List<Uri> = emptyList(),
|
||||
onZipImportHandled: () -> Unit = {},
|
||||
locateLutId: String? = null,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val currentLutId by viewModel.currentLutId.collectAsState()
|
||||
@@ -161,6 +162,8 @@ fun FilterManagementScreen(
|
||||
var pendingImportUris by remember { mutableStateOf<List<Uri>>(emptyList()) }
|
||||
var pendingZipUris by remember { mutableStateOf<Set<Uri>>(emptySet()) }
|
||||
|
||||
val lazyListState = rememberLazyListState()
|
||||
|
||||
LaunchedEffect(pendingZipImportUris) {
|
||||
if (pendingZipImportUris.isNotEmpty()) {
|
||||
pendingImportUris = pendingZipImportUris
|
||||
@@ -204,6 +207,46 @@ fun FilterManagementScreen(
|
||||
}
|
||||
}
|
||||
|
||||
var hasLocated by remember(locateLutId) { mutableStateOf(false) }
|
||||
|
||||
LaunchedEffect(locateLutId, localLutList, categories) {
|
||||
if (locateLutId != null && !hasLocated && categories.isNotEmpty()) {
|
||||
val targetLut = localLutList.find { it.id == locateLutId }
|
||||
if (targetLut != null) {
|
||||
val targetCategory = if (targetLut.isBuiltIn) builtInText
|
||||
else if (targetLut.category.isEmpty()) uncategorizedText
|
||||
else targetLut.category
|
||||
|
||||
val categoryIndex = categories.indexOf(targetCategory)
|
||||
|
||||
// 等待页面入场动画完成 (约 350ms),避免与 Navigation 切换动画抢占资源导致掉帧卡顿
|
||||
kotlinx.coroutines.delay(350)
|
||||
|
||||
if (categoryIndex >= 0 && selectedTabIndex != categoryIndex) {
|
||||
selectedTabIndex = categoryIndex
|
||||
// 等待 Tab 切换引起的列表重组完成
|
||||
kotlinx.coroutines.delay(100)
|
||||
}
|
||||
|
||||
// 重新获取过滤后的列表中的索引
|
||||
val filteredLutsNow = if (categoryIndex >= 0 && categoryIndex < categories.size) {
|
||||
when (categories[categoryIndex]) {
|
||||
builtInText -> localLutList.filter { it.isBuiltIn }
|
||||
uncategorizedText -> localLutList.filter { !it.isBuiltIn && it.category.isEmpty() }
|
||||
else -> localLutList.filter { it.category == categories[categoryIndex] }
|
||||
}
|
||||
} else localLutList
|
||||
|
||||
val indexInFiltered = filteredLutsNow.indexOfFirst { it.id == locateLutId }
|
||||
if (indexInFiltered >= 0) {
|
||||
// 使用带动画的滚动,给用户一个明确的"定位"视觉反馈
|
||||
lazyListState.animateScrollToItem(maxOf(0, indexInFiltered - 1))
|
||||
}
|
||||
}
|
||||
hasLocated = true // 标记为已定位,避免后续数据变化时反复触发
|
||||
}
|
||||
}
|
||||
|
||||
// 批量文件选择器
|
||||
val lutFilePicker = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.OpenMultipleDocuments()
|
||||
@@ -283,7 +326,6 @@ fun FilterManagementScreen(
|
||||
}
|
||||
|
||||
// 拖拽排序状态
|
||||
val lazyListState = rememberLazyListState()
|
||||
val reorderableLazyListState = rememberReorderableLazyListState(lazyListState) { from, to ->
|
||||
val fromId = from.key as? String ?: return@rememberReorderableLazyListState
|
||||
val toId = to.key as? String ?: return@rememberReorderableLazyListState
|
||||
|
||||
Reference in new issue
Block a user