mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Add iOS support to the underlying modules
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
30
core/src/iosMain/kotlin/ca/gosyer/jui/core/lang/IosLocale.kt
Normal file
30
core/src/iosMain/kotlin/ca/gosyer/jui/core/lang/IosLocale.kt
Normal 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)
|
||||
@@ -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
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user