refactor: centralize domain models into core.model module

This commit is contained in:
2026-07-01 17:39:06 +02:00
parent 657d39a293
commit 6a590344de
2 changed files with 103 additions and 31 deletions
@@ -1,44 +1,113 @@
package fr.ajaury.gwenedeg.records.data package fr.ajaury.gwenedeg.records.data
import fr.ajaury.gwenedeg.records.domain.RecordRepository import fr.ajaury.gwenedeg.core.model.Phrase
import fr.ajaury.gwenedeg.core.model.Record import fr.ajaury.gwenedeg.core.model.Record
import fr.ajaury.gwenedeg.records.domain.RecordRepository
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOf
class InMemoryRecordRepository : RecordRepository { class InMemoryRecordRepository : RecordRepository {
private val records = private val records =
listOf( listOf(
"An onestiz" to "La politesse", Phrase(
"En em brezantiñ" to "Se présenter", transcription = "An onestiz",
"An amzer a ra" to "Le temps qu'il fait", translation = "La politesse",
"E komz get unan arall" to "Parler avec quelqu'un d'autre", ),
"Me hag ar brezhoneg" to "Moi et le breton", Phrase(
"Ar yec'hed" to "La santé", transcription = "En em brezant",
"Deskriviñ" to "Décrire", translation = "Se présenter",
"Me 'gar / Ne garan ket" to "J'aime / Je n'aime pas", ),
"C'hoantoù" to "Les envies", Phrase(
"Penaos 'peus kavet...?" to "Comment as-tu trouvé... ?", transcription = "An amzer a ra",
"Oberiantizoù" to "Les activités", translation = "Le temps qu'il fait",
"Debriñ hag evet" to "Manger et boire", ),
"Bale, pourmen ha beajiñ" to "Marcher, se promener et voyager", Phrase(
"Ma c'horf (1)" to "Mon corps (1)", transcription = "E komz get unan arall",
"Ma c'horf (2)" to "Mon corps (2)", translation = "Parler avec quelqu'un d'autre",
"Dle eo / ret eo / dav eo / mall eo..." to "Il faut que... / Il est temps que (de) ...", ),
"Deizioù ar sizhun" to "Les jours de la semaine", Phrase(
"Mizioù ha kourzoù ar blez" to "Les mois et les saisons de l'année", transcription = "Me hag ar brezhoneg",
"Bez'zo / N'eus ket..." to "Il y a / Il n'y a pas...", translation = "Moi et le breton",
"Banne.../Tamm..." to "Un peu...", ),
"Stad a vuhez (1)" to "Situation de vie (1)", Phrase(
"Stad a vuhez (2)" to "Situation de vie (2)", transcription = "Ar yec'hed",
"Lec'hiiñ" to "Situer", translation = "La santé",
).mapIndexed { index, (title, titleTranslation) -> ),
Phrase(
transcription = "Deskriviñ",
translation = "Décrire",
),
Phrase(
transcription = "Me 'gar / Ne garan ket",
translation = "J'aime / Je n'aime pas",
),
Phrase(
transcription = "C'hoantoù",
translation = "Les envies",
),
Phrase(
transcription = "Penaos 'peus kavet...?",
translation = "Comment as-tu trouvé... ?",
),
Phrase(
transcription = "Oberiantizoù",
translation = "Les activités",
),
Phrase(
transcription = "Debriñ hag evet",
translation = "Manger et boire",
),
Phrase(
transcription = "Bale, pourmen ha beajiñ",
translation = "Marcher, se promener et voyager",
),
Phrase(
transcription = "Ma c'horf (1)",
translation = "Mon corps (1)",
),
Phrase(
transcription = "Ma c'horf (2)",
translation = "Mon corps (2)",
),
Phrase(
transcription = "Dle eo / ret eo / dav eo / mall eo...",
translation = "Il faut que... / Il est temps que (de) ...",
),
Phrase(
transcription = "Deizioù ar sizhun",
translation = "Les jours de la semaine",
),
Phrase(
transcription = "Mizioù ha kourzoù ar blez",
translation = "Les mois et les saisons de l'année",
),
Phrase(
transcription = "Bez'zo / N'eus ket...",
translation = "Il y a / Il n'y a pas...",
),
Phrase(
transcription = "Banne.../Tamm...",
translation = "Un peu...",
),
Phrase(
transcription = "Stad a vuhez (1)",
translation = "Situation de vie (1)",
),
Phrase(
transcription = "Stad a vuhez (2)",
translation = "Situation de vie (2)",
),
Phrase(
transcription = "Lec'hiiñ",
translation = "Situer",
),
).mapIndexed { index, phrase ->
val number = index + 1 val number = index + 1
val paddedNumber = number.toString().padStart(2, '0') val paddedNumber = number.toString().padStart(2, '0')
Record( Record(
id = number, id = number,
index = number, index = number,
title = title, title = phrase,
titleTranslation = titleTranslation,
audioResourcePath = "files/Chom_bev_$paddedNumber.m4a", audioResourcePath = "files/Chom_bev_$paddedNumber.m4a",
subtitleResourcePath = "files/Chom_bev_${paddedNumber}_st_bzh.lrc", subtitleResourcePath = "files/Chom_bev_${paddedNumber}_st_bzh.lrc",
translationSubtitleResourcePath = "files/Chom_bev_${paddedNumber}_st_fr.lrc", translationSubtitleResourcePath = "files/Chom_bev_${paddedNumber}_st_fr.lrc",
@@ -14,6 +14,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import fr.ajaury.gwenedeg.core.model.Phrase
import fr.ajaury.gwenedeg.core.model.Record import fr.ajaury.gwenedeg.core.model.Record
@Composable @Composable
@@ -35,8 +36,8 @@ fun RecordView(
fontFamily = FontFamily.Monospace, fontFamily = FontFamily.Monospace,
) )
Column { Column {
Text(text = record.title) Text(text = record.title.transcription)
record.titleTranslation?.let { translation -> record.title.translation?.let { translation ->
Text( Text(
text = translation, text = translation,
style = MaterialTheme.typography.bodySmall, style = MaterialTheme.typography.bodySmall,
@@ -55,8 +56,10 @@ private fun RecordViewPreview() {
Record( Record(
id = 1, id = 1,
index = 1, index = 1,
title = "Sample Record", title = Phrase(
titleTranslation = "Exemple d'enregistrement", transcription = "Sample Record",
translation = "Exemple d'enregistrement",
),
audioResourcePath = "files/Chom_bev_01.ogg", audioResourcePath = "files/Chom_bev_01.ogg",
subtitleResourcePath = "files/Chom_bev_01_st_bzh.lrc", subtitleResourcePath = "files/Chom_bev_01_st_bzh.lrc",
), ),