diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 5be6a16..ebb96d8 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -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) diff --git a/composeApp/src/androidMain/kotlin/mg/dot/feufaro/AndroidApp.kt b/composeApp/src/androidMain/kotlin/mg/dot/feufaro/AndroidApp.kt index a1da627..442a663 100644 --- a/composeApp/src/androidMain/kotlin/mg/dot/feufaro/AndroidApp.kt +++ b/composeApp/src/androidMain/kotlin/mg/dot/feufaro/AndroidApp.kt @@ -24,4 +24,5 @@ class AndroidApp: Application { // val fileRepository = org.koin.core.context.GlobalContext.get().get() // println("Koin et FileRepository initialisés dans AndroidApp: $fileRepository") } + } \ No newline at end of file diff --git a/composeApp/src/androidMain/kotlin/mg/dot/feufaro/di/AndroidModule.kt b/composeApp/src/androidMain/kotlin/mg/dot/feufaro/di/AndroidModule.kt index e619f6d..57b8e57 100644 --- a/composeApp/src/androidMain/kotlin/mg/dot/feufaro/di/AndroidModule.kt +++ b/composeApp/src/androidMain/kotlin/mg/dot/feufaro/di/AndroidModule.kt @@ -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() } + single { + AppConfig( + transposeto = "C", + transposeasif = "C", + buttonContainerColorHex = "#ff00f0", + buttonContentColorHex = "#ffffff", + buttonDisabledContainerColorHex = "#999999", + buttonDisabledContentColorHex = "#ffffff", + ) + } + } \ No newline at end of file diff --git a/composeApp/src/commonMain/resources/10-1.xml b/composeApp/src/commonMain/composeResources/files/10-1.xml similarity index 100% rename from composeApp/src/commonMain/resources/10-1.xml rename to composeApp/src/commonMain/composeResources/files/10-1.xml diff --git a/composeApp/src/commonMain/resources/10-2.xml b/composeApp/src/commonMain/composeResources/files/10-2.xml similarity index 100% rename from composeApp/src/commonMain/resources/10-2.xml rename to composeApp/src/commonMain/composeResources/files/10-2.xml diff --git a/composeApp/src/commonMain/resources/11.xml b/composeApp/src/commonMain/composeResources/files/11.xml similarity index 100% rename from composeApp/src/commonMain/resources/11.xml rename to composeApp/src/commonMain/composeResources/files/11.xml diff --git a/composeApp/src/commonMain/resources/12.xml b/composeApp/src/commonMain/composeResources/files/12.xml similarity index 100% rename from composeApp/src/commonMain/resources/12.xml rename to composeApp/src/commonMain/composeResources/files/12.xml diff --git a/composeApp/src/commonMain/resources/13.xml b/composeApp/src/commonMain/composeResources/files/13.xml similarity index 100% rename from composeApp/src/commonMain/resources/13.xml rename to composeApp/src/commonMain/composeResources/files/13.xml diff --git a/composeApp/src/commonMain/resources/480.txt b/composeApp/src/commonMain/composeResources/files/480.txt similarity index 100% rename from composeApp/src/commonMain/resources/480.txt rename to composeApp/src/commonMain/composeResources/files/480.txt diff --git a/composeApp/src/commonMain/resources/8.xml b/composeApp/src/commonMain/composeResources/files/8.xml similarity index 100% rename from composeApp/src/commonMain/resources/8.xml rename to composeApp/src/commonMain/composeResources/files/8.xml diff --git a/composeApp/src/commonMain/resources/9.xml b/composeApp/src/commonMain/composeResources/files/9.xml similarity index 100% rename from composeApp/src/commonMain/resources/9.xml rename to composeApp/src/commonMain/composeResources/files/9.xml diff --git a/composeApp/src/commonMain/composeResources/files/config.json b/composeApp/src/commonMain/composeResources/files/config.json new file mode 100644 index 0000000..9071c80 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/files/config.json @@ -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" +} \ No newline at end of file diff --git a/composeApp/src/commonMain/resources/ews-1.txt b/composeApp/src/commonMain/composeResources/files/ews-1.txt similarity index 100% rename from composeApp/src/commonMain/resources/ews-1.txt rename to composeApp/src/commonMain/composeResources/files/ews-1.txt diff --git a/composeApp/src/commonMain/resources/ews-2.txt b/composeApp/src/commonMain/composeResources/files/ews-2.txt similarity index 100% rename from composeApp/src/commonMain/resources/ews-2.txt rename to composeApp/src/commonMain/composeResources/files/ews-2.txt diff --git a/composeApp/src/commonMain/resources/ews-3.txt b/composeApp/src/commonMain/composeResources/files/ews-3.txt similarity index 100% rename from composeApp/src/commonMain/resources/ews-3.txt rename to composeApp/src/commonMain/composeResources/files/ews-3.txt diff --git a/composeApp/src/commonMain/resources/ews-4.txt b/composeApp/src/commonMain/composeResources/files/ews-4.txt similarity index 100% rename from composeApp/src/commonMain/resources/ews-4.txt rename to composeApp/src/commonMain/composeResources/files/ews-4.txt diff --git a/composeApp/src/commonMain/resources/ews-456.txt b/composeApp/src/commonMain/composeResources/files/ews-456.txt similarity index 84% rename from composeApp/src/commonMain/resources/ews-456.txt rename to composeApp/src/commonMain/composeResources/files/ews-456.txt index d58c641..85f4b88 100644 --- a/composeApp/src/commonMain/resources/ews-456.txt +++ b/composeApp/src/commonMain/composeResources/files/ews-456.txt @@ -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. diff --git a/composeApp/src/commonMain/resources/ews-5.txt b/composeApp/src/commonMain/composeResources/files/ews-5.txt similarity index 100% rename from composeApp/src/commonMain/resources/ews-5.txt rename to composeApp/src/commonMain/composeResources/files/ews-5.txt diff --git a/composeApp/src/commonMain/resources/ews-6.txt b/composeApp/src/commonMain/composeResources/files/ews-6.txt similarity index 100% rename from composeApp/src/commonMain/resources/ews-6.txt rename to composeApp/src/commonMain/composeResources/files/ews-6.txt diff --git a/composeApp/src/commonMain/resources/ews-7.txt b/composeApp/src/commonMain/composeResources/files/ews-7.txt similarity index 100% rename from composeApp/src/commonMain/resources/ews-7.txt rename to composeApp/src/commonMain/composeResources/files/ews-7.txt diff --git a/composeApp/src/commonMain/resources/ews-8.txt b/composeApp/src/commonMain/composeResources/files/ews-8.txt similarity index 100% rename from composeApp/src/commonMain/resources/ews-8.txt rename to composeApp/src/commonMain/composeResources/files/ews-8.txt diff --git a/composeApp/src/commonMain/resources/ffpm-1-2.txt b/composeApp/src/commonMain/composeResources/files/ffpm-1-2.txt similarity index 100% rename from composeApp/src/commonMain/resources/ffpm-1-2.txt rename to composeApp/src/commonMain/composeResources/files/ffpm-1-2.txt diff --git a/composeApp/src/commonMain/resources/ffpm-14.txt b/composeApp/src/commonMain/composeResources/files/ffpm-14.txt similarity index 100% rename from composeApp/src/commonMain/resources/ffpm-14.txt rename to composeApp/src/commonMain/composeResources/files/ffpm-14.txt diff --git a/composeApp/src/commonMain/resources/ffpm-17.txt b/composeApp/src/commonMain/composeResources/files/ffpm-17.txt similarity index 100% rename from composeApp/src/commonMain/resources/ffpm-17.txt rename to composeApp/src/commonMain/composeResources/files/ffpm-17.txt diff --git a/composeApp/src/commonMain/resources/ffpm-191.txt b/composeApp/src/commonMain/composeResources/files/ffpm-191.txt similarity index 100% rename from composeApp/src/commonMain/resources/ffpm-191.txt rename to composeApp/src/commonMain/composeResources/files/ffpm-191.txt diff --git a/composeApp/src/commonMain/resources/ffpm-194.txt b/composeApp/src/commonMain/composeResources/files/ffpm-194.txt similarity index 100% rename from composeApp/src/commonMain/resources/ffpm-194.txt rename to composeApp/src/commonMain/composeResources/files/ffpm-194.txt diff --git a/composeApp/src/commonMain/resources/ffpm-440-1.txt b/composeApp/src/commonMain/composeResources/files/ffpm-440-1.txt similarity index 100% rename from composeApp/src/commonMain/resources/ffpm-440-1.txt rename to composeApp/src/commonMain/composeResources/files/ffpm-440-1.txt diff --git a/composeApp/src/commonMain/resources/ffpm-539.txt b/composeApp/src/commonMain/composeResources/files/ffpm-539.txt similarity index 100% rename from composeApp/src/commonMain/resources/ffpm-539.txt rename to composeApp/src/commonMain/composeResources/files/ffpm-539.txt diff --git a/composeApp/src/commonMain/resources/ffpm-549.txt b/composeApp/src/commonMain/composeResources/files/ffpm-549.txt similarity index 100% rename from composeApp/src/commonMain/resources/ffpm-549.txt rename to composeApp/src/commonMain/composeResources/files/ffpm-549.txt diff --git a/composeApp/src/commonMain/resources/ffpm-55.txt b/composeApp/src/commonMain/composeResources/files/ffpm-55.txt similarity index 54% rename from composeApp/src/commonMain/resources/ffpm-55.txt rename to composeApp/src/commonMain/composeResources/files/ffpm-55.txt index 0c39f7a..de1aa4e 100644 --- a/composeApp/src/commonMain/resources/ffpm-55.txt +++ b/composeApp/src/commonMain/composeResources/files/ffpm-55.txt @@ -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! diff --git a/composeApp/src/commonMain/resources/ffpm-6.txt b/composeApp/src/commonMain/composeResources/files/ffpm-6.txt similarity index 100% rename from composeApp/src/commonMain/resources/ffpm-6.txt rename to composeApp/src/commonMain/composeResources/files/ffpm-6.txt diff --git a/composeApp/src/commonMain/resources/ffpm-8.txt b/composeApp/src/commonMain/composeResources/files/ffpm-8.txt similarity index 100% rename from composeApp/src/commonMain/resources/ffpm-8.txt rename to composeApp/src/commonMain/composeResources/files/ffpm-8.txt diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/App.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/App.kt index 2e0dd88..4553ad3 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/App.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/App.kt @@ -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() - var fileContent by remember { mutableStateOf("Chargement asset ....") } + + val displayConfigManager = koinInject() + 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() + 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 + ) } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/DisplayConfigManager.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/DisplayConfigManager.kt new file mode 100644 index 0000000..54ef525 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/DisplayConfigManager.kt @@ -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? = 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.asStateFlow() + + suspend fun loadConfigFromFile(filePath: String) { + try { + val jsonString = fileRepository.readFileContent(filePath) + val appConfigJson = Json.decodeFromString(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 +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/config/AppConfig.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/config/AppConfig.kt new file mode 100644 index 0000000..e0b4b70 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/config/AppConfig.kt @@ -0,0 +1,9 @@ +package mg.dot.feufaro.config + +import kotlinx.serialization.Serializable + +@Serializable +data class AppConfig ( + val transposeto: String , + val transposeasif: String, +) \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/config/AppConfigJson.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/config/AppConfigJson.kt new file mode 100644 index 0000000..2b1a21e --- /dev/null +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/config/AppConfigJson.kt @@ -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, + 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 + ) +} + diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/config/DisplayConfig.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/config/DisplayConfig.kt new file mode 100644 index 0000000..30eb6a5 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/config/DisplayConfig.kt @@ -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, + val buttonContainerColorHex: String, + val buttonContentColorHex: String , + val buttonDisabledContainerColorHex: String, + val buttonDisabledContentColorHex: String , + + ) \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/di/AppModule.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/di/AppModule.kt index 96df2fd..d754ea0 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/di/AppModule.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/di/AppModule.kt @@ -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())} } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXAttributes.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXAttributes.kt index cea44fa..d2a0b80 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXAttributes.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXAttributes.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXBackup.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXBackup.kt index d4d0f11..eb4e2a6 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXBackup.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXBackup.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXBeam.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXBeam.kt index a6f00a5..6371966 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXBeam.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXBeam.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XML diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXClef.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXClef.kt index 61e526c..2813981 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXClef.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXClef.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCreator.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCreator.kt index fa960b6..63994e0 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCreator.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCreator.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCredit.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCredit.kt index 77e2330..dcb7eaf 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCredit.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCredit.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCreditWords.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCreditWords.kt index b7c9b63..e90ea6b 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCreditWords.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXCreditWords.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDefaults.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDefaults.kt index c908c21..ce2cc2c 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDefaults.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDefaults.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDirection.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDirection.kt index 801e55c..1eeff27 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDirection.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDirection.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDirectionType.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDirectionType.kt index 8a6070a..55b6b53 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDirectionType.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXDirectionType.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXEncoding.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXEncoding.kt index 5f20a15..5b5c994 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXEncoding.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXEncoding.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXForward.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXForward.kt index ce6a80c..dcc8310 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXForward.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXForward.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXHarmony.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXHarmony.kt index 8dab67e..b9780c2 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXHarmony.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXHarmony.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXHarmonyRoot.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXHarmonyRoot.kt index 29dd85b..a0f5df9 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXHarmonyRoot.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXHarmonyRoot.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXIdentification.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXIdentification.kt index 50377c7..db6d6a4 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXIdentification.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXIdentification.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXKey.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXKey.kt index 9919038..9a2e1b4 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXKey.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXKey.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXKind.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXKind.kt index 84d60f7..7a30bf8 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXKind.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXKind.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXLyric.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXLyric.kt index 2742205..fce4e99 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXLyric.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXLyric.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXLyricFont.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXLyricFont.kt index 381abe7..c9b3630 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXLyricFont.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXLyricFont.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMeasure.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMeasure.kt index bed6527..f4afd86 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMeasure.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMeasure.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMidiInstrument.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMidiInstrument.kt index 49f56d3..bde0401 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMidiInstrument.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMidiInstrument.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMiscellaneous.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMiscellaneous.kt index 6137224..e54f3c1 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMiscellaneous.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMiscellaneous.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMiscellaneousField.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMiscellaneousField.kt index 8015cae..94ef7cf 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMiscellaneousField.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXMiscellaneousField.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXNotations.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXNotations.kt index 5f40cb6..ffed50c 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXNotations.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXNotations.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXNote.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXNote.kt index 442fce0..89b420b 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXNote.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXNote.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPageLayout.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPageLayout.kt index 86fe15b..de7700a 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPageLayout.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPageLayout.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPageMargins.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPageMargins.kt index 602742b..f7e04cb 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPageMargins.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPageMargins.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPart.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPart.kt index 61604b7..954c4ed 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPart.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPart.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPartList.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPartList.kt index f8a3413..9c206c5 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPartList.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPartList.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPitch.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPitch.kt index 433488c..4e878e8 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPitch.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPitch.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPrint.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPrint.kt index 0f9a1a8..275fb5c 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPrint.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXPrint.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXRoot.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXRoot.kt index 72b6807..f973e21 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXRoot.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXRoot.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScaling.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScaling.kt index a9a8b25..155023e 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScaling.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScaling.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScoreInstrument.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScoreInstrument.kt index ab57270..389d3cd 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScoreInstrument.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScoreInstrument.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScorePart.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScorePart.kt index 2df370b..7c0b4d9 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScorePart.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScorePart.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScorePartwise.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScorePartwise.kt index a6d6178..3c2b830 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScorePartwise.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXScorePartwise.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSlur.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSlur.kt index d983cf5..9cadf2e 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSlur.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSlur.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSound.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSound.kt index 6da2e73..d37c3b7 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSound.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSound.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStaffDetails.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStaffDetails.kt index 4c7b6b2..beafc8f 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStaffDetails.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStaffDetails.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStaffLayout.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStaffLayout.kt index 4e15f20..df6c9b0 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStaffLayout.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStaffLayout.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStem.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStem.kt index 5188d6c..5a2ad9b 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStem.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXStem.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSupports.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSupports.kt index 9c11089..493af88 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSupports.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSupports.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlSerialName diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSystemLayout.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSystemLayout.kt index 94dc447..e713e50 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSystemLayout.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSystemLayout.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSystemMargins.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSystemMargins.kt index be1a11e..44433af 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSystemMargins.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXSystemMargins.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXTime.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXTime.kt index 78f83cd..634b4f0 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXTime.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXTime.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXWork.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXWork.kt index cb683be..c84dd1a 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXWork.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MXWork.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.serialization.Serializable import nl.adaptivity.xmlutil.serialization.XmlElement diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MusicXML.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MusicXML.kt index 2a365ee..2ef79af 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MusicXML.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MusicXML.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaroo.musicXML +package mg.dot.feufaro.musicXML import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers diff --git a/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/DesktopFileRepository.kt b/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/DesktopFileRepository.kt index b36cb0d..db97e10 100644 --- a/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/DesktopFileRepository.kt +++ b/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/DesktopFileRepository.kt @@ -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 { + private suspend fun readAssetFileLines(assetFileName: String): List { 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) - } - } } \ No newline at end of file diff --git a/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/di/DesktopModule.kt b/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/di/DesktopModule.kt index bd8238e..313378d 100644 --- a/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/di/DesktopModule.kt +++ b/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/di/DesktopModule.kt @@ -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() } + single { + AppConfig( + transposeto = "C", + transposeasif = "C" + ) + } } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a258006..b80f210 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" } @@ -52,4 +53,5 @@ androidLibrary = { id = "com.android.library", version.ref = "agp" } composeHotReload = { id = "org.jetbrains.compose.hot-reload", version.ref = "composeHotReload" } 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" } \ No newline at end of file +kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin"} diff --git a/settings.gradle.kts b/settings.gradle.kts index ff6b1d4..6cd9c2d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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") \ No newline at end of file +include(":composeApp")