Android UI (WIP)
This commit is contained in:
@@ -13,8 +13,8 @@ android {
|
|||||||
applicationId = "ch.dissem.yaep"
|
applicationId = "ch.dissem.yaep"
|
||||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||||
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
||||||
versionCode = 1
|
versionCode = libs.versions.app.version.code.get().toInt()
|
||||||
versionName = "1.0"
|
versionName = libs.versions.app.version.name.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -56,4 +56,5 @@ android {
|
|||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.androidx.core.ktx)
|
implementation(libs.androidx.core.ktx)
|
||||||
|
debugImplementation(libs.androidx.tooling)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,23 +4,69 @@ import android.os.Bundle
|
|||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.compose.foundation.layout.padding
|
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.Scaffold
|
||||||
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
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.Modifier
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
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 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() {
|
class MainActivity : ComponentActivity() {
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
|
var game by remember { mutableStateOf<Game>(generateGame()) }
|
||||||
|
var resetCluesBeacon by remember { mutableStateOf(Any()) }
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
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 ->
|
) { 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
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun AppAndroidPreview() {
|
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()
|
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||||
namespace = "ch.dissem.yaep.common.ui"
|
namespace = "ch.dissem.yaep.common.ui"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||||
|
}
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
compose = true
|
compose = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ compose.desktop {
|
|||||||
nativeDistributions {
|
nativeDistributions {
|
||||||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
|
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
|
||||||
packageName = "YAEP"
|
packageName = "YAEP"
|
||||||
packageVersion = "1.0.0"
|
packageVersion = libs.versions.app.version.name.get()
|
||||||
macOS {
|
macOS {
|
||||||
iconFile.set(project.file("icon.icns"))
|
iconFile.set(project.file("icon.icns"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,14 @@ kotlin {
|
|||||||
android {
|
android {
|
||||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||||
namespace = "ch.dissem.yaep.domain"
|
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
|
@Test
|
||||||
fun `ensure game can be solved`() {
|
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()
|
.bufferedReader()
|
||||||
.readText()
|
.readText()
|
||||||
val game = Game.parse(gameString)
|
val game = Game.parse(gameString)
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
[versions]
|
[versions]
|
||||||
|
app-version-code = "1"
|
||||||
|
app-version-name = "1.0.0"
|
||||||
agp = "8.10.1"
|
agp = "8.10.1"
|
||||||
jdk = "21"
|
jdk = "21"
|
||||||
android-compileSdk = "35"
|
android-compileSdk = "35"
|
||||||
@@ -13,6 +15,7 @@ atrium = "1.2.0"
|
|||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
|
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-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" }
|
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "androidx-compose" }
|
||||||
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
|
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" }
|
logging-slf4j = { module = "org.slf4j:slf4j-simple", version = "2.0.17" }
|
||||||
|
|
||||||
[bundles]
|
[bundles]
|
||||||
logging = [ "logging-jvm", "logging-slf4j" ]
|
logging = ["logging-jvm", "logging-slf4j"]
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
|
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
|
||||||
|
|||||||
Reference in New Issue
Block a user