Removed PlatformStart and create new file if doesn't exist

This commit is contained in:
Stef Tervelde
2025-03-17 10:36:35 +01:00
parent b0e7f96bdd
commit d17ca0cdcd
2 changed files with 9 additions and 5 deletions

View File

@@ -16,9 +16,6 @@ import java.util.Properties
const val PREFERENCES_FILE_NAME = "preferences.txt"
const val DEFAULTS_FILE_NAME = "defaults.txt"
fun PlatformStart(){
Platform.inst ?: Platform.init()
}
class ReactiveProperties: Properties() {
val _stateMap = mutableStateMapOf<String, String>()
@@ -41,10 +38,15 @@ val LocalPreferences = compositionLocalOf<ReactiveProperties> { error("No prefer
@OptIn(FlowPreview::class)
@Composable
fun PreferencesProvider(content: @Composable () -> Unit){
PlatformStart()
remember {
Platform.init()
}
val settingsFolder = Platform.getSettingsFolder()
val preferencesFile = settingsFolder.resolve(PREFERENCES_FILE_NAME)
if(!preferencesFile.exists()){
preferencesFile.createNewFile()
}
val update = watchFile(preferencesFile)
val properties = remember(preferencesFile, update) { ReactiveProperties().apply {

View File

@@ -38,7 +38,9 @@ class Locale(language: String = "", val setLocale: (java.util.Locale) -> Unit) :
val LocalLocale = compositionLocalOf<Locale> { error("No Locale Set") }
@Composable
fun LocaleProvider(content: @Composable () -> Unit) {
PlatformStart()
remember {
Platform.init()
}
val settingsFolder = Platform.getSettingsFolder()
val languageFile = File(settingsFolder, "language.txt")