Skip to content

Commit

Permalink
[fix]page indicator start counts on 1 not 0
Browse files Browse the repository at this point in the history
[improvement] index != -1, multi selection icon background
  • Loading branch information
Steve-Mr committed Oct 4, 2024
1 parent ec65321 commit e51aa69
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/src/main/java/top/maary/oblivionis/ui/ActionComponents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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.CheckCircle
import androidx.compose.material.icons.filled.Circle
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.RadioButtonUnchecked
import androidx.compose.material3.AlertDialog
Expand Down Expand Up @@ -113,6 +114,8 @@ fun MediaPlayer(

if (isMultiSelectionState) {
// 显示选择框的图标
Icon(imageVector = Icons.Default.Circle, contentDescription = null, tint = if (isSelected) MaterialTheme.colorScheme.primaryContainer else Color.Transparent,
modifier = Modifier.align(Alignment.TopEnd).size(48.dp).padding(8.dp))
Icon(
imageVector = if (isSelected) Icons.Default.CheckCircle else Icons.Default.RadioButtonUnchecked,
contentDescription = if (isSelected) "Selected" else "Not Selected",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fun ActionScreen(
context.startActivity(shareIntent)
},
showRestore = (lastMarked.value.isNotEmpty()),
currentPage = pagerState.currentPage,
currentPage = pagerState.currentPage +1,
pagesCount = images.value.size
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,19 @@ class ActionViewModel(

fun unMarkImage(target: MediaStoreImage) {
val updatedList = _images.value.toMutableList()
updatedList[updatedList.indexOf(target.copy(isMarked = true))] =
target.copy(isMarked = false)
val index = updatedList.indexOf(target.copy(isMarked = true))
if (index == -1) return
updatedList[index] = target.copy(isMarked = false)
databaseUnmark(target.copy(isMarked = true))
_lastMarked.value = _lastMarked.value.filterNot { it == target }
_images.value = updatedList
}

fun includeMedia(target: MediaStoreImage) {
val updatedList = _images.value.toMutableList()
updatedList[updatedList.indexOf(target.copy(isExcluded = true))] =
target.copy(isExcluded = false)
val index = updatedList.indexOf(target.copy(isExcluded = true))
if (index == -1) return
updatedList[index] = target.copy(isExcluded = false)
databaseUnmark(target.copy(isExcluded = true))
_images.value = updatedList
}
Expand Down

0 comments on commit e51aa69

Please sign in to comment.