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