new: modularize data.records
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
alias(libs.plugins.androidMultiplatformLibrary)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
iosArm64()
|
||||
iosSimulatorArm64()
|
||||
|
||||
jvm()
|
||||
|
||||
js {
|
||||
browser()
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalWasmDsl::class)
|
||||
wasmJs {
|
||||
browser()
|
||||
}
|
||||
|
||||
androidLibrary {
|
||||
namespace = "fr.ajaury.gwenedeg.records"
|
||||
compileSdk =
|
||||
libs.versions.androidCompileSdk
|
||||
.get()
|
||||
.toInt()
|
||||
minSdk =
|
||||
libs.versions.androidMinSdk
|
||||
.get()
|
||||
.toInt()
|
||||
|
||||
compilerOptions {
|
||||
jvmTarget = JvmTarget.JVM_11
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain.dependencies {
|
||||
// Core modules
|
||||
implementation(projects.core.model)
|
||||
|
||||
// Coroutines
|
||||
implementation(libs.kotlinx.coroutinesCore)
|
||||
|
||||
// DI
|
||||
implementation(project.dependencies.platform(libs.koin.bom))
|
||||
implementation(libs.koin.core)
|
||||
}
|
||||
commonTest.dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
package fr.ajaury.gwenedeg.records.data
|
||||
|
||||
import fr.ajaury.gwenedeg.core.model.Phrase
|
||||
import fr.ajaury.gwenedeg.core.model.Record
|
||||
import fr.ajaury.gwenedeg.records.domain.RecordRepository
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
|
||||
internal class InMemoryRecordRepository : RecordRepository {
|
||||
private val records =
|
||||
listOf(
|
||||
Phrase(
|
||||
transcription = "An onestiz",
|
||||
translation = "La politesse",
|
||||
),
|
||||
Phrase(
|
||||
transcription = "En em brezantiñ",
|
||||
translation = "Se présenter",
|
||||
),
|
||||
Phrase(
|
||||
transcription = "An amzer a ra",
|
||||
translation = "Le temps qu'il fait",
|
||||
),
|
||||
Phrase(
|
||||
transcription = "E komz get unan arall",
|
||||
translation = "Parler avec quelqu'un d'autre",
|
||||
),
|
||||
Phrase(
|
||||
transcription = "Me hag ar brezhoneg",
|
||||
translation = "Moi et le breton",
|
||||
),
|
||||
Phrase(
|
||||
transcription = "Ar yec'hed",
|
||||
translation = "La santé",
|
||||
),
|
||||
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 paddedNumber = number.toString().padStart(2, '0')
|
||||
Record(
|
||||
id = number,
|
||||
index = number,
|
||||
title = phrase,
|
||||
audioResourcePath = "files/Chom_bev_$paddedNumber.m4a",
|
||||
subtitleResourcePath = "files/Chom_bev_${paddedNumber}_st_bzh.lrc",
|
||||
translationSubtitleResourcePath = "files/Chom_bev_${paddedNumber}_st_fr.lrc",
|
||||
)
|
||||
}
|
||||
|
||||
override fun getRecords(): Flow<List<Record>> = flowOf(records)
|
||||
|
||||
override suspend fun getRecord(id: Int): Record? = records.firstOrNull { it.id == id }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package fr.ajaury.gwenedeg.records.di
|
||||
|
||||
import fr.ajaury.gwenedeg.records.data.InMemoryRecordRepository
|
||||
import fr.ajaury.gwenedeg.records.domain.RecordRepository
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.core.module.dsl.bind
|
||||
import org.koin.core.module.dsl.factoryOf
|
||||
import org.koin.dsl.module
|
||||
|
||||
val recordsModule: Module = module {
|
||||
factoryOf(::InMemoryRecordRepository) { bind<RecordRepository>() }
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package fr.ajaury.gwenedeg.records.domain
|
||||
|
||||
import fr.ajaury.gwenedeg.core.model.Record
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface RecordRepository {
|
||||
fun getRecords(): Flow<List<Record>>
|
||||
|
||||
suspend fun getRecord(id: Int): Record?
|
||||
}
|
||||
Reference in New Issue
Block a user