1 Commits

Author SHA1 Message Date
areumwoo
00f2ec73d5 LifeTimeView Count/Hour 분리 2026-03-02 15:22:47 +09:00
3 changed files with 45 additions and 46 deletions

View File

@@ -31,7 +31,7 @@ fun HourItemView(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
hour: Int = 0, hour: Int = 0,
onClick: () -> Unit = {}, onClick: () -> Unit = {},
title:String = "" title: String = ""
) { ) {
Row(modifier = modifier, Row(modifier = modifier,
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
@@ -129,4 +129,4 @@ fun PreviewHourItemView() {
title = "Hour Item View" title = "Hour Item View"
) )
} }
} }

View File

@@ -59,7 +59,7 @@ fun LifeTimeView(
// Temp 0..7 // Temp 0..7
for (i in 0..lifeTimeTypes.size -1) { for (i in 0..lifeTimeTypes.size -1) {
val hour = when (i) { val value = when (i) {
0 -> lifeTime.lamp 0 -> lifeTime.lamp
1 -> lifeTime.hp5x5 1 -> lifeTime.hp5x5
2 -> lifeTime.hp7x7 2 -> lifeTime.hp7x7
@@ -70,22 +70,35 @@ fun LifeTimeView(
7 -> lifeTime.water 7 -> lifeTime.water
else -> 0 else -> 0
} }
HourItemView( val modifier = Modifier
modifier = Modifier .fillMaxSize()
.fillMaxSize() .weight(1f)
.weight(1f) .padding(
.padding( start = 20.px.dp,
start = 20.px.dp, end = 20.px.dp,
end = 20.px.dp, //bottom = 10.px.dp
//bottom = 10.px.dp )
), val title = lifeTimeTypes[i]
title = lifeTimeTypes[i], val onItemClick = {
hour = hour, Timber.d("onClick > Temp $i ($title)")
onClick = { onClick.invoke(i)
Timber.d("onClick > Temp $i (${lifeTimeTypes[i]})") }
onClick.invoke(i)
} if (i <= 4) {
) CountItemView(
modifier = modifier,
title = title,
count = value,
onClick = onItemClick
)
} else {
HourItemView(
modifier = modifier,
title = title,
hour = value,
onClick = onItemClick
)
}
if (i < lifeTimeTypes.size -1) { if (i < lifeTimeTypes.size -1) {
HorizontalDivider( HorizontalDivider(
@@ -108,4 +121,4 @@ fun LifeTimeView(
@Composable @Composable
fun PreviewLifeTimeView() { fun PreviewLifeTimeView() {
LifeTimeView() LifeTimeView()
} }

View File

@@ -646,7 +646,7 @@ fun PresetLoadPopup(
Timber.d("onClick - Confirm Save") Timber.d("onClick - Confirm Save")
// Check empty names and conflict priority exist in the preset viewmodel's presetList // Check empty names and conflict priority exist in the preset viewmodel's presetList
var listToValidate = presetViewModel.presetList.value val listToValidate = presetViewModel.presetList.value
// Check for any presets with an empty name // Check for any presets with an empty name
val hasEmptyName = val hasEmptyName =
@@ -678,32 +678,18 @@ fun PresetLoadPopup(
} }
// Check for duplicate priorities (ignoring priority 0) // Check for duplicate priorities (ignoring priority 0)
val duplicatePriorityGroups = listToValidate val priorityConflicts = listToValidate
.filter { it.priority > 0 } .filter { it.priority > 0 } // Only consider prioritized items
.groupBy { it.priority } .groupBy { it.priority } // Group them by priority
.filter { it.value.size > 1 } .any { it.value.size > 1 } // Check if any group is larger than 1
if (duplicatePriorityGroups.isNotEmpty()) { if (priorityConflicts) {
val resolvedList = listToValidate.map { it.copy() }.toMutableList() Toast.makeText(
val selectedPreset = resolvedList.getOrNull(selectedPresetIndex) context,
"There are duplicate priorities. Please ensure each priority is unique.",
duplicatePriorityGroups.forEach { (priorityValue, presets) -> Toast.LENGTH_LONG
val keeperId = presets ).show()
.firstOrNull { preset -> return@noRippleClickable // Stop the process
selectedPreset != null && preset.id == selectedPreset.id
}
?.id
?: presets.first().id
resolvedList.forEachIndexed { index, preset ->
if (preset.priority == priorityValue && preset.id != keeperId) {
resolvedList[index] = preset.copy(priority = 0)
}
}
}
presetViewModel.setPresetList(resolvedList)
listToValidate = resolvedList
} }
Timber.d("Validation successful. Saving list to MainViewModel.") Timber.d("Validation successful. Saving list to MainViewModel.")