Koin OK
This commit is contained in:
parent
2657b64f35
commit
82f0624095
89 changed files with 406 additions and 111 deletions
|
|
@ -9,6 +9,7 @@ plugins {
|
|||
alias(libs.plugins.composeMultiplatform)
|
||||
alias(libs.plugins.composeCompiler)
|
||||
alias(libs.plugins.composeHotReload)
|
||||
alias(libs.plugins.kotlinSerialization)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
|
@ -31,6 +32,7 @@ kotlin {
|
|||
|
||||
}
|
||||
commonMain.dependencies {
|
||||
implementation(compose.components.resources)
|
||||
implementation(compose.runtime)
|
||||
implementation(compose.foundation)
|
||||
implementation(compose.material3)
|
||||
|
|
@ -45,6 +47,7 @@ kotlin {
|
|||
implementation(libs.core) // Dépendance sous-jacente pour XML
|
||||
implementation(libs.serialization)
|
||||
api(libs.kmp.observableviewmodel.core)
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
}
|
||||
commonTest.dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
|
|
|
|||
|
|
@ -24,4 +24,5 @@ class AndroidApp: Application {
|
|||
// val fileRepository = org.koin.core.context.GlobalContext.get().get<FileRepository>()
|
||||
// println("Koin et FileRepository initialisés dans AndroidApp: $fileRepository")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,13 +2,26 @@ package mg.dot.feufaro.di
|
|||
|
||||
import android.content.Context
|
||||
import mg.dot.feufaro.AndroidFileRepository // Import the actual Android implementation
|
||||
import mg.dot.feufaro.config.AppConfig
|
||||
import org.koin.core.module.dsl.singleOf // Import for Koin DSL
|
||||
import org.koin.core.module.dsl.bind // Import for Koin DSL
|
||||
import org.koin.dsl.module
|
||||
import mg.dot.feufaro.FileRepository
|
||||
import org.koin.android.ext.koin.androidContext // Import for androidContext()
|
||||
|
||||
val androidModule = module {
|
||||
// Koin will automatically provide the Android Context because you called androidContext() in AndroidApp.
|
||||
// It then uses this Context to construct AndroidFileRepository.
|
||||
singleOf(::AndroidFileRepository) { bind<FileRepository>() }
|
||||
single<AppConfig> {
|
||||
AppConfig(
|
||||
transposeto = "C",
|
||||
transposeasif = "C",
|
||||
buttonContainerColorHex = "#ff00f0",
|
||||
buttonContentColorHex = "#ffffff",
|
||||
buttonDisabledContainerColorHex = "#999999",
|
||||
buttonDisabledContentColorHex = "#ffffff",
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
19
composeApp/src/commonMain/composeResources/files/config.json
Normal file
19
composeApp/src/commonMain/composeResources/files/config.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"themeMode": "DARK",
|
||||
"fontSize": 18.5,
|
||||
"playlist": [
|
||||
"assets://ews-456.txt",
|
||||
"assets://ews-1.txt",
|
||||
"assets://ews-2.txt",
|
||||
"assets://ews-3.txt",
|
||||
"assets://ews-4.txt",
|
||||
"assets://ews-5.txt",
|
||||
"assets://ews-6.txt",
|
||||
"assets://ews-7.txt",
|
||||
"assets://ews-8.txt"
|
||||
],
|
||||
"buttonContainerColorHex": "#FFFF8855",
|
||||
"buttonContentColorHex": "#FF000055",
|
||||
"buttonDisabledContainerColorHex": "#FF888888",
|
||||
"buttonDisabledContentColorHex": "#FF5555AA"
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@ M0:|c:G|m:3/4|r:11.11.11.11.12.12.11.11|t:456 - To God Be The Glory|n:15|l:10|a:
|
|||
T0:{:D|(D:D):D.D|D:D:D|D:D:D|D:-/D|D:D:D|D:D:D|D:D:(D.D)|D:-/D|(D:D):D.D|D:D:D|D:D:D|D:-/D|D:D:D|D:D:D|D:D:D|D:-/D.,D|D:-:D.,D|D:-:D.,D|D:D:D|D:-/D.,D|D:-:D.,D|D:-:D.D|D:D:D|D:-/D|(D:D):D.D|D:D:D|D:D:D|D:-/D|D:D:D|D:D:D|D:D:D|D:-}
|
||||
N1:s,s,-l,t,ds,drs,rm/mfl,fmdmmrl,-r/s,s,-l,t,ds,drs,rm/msfrdt,dmmrd/mfsmfssmdrmr/rmfrmffrssfm/s,s,-l,t,ds,drs,rm/msfrdt,dmmrd
|
||||
N2:m,m,s,f,f,m,m,s,s,s,s,s,/s,l,f,l,s,s,s,F,F,l,-s,/f,m,s,f,f,m,m,s,s,s,s,s,/T,l,l,l,s,s,s,s,s,f,m,/s,s,ds,s,ds,s,s,s,s,s,/s,dt,t,dt,s,s,s,s,s,s,/m,m,s,f,f,m,m,s,s,s,s,s,/T,l,l,l,s,s,s,s,s,f,m,
|
||||
N3:ss-frrssfffs/s7mmlsf/fs-frrssfffs/ssld'tltssfs/sltslttssfsf/fsllsllfssfs/ss-frrssfffs/ssld'tltssfs
|
||||
N4:s,s,t,rrs,s,t,rrrs/sddds,t,s,l,l,D-r/rs,t,rrs,s,t,rrrs/sdddr6s,/s7s,t,l,s,r/r7dt,t,l,s,/s,s,t,rrs,s,t,rrrs/sdddrrrrrrs,
|
||||
N3:dd-t,s,s,ddt,t,t,d/d7l,l,rdt,/t,d-t,s,s,ddt,t,t,d/ddrfmrmddt,d/drmdrmmddt,dt,/t,drrdrrt,ddt,d/dd-t,s,s,ddt,t,t,d/ddrfmrmddt,d
|
||||
N4:d,d,m,s,s,d,d,m,s,s,s,d/dfffd,m,d,r,r,F-s,/s,d,m,s,s,d,d,m,s,s,s,d/dfffs,6d,/d7d,m,r,d,s,/s,7fm,m,r,d,/d,d,m,s,s,d,d,m,s,s,s,d/dfffs,s,s,s,s,s,d,
|
||||
E1:To God be the glo_ry, great things He has done,/so loved He the world that He gave us His Son,/who yield_ed His life an a_tone_ment for sin,/and o_pened the life gate that all may go in./Praise the Lord, praise the Lord, let the earth hear His voice!/Praise the Lord, praise the Lord, let the peo_ple re_joice!/O come to the Fa_ther through Je_sus the Son, and give Him the glo_ry, great things He has done.
|
||||
E2:O per_fect re_demp_tion, the pur_chase of blood,/to ev'_ry be_lie_ver the pro_mise of God;/the vi_lest of_fen_der who tru_ly be_lieves,/that mo_ment from Je_sus a par_don re_ceives.
|
||||
E3:Great things He has taught us, great things He has done,/and great our re_joi_cing through Je_sus the Son;/but pu_rer, and high_er, and great_er will be/our won_der, our rap_ture, when Je_sus we see.
|
||||
|
|
@ -5,7 +5,7 @@ N2:ddt,ddt,t,ddd/dddddrdt,/rmmrddt,ss/FssmsssFs/rrddddddd/rmmmrsf-m
|
|||
N3:m(ssd)rffsfm/sffmdsss/ttd'ssFsst/lr'td'r'd'd'-t/sssssfffm/sld'd'sslts
|
||||
N4:dds,l,s,rrmfd/df,s,s,l,t,ds,/smdt,l,rs,mr/dt,mdt,l,r-s,/t,ddT,l,s,f,l,d/t,l,lsfmfsd
|
||||
Y1:Ny andron'ny fahaso_avana/Miposaka ho antsika/Manerana\ izao tontolo\ izao/Ny tarany efa hita/Ka ravo ny olombelona,/Fa lasa ny alintsika
|
||||
Y2:Niova tery ny alina/Fa teraka ny Mpamonjy,/Mamiratra be ny lanitra/Miseho izao re ny vonjy,/Ka lasa tokoa ny aizina,/Mihoby ny vo_avonjy
|
||||
Y3:Na dia ho nahay nihira re/Ny hazo an'ala rehetra,/Ka afa-mikalo ny ravina/Hidera ny Avo Indrindra,/Tsy ampy ho fanandratana/Ny Tompon'ny ain-drehetra.
|
||||
Y4:Ny fe_on'ny olonao izao/Misandratra, ry Jehovah/Hidera ny fiti_avanao/Sy ny indrafonao so_a/Ni_aro ny fi_angonanao/Hatramin'ny fahagola.
|
||||
Y5:Ho any an-tanindrazanay/I\zahay re, ry Ray Tsitoha,/Ka hiditra ao an-tranon-dRay/Nomanin'Ilay Mpialoha;/Ny olonao dia ho tafaray/Hidera Anao tokoa!
|
||||
Y2:Ni_o_va tery ny _alina/Fa teraka ny Mpamonjy,/Mamiratra be ny lanitra/Miseho\ izao re ny vonjy,/Ka lasa tokoa ny aizina,/Mihoby ny vo_avonjy
|
||||
Y3:Na dia ho nahay ni_2hira re/Ny hazo an'ala re\hetra,/Ka afa-mikalo\ ny ravina/Hidera ny Avo\ Indrindra,/Tsy ampy ho fanandratana/Ny Tompon'ny ain-drehetra.
|
||||
Y4:Ny fe_on'ny olo_2nao izao/Misandratra, ry Jehova\h/Hidera ny fiti_avanao/Sy ny indrafonao so_a/Ni_aro ny fi_angonanao/Hatramin'ny fahagola.
|
||||
Y5:Ho any an-tani_2ndrazanay/I\zahay re, ry Ray Tsitoha,/Ka hiditra ao an-tranon-dRay/Nomanin'Ilay Mpialoha;/Ny olonao dia ho tafaray/Hidera Anao toko_a!
|
||||
|
|
@ -2,55 +2,204 @@ package mg.dot.feufaro
|
|||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.safeContentPadding
|
||||
import androidx.compose.foundation.layout.safeDrawing
|
||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
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.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import org.jetbrains.compose.ui.tooling.preview.Preview
|
||||
import mg.dot.feufaro.musicXML.MusicXML
|
||||
|
||||
import feufaro.composeapp.generated.resources.Res
|
||||
import feufaro.composeapp.generated.resources.compose_multiplatform
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import mg.dot.feufaro.solfa.LazyVerticalGridTUO
|
||||
import mg.dot.feufaro.solfa.Solfa
|
||||
import org.koin.compose.koinInject
|
||||
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun App() {
|
||||
fun App(sharedViewModel: SharedViewModel = SharedViewModel()
|
||||
) {
|
||||
val fileRepository = koinInject<FileRepository>()
|
||||
var fileContent by remember { mutableStateOf("Chargement asset ....") }
|
||||
|
||||
val displayConfigManager = koinInject<DisplayConfigManager>()
|
||||
val currentDisplayConfig by displayConfigManager.displayConfig.collectAsState()
|
||||
// Load Configurations
|
||||
val configScope = CoroutineScope(Dispatchers.Default)
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
try {
|
||||
fileContent = "xxx"+ fileRepository.readFileContent("assets://ews-1.txt")
|
||||
}catch (e: Exception) {
|
||||
fileContent = "Erreur : ${e.message}"
|
||||
e.printStackTrace()
|
||||
configScope.launch {
|
||||
try {
|
||||
displayConfigManager.loadConfigFromFile("assets://config.json")
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
MaterialTheme {
|
||||
var showContent by remember { mutableStateOf(false) }
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.safeContentPadding()
|
||||
.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Text(text = fileContent)
|
||||
Button(onClick = { showContent = !showContent }) {
|
||||
Text("Click me!")
|
||||
val solfa = Solfa(sharedViewModel, fileRepository)
|
||||
LaunchedEffect(currentDisplayConfig) {
|
||||
if (currentDisplayConfig.playlist.isNotEmpty()) {
|
||||
try {
|
||||
sharedViewModel.setPlaylist(currentDisplayConfig.playlist)
|
||||
solfa.loadNextInPlaylist()
|
||||
} catch (e: Exception) {
|
||||
println("Error loading playlist : ${e.message}")
|
||||
}
|
||||
AnimatedVisibility(showContent) {
|
||||
val greeting = remember { Greeting().greet() }
|
||||
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Image(painterResource(Res.drawable.compose_multiplatform), null)
|
||||
Text("Compose: $greeting")
|
||||
}
|
||||
}
|
||||
|
||||
val musicXML = MusicXML(fileRepository)
|
||||
// Start App
|
||||
//solfa.parse()
|
||||
MaterialTheme {
|
||||
MaterialTheme {
|
||||
var showContent by remember { mutableStateOf(false) }
|
||||
var gridWidthPx by remember { mutableStateOf(0) }
|
||||
Column(Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f)
|
||||
.verticalScroll(rememberScrollState())
|
||||
) {
|
||||
val stanza: Int by sharedViewModel.stanza.collectAsState()
|
||||
FlowRow(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.windowInsetsPadding(WindowInsets.safeDrawing)
|
||||
.padding(start = 8.dp, end = 8.dp, top = 8.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
val measureString: String by sharedViewModel.measure.collectAsState()
|
||||
val songTitle: String by sharedViewModel.songTitle.collectAsState()
|
||||
val songKey: String by sharedViewModel.songKey.collectAsState()
|
||||
Text(text = songTitle, fontWeight = FontWeight.Bold)
|
||||
Text(
|
||||
text = songKey,
|
||||
modifier = Modifier.background(Color(0xff, 0xea, 0xe7))
|
||||
.padding(horizontal = 4.dp)
|
||||
)
|
||||
Text(text = measureString)
|
||||
Text(text = "Stanza: $stanza")
|
||||
val songAuthor: String by sharedViewModel.songAuthor.collectAsState()
|
||||
val songComposer: String by sharedViewModel.songComposer.collectAsState()
|
||||
val songRhythm: String by sharedViewModel.songRhythm.collectAsState()
|
||||
val nbStanzas: Int by sharedViewModel.nbStanzas.collectAsState()
|
||||
Text(text = songAuthor, fontStyle = FontStyle.Italic)
|
||||
Text(text = songRhythm)
|
||||
Text(text = songComposer)
|
||||
Row() {
|
||||
for (i in 1..nbStanzas) {
|
||||
MGButton(
|
||||
enabled = (i != stanza.toInt()),
|
||||
onClick = {
|
||||
sharedViewModel.setStanza(i.toString())
|
||||
},
|
||||
modifier = Modifier.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text("$i")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LazyVerticalGridTUO(
|
||||
sharedViewModel,
|
||||
gridWidthPx = gridWidthPx,
|
||||
onGridWidthMeasured = { width -> gridWidthPx = width }
|
||||
)
|
||||
MGButton(onClick = {
|
||||
//showContent = !showContent
|
||||
|
||||
solfa.loadNextInPlaylist()
|
||||
}, modifier = Modifier.height(40.dp)) {
|
||||
val debugData: String by sharedViewModel.data.collectAsState()
|
||||
Text(debugData)
|
||||
}
|
||||
AnimatedVisibility(showContent) {
|
||||
val greeting = remember { Greeting().greet() }
|
||||
Column(
|
||||
Modifier.fillMaxWidth().height(180.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Image(painterResource(Res.drawable.compose_multiplatform), null)
|
||||
Text("Compose: $greeting")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun String?.toColor(foreGround: Boolean = false): Color {
|
||||
val defaultColor = if (foreGround) {
|
||||
"00FFFFFF"
|
||||
} else {
|
||||
"00008800"
|
||||
}
|
||||
var hex = this?.removePrefix("#") ?: defaultColor
|
||||
if (hex.length == 6) {
|
||||
hex = "00" + hex
|
||||
}
|
||||
val red = hex.substring(2, 4).toInt(16)
|
||||
val green = hex.substring(4, 6).toInt(16)
|
||||
val blue = hex.substring(6, 8).toInt(16)
|
||||
|
||||
return try {
|
||||
Color(red, green, blue)
|
||||
} catch (e: NumberFormatException) {
|
||||
if (foreGround) Color.White else Color.Black
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun MGButton(
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
content: @Composable RowScope.() -> Unit
|
||||
) {
|
||||
val displayConfigManager = koinInject<DisplayConfigManager>()
|
||||
val currentDisplayConfig by displayConfigManager.displayConfig.collectAsState()
|
||||
val buttonColors = ButtonDefaults.buttonColors(
|
||||
containerColor = currentDisplayConfig.buttonContainerColorHex.toColor(),
|
||||
disabledContainerColor = currentDisplayConfig.buttonDisabledContainerColorHex.toColor(),
|
||||
contentColor = currentDisplayConfig.buttonDisabledContentColorHex.toColor(),
|
||||
disabledContentColor = currentDisplayConfig.buttonDisabledContentColorHex.toColor()
|
||||
)
|
||||
Button(
|
||||
onClick = onClick,
|
||||
modifier = modifier,
|
||||
enabled = enabled,
|
||||
colors = buttonColors,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package mg.dot.feufaro
|
||||
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import mg.dot.feufaro.config.AppConfigJson
|
||||
import mg.dot.feufaro.config.DisplayConfig
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlin.String
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class AppConfigJson(
|
||||
val themeMode: String? = null,
|
||||
val fontSize: Float? = null,
|
||||
val playlist: List<String>? = null,
|
||||
val buttonContainerColorHex: String? = null,
|
||||
val buttonContentColorHex: String? = null,
|
||||
val buttonDisabledContainerColorHex: String? = null,
|
||||
val buttonDisabledContentColorHex: String? = null
|
||||
)
|
||||
|
||||
fun AppConfigJson.toDisplayConfig(defaultConfig: DisplayConfig): DisplayConfig {
|
||||
return DisplayConfig(
|
||||
themeMode = this.themeMode,
|
||||
fontSize = this.fontSize,
|
||||
playlist = this.playlist,
|
||||
buttonContainerColorHex = this.buttonContainerColorHex,
|
||||
buttonContentColorHex = this.buttonContentColorHex,
|
||||
buttonDisabledContainerColorHex = this.buttonDisabledContainerColorHex,
|
||||
buttonDisabledContentColorHex = this.buttonDisabledContentColorHex
|
||||
)
|
||||
}
|
||||
class DisplayConfigManager(
|
||||
private val fileRepository: FileRepository
|
||||
)
|
||||
{
|
||||
private val _displayConfig = MutableStateFlow(
|
||||
DisplayConfig(
|
||||
themeMode = "SYSTEM",
|
||||
fontSize = 16f,
|
||||
playlist = listOf(),
|
||||
buttonContainerColorHex = "#FF000000",
|
||||
buttonContentColorHex = "#FFFFFFFF",
|
||||
buttonDisabledContainerColorHex = "#FF888888",
|
||||
buttonDisabledContentColorHex = "#FFAA6666"
|
||||
|
||||
),
|
||||
)
|
||||
val displayConfig: StateFlow<DisplayConfig> = _displayConfig.asStateFlow()
|
||||
|
||||
suspend fun loadConfigFromFile(filePath: String) {
|
||||
try {
|
||||
val jsonString = fileRepository.readFileContent(filePath)
|
||||
val appConfigJson = Json.decodeFromString<AppConfigJson>(jsonString)
|
||||
_displayConfig.value = appConfigJson.toDisplayConfig(_displayConfig.value)
|
||||
|
||||
} catch (e: Exception) {
|
||||
println("DisplayConfigManager Error 22: ${e.message}")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
// NOUVELLE MÉTHODE : Pour basculer le mode débogage
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package mg.dot.feufaro.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class AppConfig (
|
||||
val transposeto: String ,
|
||||
val transposeasif: String,
|
||||
)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package mg.dot.feufaro.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
// Cette classe représente la structure de votre fichier JSON de configuration.
|
||||
// Elle doit être @Serializable pour être désérialisée.
|
||||
@Serializable
|
||||
data class AppConfigJson(
|
||||
val themeMode: String = "SYSTEM", // Utilisez String pour la sérialisation de l'enum
|
||||
val fontSize: Float = 16f,
|
||||
val playlist: List<String>,
|
||||
val buttonContainerColorHex: String,
|
||||
val buttonContentColorHex: String ,
|
||||
val buttonDisabledContainerColorHex: String,
|
||||
val buttonDisabledContentColorHex: String ,
|
||||
|
||||
)
|
||||
|
||||
// Vous pouvez ajouter une fonction d'extension pour convertir AppConfigJson en DisplayConfig
|
||||
fun AppConfigJson.toDisplayConfig(): DisplayConfig {
|
||||
return DisplayConfig(
|
||||
themeMode = this.themeMode.uppercase(), // Convertir String en Enum
|
||||
fontSize = this.fontSize,
|
||||
playlist = this.playlist,
|
||||
buttonDisabledContainerColorHex = this.buttonDisabledContainerColorHex,
|
||||
buttonDisabledContentColorHex = this.buttonDisabledContentColorHex,
|
||||
buttonContainerColorHex = this.buttonContainerColorHex,
|
||||
buttonContentColorHex = this.buttonContentColorHex
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package mg.dot.feufaro.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class DisplayConfig (
|
||||
val themeMode: String,
|
||||
val fontSize: Float,
|
||||
val playlist: List<String>,
|
||||
val buttonContainerColorHex: String,
|
||||
val buttonContentColorHex: String ,
|
||||
val buttonDisabledContainerColorHex: String,
|
||||
val buttonDisabledContentColorHex: String ,
|
||||
|
||||
)
|
||||
|
|
@ -1,13 +1,18 @@
|
|||
package mg.dot.feufaro.di
|
||||
|
||||
import mg.dot.feufaroo.musicXML.MusicXML
|
||||
import mg.dot.feufaro.FileRepository
|
||||
import mg.dot.feufaro.DisplayConfigManager // Importez DisplayConfigManager
|
||||
import mg.dot.feufaro.config.AppConfig
|
||||
import mg.dot.feufaro.musicXML.MusicXML
|
||||
import org.koin.dsl.module
|
||||
import org.koin.core.module.dsl.singleOf
|
||||
import org.koin.core.module.Module
|
||||
|
||||
val commonModule = module {
|
||||
// Déclarez FileRepository comme un singleton.
|
||||
// L'implémentation concrète (actual) sera résolue par Koin en fonction de la plateforme.
|
||||
// Pour Android, Koin injectera le Context que vous avez fourni via androidContext().
|
||||
singleOf(::MusicXML)
|
||||
single { DisplayConfigManager(fileRepository = get())}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XML
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlSerialName
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package mg.dot.feufaroo.musicXML
|
||||
package mg.dot.feufaro.musicXML
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
package mg.dot.feufaro
|
||||
|
||||
import feufaro.composeapp.generated.resources.Res
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import mg.dot.feufaro.FileRepository
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
|
||||
// This is just a regular class that implements the common 'FileRepository' interface.
|
||||
// It is NOT an 'actual' declaration of 'FileRepository'.
|
||||
class DesktopFileRepository : FileRepository { // IMPORTS AND IMPLEMENTS THE commonMain 'FileRepository' interface
|
||||
|
|
@ -28,22 +29,13 @@ class DesktopFileRepository : FileRepository { // IMPORTS AND IMPLEMENTS THE com
|
|||
val lines = readFileLines(filePath)
|
||||
lines.joinToString("\n") { it }
|
||||
}
|
||||
private fun readAssetFileLines(assetFileName: String): List<String> {
|
||||
private suspend fun readAssetFileLines(assetFileName: String): List<String> {
|
||||
return try {
|
||||
//myApplicationContext.assets.open(filename.removePrefix("assets://")).bufferedReader().use {
|
||||
object {}.javaClass.getResource("/"+assetFileName.removePrefix("assets://")).readText().split("\n")
|
||||
|
||||
Res.readBytes("files/"+assetFileName.removePrefix("assets://")).decodeToString().split("\n")
|
||||
} catch (e: IOException) {
|
||||
println("Could not read /"+assetFileName.removePrefix("assets://"))
|
||||
throw IOException("Could not read asset file: $assetFileName", e)
|
||||
}
|
||||
|
||||
}
|
||||
private fun readAssetFileContent(assetFileName: String): String {
|
||||
return try {
|
||||
//myApplicationContext.assets.open(filename.removePrefix("assets://")).bufferedReader().use {
|
||||
object {}.javaClass.getResource("/"+assetFileName.removePrefix("assets://")).readText()
|
||||
} catch (e: IOException) {
|
||||
throw IOException("Could not read asset file: $assetFileName", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,9 +5,16 @@ import org.koin.core.module.dsl.singleOf // Import for Koin DSL
|
|||
import org.koin.core.module.dsl.bind // Import for Koin DSL
|
||||
import org.koin.dsl.module
|
||||
import mg.dot.feufaro.FileRepository
|
||||
import mg.dot.feufaro.config.AppConfig
|
||||
|
||||
val desktopModule = module {
|
||||
// When Koin is initialized on Desktop, it will use DesktopFileRepository
|
||||
// as the implementation for the FileRepository interface.
|
||||
singleOf(::DesktopFileRepository) { bind<FileRepository>() }
|
||||
single<AppConfig> {
|
||||
AppConfig(
|
||||
transposeto = "C",
|
||||
transposeasif = "C"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ kotlinx-coroutines = "1.10.2"
|
|||
koin = "4.0.4"
|
||||
core = "0.91.1"
|
||||
kmpObservableviewmodelCore = "1.0.0-BETA-3"
|
||||
|
||||
kotlinxSerializationJson = "1.8.1"
|
||||
|
||||
[libraries]
|
||||
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
|
||||
|
|
@ -45,6 +45,7 @@ core = { module = "io.github.pdvrieze.xmlutil:core", version.ref = "core" }
|
|||
#core-jdk = { module = "io.github.pdvrieze.xmlutil:core-jdk", version.ref = "core" }
|
||||
serialization = { module = "io.github.pdvrieze.xmlutil:serialization", version.ref = "core" }
|
||||
kmp-observableviewmodel-core = { module = "com.rickclephas.kmp:kmp-observableviewmodel-core", version.ref = "kmpObservableviewmodelCore" }
|
||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
|
||||
|
||||
[plugins]
|
||||
androidApplication = { id = "com.android.application", version.ref = "agp" }
|
||||
|
|
@ -53,3 +54,4 @@ composeHotReload = { id = "org.jetbrains.compose.hot-reload", version.ref = "com
|
|||
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }
|
||||
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||
kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin"}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,7 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
|||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google {
|
||||
mavenContent {
|
||||
includeGroupAndSubgroups("androidx")
|
||||
includeGroupAndSubgroups("com.android")
|
||||
includeGroupAndSubgroups("com.google")
|
||||
}
|
||||
}
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
|
@ -17,19 +11,9 @@ pluginManagement {
|
|||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
google {
|
||||
mavenContent {
|
||||
includeGroupAndSubgroups("androidx")
|
||||
includeGroupAndSubgroups("com.android")
|
||||
includeGroupAndSubgroups("com.google")
|
||||
}
|
||||
}
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
|
||||
}
|
||||
|
||||
include(":composeApp")
|
||||
Loading…
Add table
Reference in a new issue