Skip to content

Commit

Permalink
fix header selector size not matching sort size
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcarter11 committed Oct 13, 2024
1 parent e027f4d commit f6b08dc
Showing 1 changed file with 49 additions and 40 deletions.
89 changes: 49 additions & 40 deletions app/src/main/java/com/dd3boh/outertune/ui/component/SelectHeader.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.dd3boh.outertune.ui.component

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Close
import androidx.compose.material.icons.rounded.Deselect
Expand All @@ -11,7 +13,9 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.dd3boh.outertune.models.MediaMetadata
import com.dd3boh.outertune.ui.menu.SelectionMediaMetadataMenu

Expand All @@ -25,51 +29,56 @@ fun RowScope.SelectHeader(
onDismiss: () -> Unit = {},
onRemoveFromHistory: (() -> Unit)? = null
) {
Text(
text = "${selectedItems.size}/${totalItemCount} selected",
modifier = Modifier.weight(1f)
)
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.padding(top = 2.dp, bottom = 3.dp)
) {
Text(
text = "${selectedItems.size}/${totalItemCount} selected",
modifier = Modifier.weight(1f)
)

// option menu
IconButton(
onClick = {
menuState.show {
SelectionMediaMetadataMenu(
selection = selectedItems,
onDismiss = menuState::dismiss,
clearAction = onDeselectAll,
onRemoveFromHistory = onRemoveFromHistory
)
// option menu
IconButton(
onClick = {
menuState.show {
SelectionMediaMetadataMenu(
selection = selectedItems,
onDismiss = menuState::dismiss,
clearAction = onDeselectAll,
onRemoveFromHistory = onRemoveFromHistory
)
}
}
) {
Icon(
Icons.Rounded.MoreVert,
contentDescription = null,
tint = LocalContentColor.current
)
}
) {
Icon(
Icons.Rounded.MoreVert,
contentDescription = null,
tint = LocalContentColor.current
)
}

// select/deselect all
val allSelected = selectedItems.size < totalItemCount
// select/deselect all
val allSelected = selectedItems.size < totalItemCount

IconButton(
onClick = if (allSelected) onSelectAll else onDeselectAll
) {
Icon(
imageVector = if (allSelected) Icons.Rounded.SelectAll else Icons.Rounded.Deselect,
contentDescription = null,
tint = LocalContentColor.current
)
}
IconButton(
onClick = if (allSelected) onSelectAll else onDeselectAll
) {
Icon(
imageVector = if (allSelected) Icons.Rounded.SelectAll else Icons.Rounded.Deselect,
contentDescription = null,
tint = LocalContentColor.current
)
}

// close selection mode
IconButton(
onClick = onDismiss,
) {
Icon(
Icons.Rounded.Close,
contentDescription = null
)
// close selection mode
IconButton(
onClick = onDismiss,
) {
Icon(
Icons.Rounded.Close,
contentDescription = null
)
}
}
}

0 comments on commit f6b08dc

Please sign in to comment.