Add iOS support to the underlying modules

This commit is contained in:
Syer10
2022-08-01 22:11:17 -04:00
parent 85cae9608c
commit caf373102e
12 changed files with 246 additions and 0 deletions

View File

@@ -24,6 +24,9 @@ kotlin {
}
}
}
iosX64()
iosArm64()
//iosSimulatorArm64()
sourceSets {
all {
@@ -80,6 +83,20 @@ kotlin {
}
}
val androidTest by getting
val iosMain by creating {
dependsOn(commonMain)
}
val iosTest by creating {
dependsOn(commonTest)
}
listOf("iosX64Main", "iosArm64Main"/*, "iosSimulatorArm64Main"*/).forEach {
getByName(it).dependsOn(iosMain)
}
listOf("iosX64Test", "iosArm64Test"/*, "iosSimulatorArm64Test"*/).forEach {
getByName(it).dependsOn(iosTest)
}
}
}

View File

@@ -0,0 +1,13 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package ca.gosyer.jui.core.io
import okio.FileSystem
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
actual val FileSystem.Companion.SYSTEM: FileSystem
get() = SYSTEM

View File

@@ -0,0 +1,9 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package ca.gosyer.jui.core.io
actual interface Serializable

View File

@@ -0,0 +1,18 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package ca.gosyer.jui.core.lang
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
@OptIn(ExperimentalCoroutinesApi::class)
private val ioDispatcher = Dispatchers.Default.limitedParallelism(64)
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
actual val Dispatchers.IO: CoroutineDispatcher
get() = ioDispatcher

View File

@@ -0,0 +1,30 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package ca.gosyer.jui.core.lang
import androidx.compose.ui.text.intl.Locale
import platform.Foundation.localizedStringForLanguageCode
import platform.Foundation.localizedStringForLocaleIdentifier
import platform.Foundation.NSLocale as PlatformLocale
fun Locale.toPlatform(): PlatformLocale = PlatformLocale(toLanguageTag())
/**
* First Locale: en_IN
* Language: English
*/
actual fun Locale.getDisplayLanguage(displayLocale: Locale): String = toPlatform()
.localizedStringForLanguageCode(displayLocale.toLanguageTag())!!
/**
* First Locale: en_US
* Language: English (United States)
*/
actual fun Locale.getDisplayName(displayLocale: Locale): String = toPlatform()
.localizedStringForLocaleIdentifier(displayLocale.toLanguageTag())
actual val Locale.displayName: String get() = getDisplayLanguage(this)

View File

@@ -0,0 +1,21 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package ca.gosyer.jui.core.prefs
import com.russhwolf.settings.NSUserDefaultsSettings
import me.tatarka.inject.annotations.Inject
import platform.Foundation.NSUserDefaults
actual class PreferenceStoreFactory @Inject constructor() {
actual fun create(vararg names: String): PreferenceStore {
return StandardPreferenceStore(
NSUserDefaultsSettings(
NSUserDefaults.standardUserDefaults
)
)
}
}