Android UI (WIP)
This commit is contained in:
@@ -13,8 +13,8 @@ android {
|
||||
applicationId = "ch.dissem.yaep"
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
versionCode = libs.versions.app.version.code.get().toInt()
|
||||
versionName = libs.versions.app.version.name.get()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -56,4 +56,5 @@ android {
|
||||
}
|
||||
dependencies {
|
||||
implementation(libs.androidx.core.ktx)
|
||||
debugImplementation(libs.androidx.tooling)
|
||||
}
|
||||
|
||||
@@ -4,23 +4,69 @@ import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.CenterAlignedTopAppBar
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import ch.dissem.yaep.domain.Game
|
||||
import ch.dissem.yaep.domain.generateGame
|
||||
import ch.dissem.yaep.ui.common.App
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import yaep.commonui.generated.resources.action_restart
|
||||
import yaep.commonui.generated.resources.app_name
|
||||
import yaep.commonui.generated.resources.restart
|
||||
import yaep.commonui.generated.resources.Res as CRes
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
var game by remember { mutableStateOf<Game>(generateGame()) }
|
||||
var resetCluesBeacon by remember { mutableStateOf(Any()) }
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
|
||||
CenterAlignedTopAppBar(
|
||||
title = {
|
||||
Text(text = stringResource(CRes.string.app_name))
|
||||
},
|
||||
navigationIcon = { },
|
||||
actions = {
|
||||
IconButton(
|
||||
onClick = {
|
||||
do {
|
||||
// continue
|
||||
} while (game.grid.undo())
|
||||
resetCluesBeacon = Any()
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(CRes.drawable.action_restart),
|
||||
contentDescription = stringResource(CRes.string.restart)
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
) { insets ->
|
||||
App(modifier = Modifier.padding(insets))
|
||||
App(
|
||||
modifier = Modifier.padding(insets),
|
||||
game = game,
|
||||
onNewGame = { game = generateGame() },
|
||||
resetCluesBeacon = resetCluesBeacon
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,5 +75,12 @@ class MainActivity : ComponentActivity() {
|
||||
@Preview
|
||||
@Composable
|
||||
fun AppAndroidPreview() {
|
||||
App()
|
||||
var game by remember { mutableStateOf<Game>(generateGame()) }
|
||||
var resetCluesBeacon by remember { mutableStateOf(Any()) }
|
||||
|
||||
App(
|
||||
game = game,
|
||||
onNewGame = { game = generateGame() },
|
||||
resetCluesBeacon = resetCluesBeacon
|
||||
)
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ android {
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
namespace = "ch.dissem.yaep.common.ui"
|
||||
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ compose.desktop {
|
||||
nativeDistributions {
|
||||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
|
||||
packageName = "YAEP"
|
||||
packageVersion = "1.0.0"
|
||||
packageVersion = libs.versions.app.version.name.get()
|
||||
macOS {
|
||||
iconFile.set(project.file("icon.icns"))
|
||||
}
|
||||
|
||||
@@ -37,4 +37,14 @@ kotlin {
|
||||
android {
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
namespace = "ch.dissem.yaep.domain"
|
||||
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
getByName("test") {
|
||||
resources.srcDirs("src/commonTest/resources")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class GameSolverTest {
|
||||
|
||||
@Test
|
||||
fun `ensure game can be solved`() {
|
||||
val gameString = this.javaClass.classLoader.getResourceAsStream("games/001.yaep")!!
|
||||
val gameString = this::class.java.getResourceAsStream("/games/001.yaep")!!
|
||||
.bufferedReader()
|
||||
.readText()
|
||||
val game = Game.parse(gameString)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
[versions]
|
||||
app-version-code = "1"
|
||||
app-version-name = "1.0.0"
|
||||
agp = "8.10.1"
|
||||
jdk = "21"
|
||||
android-compileSdk = "35"
|
||||
@@ -13,6 +15,7 @@ atrium = "1.2.0"
|
||||
|
||||
[libraries]
|
||||
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
|
||||
androidx-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "androidx-compose" }
|
||||
androidx-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "androidx-compose" }
|
||||
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "androidx-compose" }
|
||||
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
|
||||
@@ -23,7 +26,7 @@ logging-jvm = { module = "io.github.oshai:kotlin-logging-jvm", version = "7.0.7"
|
||||
logging-slf4j = { module = "org.slf4j:slf4j-simple", version = "2.0.17" }
|
||||
|
||||
[bundles]
|
||||
logging = [ "logging-jvm", "logging-slf4j" ]
|
||||
logging = ["logging-jvm", "logging-slf4j"]
|
||||
|
||||
[plugins]
|
||||
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
|
||||
|
||||
Reference in New Issue
Block a user