Compare commits
2 Commits
feature/IS
...
feature/IS
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cba0674cf | ||
|
|
b87d911cea |
@@ -108,15 +108,15 @@ fun PresetIconButton(
|
|||||||
Image(
|
Image(
|
||||||
painter = painterResource(id =
|
painter = painterResource(id =
|
||||||
if (type == PresetButtonType.SAVE) {
|
if (type == PresetButtonType.SAVE) {
|
||||||
R.drawable.ic_preset_save
|
R.drawable.ic_preset_save2
|
||||||
} else {
|
} else {
|
||||||
R.drawable.ic_preset_load
|
R.drawable.ic_preset_load
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
contentDescription = "",
|
contentDescription = "",
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(20.px.dp),
|
.size(30.px.dp),
|
||||||
contentScale = ContentScale.Crop
|
contentScale = ContentScale.Fit
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -552,12 +552,12 @@ fun PresetLoadPopup(
|
|||||||
horizontalArrangement = Arrangement.Center,
|
horizontalArrangement = Arrangement.Center,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Spacer(Modifier.weight(1f))
|
|
||||||
|
|
||||||
if (isEditMode) {
|
if (isEditMode) {
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
// Edit Mode
|
// Edit Mode
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.width(10.px.dp))
|
||||||
|
|
||||||
// Preset Delete (Delete confirm popup)
|
// Preset Delete (Delete confirm popup)
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -578,7 +578,7 @@ fun PresetLoadPopup(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(Modifier.width(10.px.dp))
|
Spacer(Modifier.weight(1f))
|
||||||
|
|
||||||
// Preset Cancel (Reload selected item from mainViewModel)
|
// Preset Cancel (Reload selected item from mainViewModel)
|
||||||
Box(
|
Box(
|
||||||
@@ -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.")
|
||||||
@@ -743,7 +729,11 @@ fun PresetLoadPopup(
|
|||||||
contentScale = ContentScale.Crop
|
contentScale = ContentScale.Crop
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.width(10.px.dp))
|
||||||
} else {
|
} else {
|
||||||
|
Spacer(Modifier.weight(1f))
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
// Select Mode - hide Keyboard
|
// Select Mode - hide Keyboard
|
||||||
focusManager.clearFocus(force = true) // Hide the keyboard
|
focusManager.clearFocus(force = true) // Hide the keyboard
|
||||||
@@ -804,6 +794,8 @@ fun PresetLoadPopup(
|
|||||||
contentScale = ContentScale.Crop
|
contentScale = ContentScale.Crop
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.width(10.px.dp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user