mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-22 12:32:31 +01:00
Add iOS support to the underlying modules
This commit is contained in:
@@ -24,6 +24,9 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
iosX64()
|
||||||
|
iosArm64()
|
||||||
|
//iosSimulatorArm64()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
all {
|
all {
|
||||||
@@ -80,6 +83,20 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val androidTest by getting
|
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
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,9 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
iosX64()
|
||||||
|
iosArm64()
|
||||||
|
//iosSimulatorArm64()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
all {
|
all {
|
||||||
@@ -72,6 +75,20 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val androidTest by getting
|
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,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.data.base
|
||||||
|
|
||||||
|
import androidx.compose.ui.text.intl.Locale
|
||||||
|
import ca.gosyer.jui.core.lang.toPlatform
|
||||||
|
import kotlinx.datetime.Instant
|
||||||
|
import kotlinx.datetime.toNSDate
|
||||||
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import platform.Foundation.NSDateFormatter
|
||||||
|
import platform.Foundation.NSDateFormatterNoStyle
|
||||||
|
import platform.Foundation.NSDateFormatterShortStyle
|
||||||
|
|
||||||
|
actual class DateHandler @Inject constructor() {
|
||||||
|
actual val formatOptions by lazy {
|
||||||
|
listOf(
|
||||||
|
"",
|
||||||
|
"MM/dd/yy",
|
||||||
|
"dd/MM/yy",
|
||||||
|
"yyyy-MM-dd"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
actual fun getDateFormat(format: String): (Instant) -> String = when (format) {
|
||||||
|
"" -> NSDateFormatter()
|
||||||
|
.apply {
|
||||||
|
setDateStyle(NSDateFormatterShortStyle)
|
||||||
|
setTimeStyle(NSDateFormatterNoStyle)
|
||||||
|
setLocale(Locale.current.toPlatform())
|
||||||
|
}
|
||||||
|
else -> NSDateFormatter()
|
||||||
|
.apply {
|
||||||
|
setDateFormat(format)
|
||||||
|
}
|
||||||
|
}.let { formatter ->
|
||||||
|
{
|
||||||
|
formatter.stringFromDate(it.toNSDate())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actual val dateTimeFormat: (Instant) -> String by lazy {
|
||||||
|
NSDateFormatter()
|
||||||
|
.apply {
|
||||||
|
setDateStyle(NSDateFormatterShortStyle)
|
||||||
|
setTimeStyle(NSDateFormatterShortStyle)
|
||||||
|
setLocale(Locale.current.toPlatform())
|
||||||
|
}
|
||||||
|
.let { formatter ->
|
||||||
|
{
|
||||||
|
formatter.stringFromDate(it.toNSDate())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,9 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
iosX64()
|
||||||
|
iosArm64()
|
||||||
|
//iosSimulatorArm64()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
all {
|
all {
|
||||||
@@ -79,6 +82,23 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val androidTest by getting
|
val androidTest by getting
|
||||||
|
|
||||||
|
val iosMain by creating {
|
||||||
|
dependsOn(commonMain)
|
||||||
|
dependencies {
|
||||||
|
api(libs.ktor.darwin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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,12 @@
|
|||||||
|
/*
|
||||||
|
* 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.domain
|
||||||
|
|
||||||
|
actual interface DomainComponent : SharedDomainComponent {
|
||||||
|
|
||||||
|
companion object
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* 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.domain.server
|
||||||
|
|
||||||
|
import io.ktor.client.HttpClientConfig
|
||||||
|
import io.ktor.client.engine.HttpClientEngineConfig
|
||||||
|
import io.ktor.client.engine.HttpClientEngineFactory
|
||||||
|
import io.ktor.client.engine.darwin.Darwin
|
||||||
|
import io.ktor.client.engine.darwin.DarwinClientEngineConfig
|
||||||
|
|
||||||
|
actual val Engine: HttpClientEngineFactory<HttpClientEngineConfig>
|
||||||
|
get() = Darwin
|
||||||
|
|
||||||
|
actual fun HttpClientConfig<HttpClientEngineConfig>.configurePlatform() {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
(this as HttpClientConfig<DarwinClientEngineConfig>).realConfigurePlatform()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun HttpClientConfig<DarwinClientEngineConfig>.realConfigurePlatform() {
|
||||||
|
engine {
|
||||||
|
configureRequest {
|
||||||
|
setAllowsCellularAccess(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,8 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
iosX64()
|
||||||
|
iosArm64()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
val commonMain by getting {
|
val commonMain by getting {
|
||||||
|
|||||||
Reference in New Issue
Block a user