|
@@ -1,16 +1,18 @@
|
|
|
package eu.mjdev.desktop.components.appsmenu
|
|
package eu.mjdev.desktop.components.appsmenu
|
|
|
|
|
|
|
|
import androidx.compose.desktop.ui.tooling.preview.Preview
|
|
import androidx.compose.desktop.ui.tooling.preview.Preview
|
|
|
-import androidx.compose.foundation.clickable
|
|
|
|
|
|
|
+import androidx.compose.foundation.ExperimentalFoundationApi
|
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
|
import androidx.compose.foundation.layout.Row
|
|
import androidx.compose.foundation.layout.Row
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
import androidx.compose.foundation.layout.padding
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
+import androidx.compose.foundation.mouseClickable
|
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.runtime.remember
|
|
import androidx.compose.runtime.remember
|
|
|
import androidx.compose.ui.Alignment
|
|
import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.graphics.Color
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
+import androidx.compose.ui.input.pointer.isSecondaryPressed
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
import androidx.compose.ui.unit.DpSize
|
|
import androidx.compose.ui.unit.DpSize
|
|
|
import androidx.compose.ui.unit.dp
|
|
import androidx.compose.ui.unit.dp
|
|
@@ -20,6 +22,8 @@ import eu.mjdev.desktop.data.Category
|
|
|
import eu.mjdev.desktop.provider.DesktopProvider
|
|
import eu.mjdev.desktop.provider.DesktopProvider
|
|
|
import eu.mjdev.desktop.provider.DesktopProvider.Companion.LocalDesktop
|
|
import eu.mjdev.desktop.provider.DesktopProvider.Companion.LocalDesktop
|
|
|
|
|
|
|
|
|
|
+@Suppress("DEPRECATION")
|
|
|
|
|
+@OptIn(ExperimentalFoundationApi::class)
|
|
|
@Preview
|
|
@Preview
|
|
|
@Composable
|
|
@Composable
|
|
|
fun AppsMenuCategory(
|
|
fun AppsMenuCategory(
|
|
@@ -30,9 +34,16 @@ fun AppsMenuCategory(
|
|
|
textColor: Color = Color.White,
|
|
textColor: Color = Color.White,
|
|
|
backgroundColor: Color = Color.White,
|
|
backgroundColor: Color = Color.White,
|
|
|
api: DesktopProvider = LocalDesktop.current,
|
|
api: DesktopProvider = LocalDesktop.current,
|
|
|
- onClick: (category: Category) -> Unit = {}
|
|
|
|
|
|
|
+ onClick: (category: Category) -> Unit = {},
|
|
|
|
|
+ onContextMenuClick: (category: Category) -> Unit = {}
|
|
|
) = Row(
|
|
) = Row(
|
|
|
- modifier = modifier.clickable { onClick(category) },
|
|
|
|
|
|
|
+ modifier = modifier.mouseClickable {
|
|
|
|
|
+ if (buttons.isSecondaryPressed) {
|
|
|
|
|
+ onContextMenuClick(category)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ onClick(category)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
verticalAlignment = Alignment.CenterVertically
|
|
verticalAlignment = Alignment.CenterVertically
|
|
|
) {
|
|
) {
|
|
|
val categoryName = remember(category) { category.name }
|
|
val categoryName = remember(category) { category.name }
|
|
@@ -43,10 +54,10 @@ fun AppsMenuCategory(
|
|
|
iconColor = iconTint,
|
|
iconColor = iconTint,
|
|
|
iconBackgroundColor = backgroundColor,
|
|
iconBackgroundColor = backgroundColor,
|
|
|
outerPadding = PaddingValues(2.dp),
|
|
outerPadding = PaddingValues(2.dp),
|
|
|
- innerPadding = PaddingValues(0.dp)
|
|
|
|
|
- ) {
|
|
|
|
|
- onClick(category)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ innerPadding = PaddingValues(0.dp),
|
|
|
|
|
+ onClick = { onClick(category) },
|
|
|
|
|
+ onRightClick = { onContextMenuClick(category) }
|
|
|
|
|
+ )
|
|
|
TextAny(
|
|
TextAny(
|
|
|
modifier = Modifier.padding(start = 4.dp).fillMaxWidth(),
|
|
modifier = Modifier.padding(start = 4.dp).fillMaxWidth(),
|
|
|
text = category.name,
|
|
text = category.name,
|