refactor: replace sample app with list of records

This commit is contained in:
2026-06-09 15:57:38 +02:00
parent f37e71dddd
commit 09deb69d05
16 changed files with 163 additions and 229 deletions
@@ -1,12 +0,0 @@
package fr.ajaury.gwenedeg
import kotlin.test.Test
import kotlin.test.assertEquals
class SharedLogicAndroidHostTest {
@Test
fun example() {
assertEquals(3, 1 + 2)
}
}
@@ -1,9 +0,0 @@
package fr.ajaury.gwenedeg
import android.os.Build
class AndroidPlatform : Platform {
override val name: String = "Android ${Build.VERSION.SDK_INT}"
}
actual fun getPlatform(): Platform = AndroidPlatform()
@@ -1,49 +1,14 @@
package fr.ajaury.gwenedeg
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import org.jetbrains.compose.resources.painterResource
import gwenedeg.shared.generated.resources.Res
import gwenedeg.shared.generated.resources.compose_multiplatform
import fr.ajaury.gwenedeg.records.ui.RecordsScreen
@Composable
@Preview
fun App() {
MaterialTheme {
var showContent by remember { mutableStateOf(false) }
Column(
modifier = Modifier
.background(MaterialTheme.colorScheme.primaryContainer)
.safeContentPadding()
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Button(onClick = { showContent = !showContent }) {
Text("Click me!")
}
AnimatedVisibility(showContent) {
val greeting = remember { Greeting().greet() }
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Image(painterResource(Res.drawable.compose_multiplatform), null)
Text("Compose: $greeting")
}
}
}
RecordsScreen()
}
}
}
@@ -1,9 +0,0 @@
package fr.ajaury.gwenedeg
class Greeting {
private val platform = getPlatform()
fun greet(): String {
return sayHello(platform.name)
}
}
@@ -1,4 +0,0 @@
package fr.ajaury.gwenedeg
fun sayHello(to: String): String =
"Hello, $to!"
@@ -1,7 +0,0 @@
package fr.ajaury.gwenedeg
interface Platform {
val name: String
}
expect fun getPlatform(): Platform
@@ -0,0 +1,15 @@
package fr.ajaury.gwenedeg.records.ui
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@Composable
fun RecordView(record: String) {
Text(
text = record,
modifier = Modifier.padding(16.dp),
)
}
@@ -0,0 +1,68 @@
package fr.ajaury.gwenedeg.records.ui
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
private val records =
listOf(
"An onestiz",
"En em brezntiñ",
"An amzer a ra",
"E komz get unan arall",
"Me hag ar brezhoneg",
"Ar yec'hed",
"Deskriviñ",
"Me 'gar / Ne garan ket",
"C'hoantoù",
"Penaos 'peus kavet...?",
"Oberiantizoù",
"Debriñ hag evet",
"Bale, pourmen ha beajiñ",
"Ma c'horf",
"Dle eo / ret eo / dav eo / mall eo...",
"Deizioù ar sizhun",
"Mizioù ha kourzoù ar blez",
"Bez'zo / N'eus ket...",
"Banne.../Tamm...",
"Stad a vuhez",
"Lec'hiiñ",
)
@Composable
fun RecordsScreen() {
Scaffold { innerPadding ->
LazyColumn(
modifier =
Modifier
.padding(innerPadding)
.background(MaterialTheme.colorScheme.primaryContainer)
.fillMaxSize(),
) {
items(records) { item ->
RecordView(
record = item,
)
if (!item.isLastItem()) {
HorizontalDivider(
modifier = Modifier.padding(horizontal = 16.dp),
thickness = 1.dp,
color = MaterialTheme.colorScheme.outlineVariant,
)
}
}
}
}
}
private fun String.isLastItem(): Boolean = this == records.last()
@@ -1,12 +0,0 @@
package fr.ajaury.gwenedeg
import kotlin.test.Test
import kotlin.test.assertEquals
class SharedCommonTest {
@Test
fun example() {
assertEquals(3, 1 + 2)
}
}
@@ -1,9 +0,0 @@
package fr.ajaury.gwenedeg
import platform.UIKit.UIDevice
class IOSPlatform: Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}
actual fun getPlatform(): Platform = IOSPlatform()
@@ -1,12 +0,0 @@
package fr.ajaury.gwenedeg
import kotlin.test.Test
import kotlin.test.assertEquals
class SharedLogicIOSTest {
@Test
fun example() {
assertEquals(3, 1 + 2)
}
}
@@ -1,14 +0,0 @@
package fr.ajaury.gwenedeg
import web.navigator.navigator
class JsPlatform: Platform {
private val userAgent = navigator.userAgent
private val browserList = listOf("Chrome", "Firefox", "Safari", "Edge")
override val name: String = userAgent.findAnyOf(browserList, ignoreCase = true)
?.let { (startIndex) -> userAgent.substring(startIndex).substringBefore(" ") }
?: "Unknown"
}
actual fun getPlatform(): Platform = JsPlatform()
@@ -1,7 +0,0 @@
package fr.ajaury.gwenedeg
class JVMPlatform: Platform {
override val name: String = "Java ${System.getProperty("java.version")}"
}
actual fun getPlatform(): Platform = JVMPlatform()
@@ -1,12 +0,0 @@
package fr.ajaury.gwenedeg
import kotlin.test.Test
import kotlin.test.assertEquals
class SharedLogicDesktopTest {
@Test
fun example() {
assertEquals(3, 1 + 2)
}
}
@@ -1,7 +0,0 @@
package fr.ajaury.gwenedeg
class WasmPlatform: Platform {
override val name: String = "Web with Kotlin/Wasm"
}
actual fun getPlatform(): Platform = WasmPlatform()