From c96490971480139a0dc706601704c4bf162c017e Mon Sep 17 00:00:00 2001 From: Antoine Jaury Date: Fri, 19 Jun 2026 09:59:22 +0200 Subject: [PATCH] new: display record indices in RecordView and update layout styling --- .../ajaury/gwenedeg/records/ui/RecordView.kt | 31 +++++++++++++++++-- .../gwenedeg/records/ui/RecordsScreen.kt | 1 + 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/records/ui/RecordView.kt b/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/records/ui/RecordView.kt index 01cdb5f..28eb452 100644 --- a/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/records/ui/RecordView.kt +++ b/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/records/ui/RecordView.kt @@ -1,23 +1,48 @@ package fr.ajaury.gwenedeg.records.ui import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import fr.ajaury.gwenedeg.records.domain.Record @Composable fun RecordView( + index: Int, record: Record, - onClick: () -> Unit, + onClick: () -> Unit = {}, ) { - Text( - text = record.title, + Row( modifier = Modifier + .fillMaxWidth() .clickable { onClick() } .padding(16.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(16.dp), + ) { + Text( + text = index.toString().padStart(2), + fontFamily = FontFamily.Monospace, + ) + Text(text = record.title) + } +} + +@Preview +@Composable +private fun RecordViewPreview() { + RecordView( + index = 1, + record = Record(title = "Sample Record"), + onClick = {}, ) } diff --git a/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/records/ui/RecordsScreen.kt b/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/records/ui/RecordsScreen.kt index 9211510..cf76107 100644 --- a/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/records/ui/RecordsScreen.kt +++ b/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/records/ui/RecordsScreen.kt @@ -46,6 +46,7 @@ fun RecordsScreen( ) { itemsIndexed(records) { index, item -> RecordView( + index = index + 1, record = item, onClick = { onRecordClick(item) }, )