Fix some rendering issues
This commit is contained in:
@@ -2,6 +2,7 @@ plugins {
|
|||||||
alias(libs.plugins.android.application)
|
alias(libs.plugins.android.application)
|
||||||
alias(libs.plugins.kotlin.compose)
|
alias(libs.plugins.kotlin.compose)
|
||||||
alias(libs.plugins.compose)
|
alias(libs.plugins.compose)
|
||||||
|
alias(libs.plugins.jetbrains.kotlin.android)
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@@ -26,15 +27,16 @@ android {
|
|||||||
implementation(libs.androidx.activity.compose)
|
implementation(libs.androidx.activity.compose)
|
||||||
// implementation(libs.compose.ui.text.googlefonts)
|
// implementation(libs.compose.ui.text.googlefonts)
|
||||||
implementation(projects.commonUI)
|
implementation(projects.commonUI)
|
||||||
implementation(compose.components.uiToolingPreview)
|
// implementation(compose.components.uiToolingPreview)
|
||||||
|
implementation(libs.androidx.tooling.preview)
|
||||||
|
|
||||||
testImplementation(libs.kotlin.test)
|
testImplementation(libs.kotlin.test)
|
||||||
testImplementation(libs.atrium)
|
testImplementation(libs.atrium)
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@@ -48,4 +50,10 @@ android {
|
|||||||
merges += "/META-INF/{AL2.0,LGPL2.1}"
|
merges += "/META-INF/{AL2.0,LGPL2.1}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "17"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.androidx.core.ktx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ 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.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import ch.dissem.yaep.ui.common.App
|
import ch.dissem.yaep.ui.common.App
|
||||||
import org.jetbrains.compose.ui.tooling.preview.Preview
|
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ plugins {
|
|||||||
alias(libs.plugins.kotlin.compose) apply false
|
alias(libs.plugins.kotlin.compose) apply false
|
||||||
alias(libs.plugins.kotlin.multiplatform) apply false
|
alias(libs.plugins.kotlin.multiplatform) apply false
|
||||||
alias(libs.plugins.kotlin.jvm) apply false
|
alias(libs.plugins.kotlin.jvm) apply false
|
||||||
|
alias(libs.plugins.jetbrains.kotlin.android) apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinJvmCompile>().configureEach {
|
tasks.withType<KotlinJvmCompile>().configureEach {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ kotlin {
|
|||||||
jvmToolchain(11)
|
jvmToolchain(11)
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
api(projects.domain)
|
||||||
|
|
||||||
implementation(compose.components.resources)
|
implementation(compose.components.resources)
|
||||||
implementation(compose.runtime)
|
implementation(compose.runtime)
|
||||||
implementation(compose.foundation)
|
implementation(compose.foundation)
|
||||||
@@ -16,7 +18,6 @@ kotlin {
|
|||||||
implementation(compose.components.resources)
|
implementation(compose.components.resources)
|
||||||
implementation(compose.components.uiToolingPreview)
|
implementation(compose.components.uiToolingPreview)
|
||||||
// implementation(libs.compose.ui.text.googlefonts)
|
// implementation(libs.compose.ui.text.googlefonts)
|
||||||
implementation(projects.domain)
|
|
||||||
|
|
||||||
testImplementation(libs.kotlin.test)
|
testImplementation(libs.kotlin.test)
|
||||||
testImplementation(libs.atrium)
|
testImplementation(libs.atrium)
|
||||||
|
|||||||
10
commonUI/src/main/composeResources/drawable/lightbulb.xml
Normal file
10
commonUI/src/main/composeResources/drawable/lightbulb.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="#fff"
|
||||||
|
android:pathData="M480,880Q447,880 423.5,856.5Q400,833 400,800L560,800Q560,833 536.5,856.5Q513,880 480,880ZM320,760L320,680L640,680L640,760L320,760ZM330,640Q261,599 220.5,530Q180,461 180,380Q180,255 267.5,167.5Q355,80 480,80Q605,80 692.5,167.5Q780,255 780,380Q780,461 739.5,530Q699,599 630,640L330,640ZM354,560L606,560Q651,528 675.5,481Q700,434 700,380Q700,288 636,224Q572,160 480,160Q388,160 324,224Q260,288 260,380Q260,434 284.5,481Q309,528 354,560ZM480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Z"/>
|
||||||
|
</vector>
|
||||||
@@ -5,11 +5,15 @@ import androidx.compose.foundation.clickable
|
|||||||
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
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
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.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.GridItemSpan
|
||||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||||
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.OutlinedCard
|
import androidx.compose.material3.OutlinedCard
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@@ -43,8 +47,8 @@ fun App(modifier: Modifier = Modifier) {
|
|||||||
val horizontalClues = remember { game.horizontalClues.map { DisplayClue(it) } }
|
val horizontalClues = remember { game.horizontalClues.map { DisplayClue(it) } }
|
||||||
val verticalClues = remember { game.verticalClues.map { DisplayClue(it) } }
|
val verticalClues = remember { game.verticalClues.map { DisplayClue(it) } }
|
||||||
Row(modifier = modifier) {
|
Row(modifier = modifier) {
|
||||||
PuzzleGrid(modifier = Modifier.weight(1f), game.grid)
|
PuzzleGrid(modifier = Modifier.aspectRatio(1f).weight(0.6f).fillMaxHeight(), game.grid)
|
||||||
PuzzleClues(modifier = Modifier.weight(1f), horizontalClues, verticalClues)
|
PuzzleClues(modifier = Modifier.weight(0.4f).fillMaxHeight(), horizontalClues, verticalClues)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +67,7 @@ fun PuzzleGrid(
|
|||||||
for (item in row) {
|
for (item in row) {
|
||||||
Selector(
|
Selector(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(4.dp)
|
.padding(8.dp)
|
||||||
.weight(1f),
|
.weight(1f),
|
||||||
category = row.category,
|
category = row.category,
|
||||||
options = item.options,
|
options = item.options,
|
||||||
@@ -84,13 +88,15 @@ fun PuzzleClues(
|
|||||||
) {
|
) {
|
||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
LazyVerticalGrid(
|
LazyVerticalGrid(
|
||||||
modifier = Modifier.fillMaxWidth().weight(1f),
|
modifier = Modifier.fillMaxSize(),
|
||||||
columns = GridCells.Adaptive(32.dp)
|
columns = GridCells.Fixed(4)
|
||||||
) {
|
) {
|
||||||
for (clue in horizontalClues.filter { it.isActive }) {
|
for (clue in horizontalClues.filter { it.isActive }) {
|
||||||
item {
|
item {
|
||||||
HorizontalClue(
|
HorizontalClue(
|
||||||
modifier = Modifier.clickable { clue.isActive = false },
|
modifier = Modifier
|
||||||
|
.padding(8.dp)
|
||||||
|
.clickable { clue.isActive = false },
|
||||||
clue = clue.clue
|
clue = clue.clue
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -100,21 +106,22 @@ fun PuzzleClues(
|
|||||||
HorizontalClue(
|
HorizontalClue(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.alpha(0.5f)
|
.alpha(0.5f)
|
||||||
|
.padding(8.dp)
|
||||||
.clickable { clue.isActive = true },
|
.clickable { clue.isActive = true },
|
||||||
clue = clue.clue
|
clue = clue.clue
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
item(span = { GridItemSpan(maxLineSpan) }) {
|
||||||
|
HorizontalDivider()
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyVerticalGrid(
|
|
||||||
modifier = Modifier.fillMaxWidth().weight(1f),
|
|
||||||
columns = GridCells.Adaptive(32.dp)
|
|
||||||
) {
|
|
||||||
for (clue in verticalClues.filter { it.isActive }) {
|
for (clue in verticalClues.filter { it.isActive }) {
|
||||||
item {
|
item {
|
||||||
VerticalClue(
|
VerticalClue(
|
||||||
modifier = Modifier.clickable { clue.isActive = false },
|
modifier = Modifier
|
||||||
|
.padding(8.dp)
|
||||||
|
.aspectRatio(0.3333f)
|
||||||
|
.clickable { clue.isActive = false },
|
||||||
clue = clue.clue
|
clue = clue.clue
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -124,6 +131,8 @@ fun PuzzleClues(
|
|||||||
VerticalClue(
|
VerticalClue(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.alpha(0.5f)
|
.alpha(0.5f)
|
||||||
|
.padding(8.dp)
|
||||||
|
.aspectRatio(0.3333f)
|
||||||
.clickable { clue.isActive = true },
|
.clickable { clue.isActive = true },
|
||||||
clue = clue.clue
|
clue = clue.clue
|
||||||
)
|
)
|
||||||
@@ -135,24 +144,26 @@ fun PuzzleClues(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HorizontalClue(modifier: Modifier = Modifier, clue: HorizontalClue) {
|
fun HorizontalClue(modifier: Modifier = Modifier, clue: HorizontalClue) {
|
||||||
Column {
|
OutlinedCard(modifier) {
|
||||||
|
Row {
|
||||||
when (clue) {
|
when (clue) {
|
||||||
is NeighbourClue<*, *> -> {
|
is NeighbourClue<*, *> -> {
|
||||||
DrawItem(modifier = Modifier.weight(1f), clue.a)
|
DrawItem(modifier = Modifier.weight(1f), clue.a)
|
||||||
OutlinedCard(modifier = modifier.aspectRatio(1f).weight(1f)) {
|
|
||||||
Image(
|
Image(
|
||||||
|
modifier = Modifier.aspectRatio(1f).weight(1f),
|
||||||
painter = painterResource(Res.drawable.neighbour),
|
painter = painterResource(Res.drawable.neighbour),
|
||||||
contentDescription = null
|
contentDescription = null
|
||||||
)
|
)
|
||||||
}
|
|
||||||
DrawItem(modifier = Modifier.weight(1f), clue.b)
|
DrawItem(modifier = Modifier.weight(1f), clue.b)
|
||||||
}
|
}
|
||||||
|
|
||||||
is OrderClue<*, *> -> {
|
is OrderClue<*, *> -> {
|
||||||
DrawItem(modifier = Modifier.weight(1f), clue.left)
|
DrawItem(modifier = Modifier.weight(1f), clue.left)
|
||||||
OutlinedCard(modifier = modifier.aspectRatio(1f).weight(1f)) {
|
Image(
|
||||||
Image(painter = painterResource(Res.drawable.order), contentDescription = null)
|
modifier = Modifier.aspectRatio(1f).weight(1f),
|
||||||
}
|
painter = painterResource(Res.drawable.order),
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
DrawItem(modifier = Modifier.weight(1f), clue.right)
|
DrawItem(modifier = Modifier.weight(1f), clue.right)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,11 +175,14 @@ fun HorizontalClue(modifier: Modifier = Modifier, clue: HorizontalClue) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun VerticalClue(modifier: Modifier = Modifier, clue: SameColumnClue<*, *>) {
|
fun VerticalClue(modifier: Modifier = Modifier, clue: SameColumnClue<*, *>) {
|
||||||
Column(modifier = modifier) {
|
OutlinedCard(modifier) {
|
||||||
|
Column {
|
||||||
DrawItem(modifier = Modifier.weight(1f), clue.a)
|
DrawItem(modifier = Modifier.weight(1f), clue.a)
|
||||||
DrawItem(modifier = Modifier.weight(1f), clue.b)
|
DrawItem(modifier = Modifier.weight(1f), clue.b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -88,3 +88,4 @@ fun <C : ItemClass<C>> DrawItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import androidx.compose.ui.window.WindowState
|
|||||||
import ch.dissem.yaep.ui.common.theme.AppTheme
|
import ch.dissem.yaep.ui.common.theme.AppTheme
|
||||||
import org.jetbrains.compose.resources.painterResource
|
import org.jetbrains.compose.resources.painterResource
|
||||||
import yaep.commonui.generated.resources.Res
|
import yaep.commonui.generated.resources.Res
|
||||||
|
import yaep.commonui.generated.resources.lightbulb
|
||||||
import yaep.commonui.generated.resources.moon
|
import yaep.commonui.generated.resources.moon
|
||||||
import yaep.commonui.generated.resources.sun
|
import yaep.commonui.generated.resources.sun
|
||||||
import yaep.commonui.generated.resources.window_close
|
import yaep.commonui.generated.resources.window_close
|
||||||
@@ -55,7 +56,7 @@ fun AppBar(
|
|||||||
) {
|
) {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
// TODO Icon(painterResource(Res.drawable.heart), null)
|
Icon(painterResource(Res.drawable.lightbulb), null)
|
||||||
},
|
},
|
||||||
title = { Text(text = "Yet Another Einstein Puzzle") },
|
title = { Text(text = "Yet Another Einstein Puzzle") },
|
||||||
actions = {
|
actions = {
|
||||||
|
|||||||
@@ -26,11 +26,15 @@ fun main() = application {
|
|||||||
style = FontStyle.Normal
|
style = FontStyle.Normal
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
val windowState = rememberWindowState(
|
||||||
|
placement = WindowPlacement.Floating
|
||||||
|
)
|
||||||
|
|
||||||
Window(
|
Window(
|
||||||
onCloseRequest = ::exitApplication,
|
onCloseRequest = ::exitApplication,
|
||||||
undecorated = true,
|
undecorated = true,
|
||||||
title = "YAEP",
|
title = "YAEP",
|
||||||
|
state = windowState,
|
||||||
icon = painterResource(Res.drawable.moon)
|
icon = painterResource(Res.drawable.moon)
|
||||||
) {
|
) {
|
||||||
var useDarkMode by remember { mutableStateOf(true) }
|
var useDarkMode by remember { mutableStateOf(true) }
|
||||||
@@ -41,9 +45,7 @@ fun main() = application {
|
|||||||
useDarkMode = useDarkMode,
|
useDarkMode = useDarkMode,
|
||||||
setDarkMode = { useDarkMode = it },
|
setDarkMode = { useDarkMode = it },
|
||||||
onCloseRequest = ::exitApplication,
|
onCloseRequest = ::exitApplication,
|
||||||
windowState = rememberWindowState(
|
windowState = windowState
|
||||||
placement = WindowPlacement.Floating
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -4,13 +4,18 @@ android-compileSdk = "34"
|
|||||||
android-minSdk = "24"
|
android-minSdk = "24"
|
||||||
android-targetSdk = "34"
|
android-targetSdk = "34"
|
||||||
androidx-activityCompose = "1.9.0"
|
androidx-activityCompose = "1.9.0"
|
||||||
|
androidx-compose = "1.6.8"
|
||||||
compose-plugin = "1.6.11"
|
compose-plugin = "1.6.11"
|
||||||
kotlin = "2.0.0"
|
kotlin = "2.0.0"
|
||||||
|
kotlinVersion = "2.0.0"
|
||||||
|
coreKtx = "1.13.1"
|
||||||
|
|
||||||
[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-preview = {module="androidx.compose.ui:ui-tooling-preview", 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" }
|
||||||
atrium = { module = "ch.tutteli.atrium:atrium-fluent", version = "1.2.0" }
|
atrium = { module = "ch.tutteli.atrium:atrium-fluent", version = "1.2.0" }
|
||||||
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
@@ -19,3 +24,4 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref
|
|||||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||||
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||||
compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
|
compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
|
||||||
|
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }
|
||||||
|
|||||||
Reference in New Issue
Block a user