Improvements
try to make it run on Android (finally!)
This commit is contained in:
@@ -8,7 +8,7 @@ plugins {
|
||||
kotlin {
|
||||
jvmToolchain(libs.versions.jdk.get().toInt())
|
||||
|
||||
jvm("desktop")
|
||||
jvm()
|
||||
androidTarget()
|
||||
|
||||
// @OptIn(ExperimentalWasmDsl::class)
|
||||
@@ -19,29 +19,33 @@ kotlin {
|
||||
// }
|
||||
|
||||
sourceSets {
|
||||
val androidMain by getting
|
||||
val commonTest by getting
|
||||
commonMain {
|
||||
dependencies {
|
||||
api(projects.domain)
|
||||
|
||||
commonMain.dependencies {
|
||||
api(projects.domain)
|
||||
|
||||
implementation(compose.components.resources)
|
||||
implementation(compose.runtime)
|
||||
implementation(compose.foundation)
|
||||
implementation(compose.material3)
|
||||
implementation(compose.ui)
|
||||
implementation(compose.components.uiToolingPreview)
|
||||
implementation(compose.components.resources)
|
||||
implementation(compose.runtime)
|
||||
implementation(compose.foundation)
|
||||
implementation(compose.material3)
|
||||
implementation(compose.ui)
|
||||
implementation(compose.components.uiToolingPreview)
|
||||
// implementation(libs.compose.ui.text.googlefonts)
|
||||
|
||||
implementation(libs.logging)
|
||||
}
|
||||
androidMain.dependencies {
|
||||
implementation(libs.androidx.compose.foundation)
|
||||
implementation(libs.logging)
|
||||
}
|
||||
}
|
||||
|
||||
commonTest.dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
implementation(libs.atrium)
|
||||
androidMain {
|
||||
dependencies {
|
||||
implementation(libs.androidx.compose.foundation)
|
||||
}
|
||||
}
|
||||
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
implementation(libs.atrium)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
actual fun Modifier.onPointerAction(
|
||||
primary: () -> Unit,
|
||||
secondary: () -> Unit
|
||||
): Modifier {
|
||||
return this
|
||||
.combinedClickable(
|
||||
onClick = primary,
|
||||
onLongClick = secondary
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.PointerMatcher
|
||||
import androidx.compose.foundation.PointerMatcher.Companion.mouse
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
@@ -14,7 +11,6 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.onClick
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -29,7 +25,6 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.input.pointer.PointerButton.Companion.Secondary
|
||||
import androidx.compose.ui.unit.TextUnit
|
||||
import androidx.compose.ui.unit.TextUnitType
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -186,11 +181,10 @@ fun PuzzleClues(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
private fun Modifier.forClue(clue: DisplayClue<out Clue>) = this
|
||||
private fun Modifier.forClue(clue: DisplayClue<out Clue>): Modifier = this
|
||||
.alpha(if (clue.isActive) 1f else 0.2f)
|
||||
.padding(8.dp)
|
||||
.onClick(matcher = PointerMatcher.Primary + mouse(Secondary)) { clue.isActive = !clue.isActive }
|
||||
.onEitherPointerAction { clue.isActive = !clue.isActive }
|
||||
|
||||
@Composable
|
||||
fun HorizontalClue(modifier: Modifier = Modifier, clue: HorizontalClue, isClueViolated: Boolean) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
expect fun Modifier.onPointerAction(primary: () -> Unit = {}, secondary: () -> Unit = {}): Modifier
|
||||
|
||||
fun Modifier.onEitherPointerAction(action: () -> Unit): Modifier =
|
||||
onPointerAction(primary = action, secondary = action)
|
||||
@@ -1,6 +1,7 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -14,7 +15,6 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.input.pointer.PointerButton
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.drawText
|
||||
import androidx.compose.ui.text.rememberTextMeasurer
|
||||
@@ -23,7 +23,6 @@ import ch.dissem.yaep.domain.ItemClass
|
||||
import ch.dissem.yaep.ui.common.theme.emojiFontFamily
|
||||
import kotlin.math.min
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun <C : ItemClass<C>> Selector(
|
||||
modifier: Modifier = Modifier,
|
||||
@@ -48,13 +47,9 @@ fun <C : ItemClass<C>> Selector(
|
||||
item = option.item,
|
||||
modifier = Modifier
|
||||
.alpha(if (option.enabled) 1f else 0.1f)
|
||||
.combinedClickable(
|
||||
onClick = { onSelectItem(option.item) },
|
||||
onLongClick = { option.enabled = false }
|
||||
)
|
||||
.onClick(
|
||||
matcher = PointerMatcher.mouse(PointerButton.Secondary),
|
||||
onClick = {
|
||||
.onPointerAction(
|
||||
primary = { onSelectItem(option.item) },
|
||||
secondary = {
|
||||
if (option.enabled) {
|
||||
option.enabled = false
|
||||
onOptionRemoved(option.item)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.PointerMatcher
|
||||
import androidx.compose.foundation.PointerMatcher.Companion.mouse
|
||||
import androidx.compose.foundation.onClick
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.pointer.PointerButton.Companion.Secondary
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
actual fun Modifier.onPointerAction(primary: () -> Unit, secondary: () -> Unit): Modifier {
|
||||
return this
|
||||
.onClick(matcher = PointerMatcher.Primary, onClick = primary)
|
||||
.onClick(matcher = mouse(Secondary), onClick = secondary)
|
||||
}
|
||||
@@ -16,6 +16,8 @@ kotlin {
|
||||
// binaries.executable()
|
||||
// }
|
||||
|
||||
// linuxX64()
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
|
||||
@@ -5,9 +5,9 @@ android-compileSdk = "34"
|
||||
android-minSdk = "24"
|
||||
android-targetSdk = "34"
|
||||
androidx-activityCompose = "1.9.1"
|
||||
androidx-compose = "1.6.7"
|
||||
androidx-compose = "1.6.8"
|
||||
compose-plugin = "1.6.11"
|
||||
kotlin = "2.0.0"
|
||||
kotlin = "2.0.20"
|
||||
coreKtx = "1.13.1"
|
||||
atrium = "1.2.0"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user