From 1a5c37b42533bb13810afaeae5d6f75b49cc73fe Mon Sep 17 00:00:00 2001 From: Maciej Procyk Date: Sun, 3 Mar 2024 16:18:08 +0100 Subject: [PATCH] update versions --- build.gradle.kts | 2 -- desktopApp/compose-desktop.pro | 4 +-- gradle/libs.versions.toml | 23 ++++++-------- iosApp/iosApp/ContentView.swift | 4 +-- iosApp/iosApp/iOSApp.swift | 19 ++++-------- shared/build.gradle.kts | 8 +---- .../ml/dev/kotlin/openotp/OpenOtpApp.kt | 8 ++--- .../ui/component/FilteredOtpCodeItems.kt | 4 +-- .../openotp/ui/component/OtpCodeItems.kt | 11 ++++--- .../kotlin/openotp/ui/component/SearchBar.kt | 3 +- .../openotp/ui/screen/AddProviderScreen.kt | 2 +- .../openotp/ui/screen/LinkAccountScreen.kt | 2 +- .../kotlin/openotp/ui/screen/MainScreen.kt | 2 +- .../openotp/ui/screen/SettingsScreen.kt | 4 +-- .../ml/dev/kotlin/openotp/ui/theme/Theme.kt | 2 +- .../openotp/util/Material3ComposeUtil.kt | 6 ++-- shared/src/desktopMain/kotlin/main.desktop.kt | 2 +- shared/src/iosMain/kotlin/KoinHelpers.kt | 14 +++++++++ shared/src/iosMain/kotlin/StateKeeperUtils.kt | 30 +++++++++++++++++++ .../{SwiftHelpers.kt => ThemeHelpers.kt} | 15 ++-------- 20 files changed, 90 insertions(+), 75 deletions(-) create mode 100644 shared/src/iosMain/kotlin/KoinHelpers.kt create mode 100644 shared/src/iosMain/kotlin/StateKeeperUtils.kt rename shared/src/iosMain/kotlin/{SwiftHelpers.kt => ThemeHelpers.kt} (64%) diff --git a/build.gradle.kts b/build.gradle.kts index 1d686a0..703cbdd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,12 +2,10 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask plugins { alias(libs.plugins.kotlin.multiplatform) apply false - alias(libs.plugins.kotlin.parcelize) apply false alias(libs.plugins.kotlin.serialization) apply false alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false alias(libs.plugins.compose.multiplatform) apply false - alias(libs.plugins.parcelize.darwin) apply false alias(libs.plugins.moko.resources) apply false alias(libs.plugins.gradle.versions) apply true diff --git a/desktopApp/compose-desktop.pro b/desktopApp/compose-desktop.pro index 108e01f..d0a7cd9 100644 --- a/desktopApp/compose-desktop.pro +++ b/desktopApp/compose-desktop.pro @@ -1,4 +1,4 @@ --keep class com.arkivanov.decompose.extensions.compose.jetbrains.mainthread.SwingMainThreadChecker +-keep class com.arkivanov.decompose.extensions.compose.mainthread.SwingMainThreadChecker -keep class kotlinx.coroutines.swing.SwingDispatcherFactory -keep class org.bridj.** { *; } -keep class io.ktor.serialization.kotlinx.json.KotlinxSerializationJsonExtensionProvider { *; } @@ -26,7 +26,7 @@ kotlinx.serialization.KSerializer serializer(...); } --dontwarn com.arkivanov.decompose.extensions.compose.jetbrains.pages.** +-dontwarn com.arkivanov.decompose.extensions.compose.pages.** -dontwarn org.xml.sax.** -dontwarn javax.xml.** -dontwarn org.w3c.dom.** diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c17e6fb..c7d0da3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ # @keep android-compileSdk = "34" # @pin -android-gradle-plugin = "8.1.2" +android-gradle-plugin = "8.2.2" # @keep android-minSdk = "26" # @keep @@ -15,11 +15,11 @@ androidx-core-ktx = "1.12.0" androidx-crypto = "1.1.0-alpha05" barcodeScanning = "17.2.0" buffer = "1.3.6" -compose = "1.5.12" -compose-extensions = "1.5.11.0" -decompose = "2.2.2-compose-experimental" +compose = "1.6.0-rc02" +compose-extensions = "1.6.0-rc02.0" +decompose = "3.0.0-alpha08" encoding = "2.0.0" -essenty = "1.3.0" +essenty = "2.0.0-alpha07" gradle-versions = "0.51.0" kermit = "2.0.0-RC5" koin = "3.5.0" @@ -29,13 +29,12 @@ kotlin = "1.9.22" kotlincrypto-hash = "0.3.0" kotlincrypto-macs = "0.3.0" kotlincrypto-secure-random = "0.1.0" -kotlinx-coroutines = "1.7.3" +kotlinx-coroutines = "1.8.0" kotlinx-datetime = "0.5.0" kotlinx-serialization = "1.6.2" -ktor = "2.3.7" +ktor = "2.3.8" moko-resources = "0.23.0" multiplatform-settings = "1.1.1" -parcelize-darwin = "0.2.3" uri-kmp = "0.0.15" uuid = "0.8.2" version-catalog-update = "0.8.4" @@ -43,7 +42,7 @@ version-catalog-update = "0.8.4" versionCode = "19" webcamCapture = "0.3.12" webcamCaptureDriverNative = "1.0.0" -zxing-core = "3.5.2" +zxing-core = "3.5.3" [libraries] androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity-compose" } @@ -56,11 +55,10 @@ compose-extensions-camera-permission = { module = "in.procyk.compose:camera-perm compose-extensions-camera-qr = { module = "in.procyk.compose:camera-qr", version.ref = "compose-extensions" } compose-extensions-util = { module = "in.procyk.compose:util", version.ref = "compose-extensions" } decompose = { module = "com.arkivanov.decompose:decompose", version.ref = "decompose" } -decompose-extensionsComposeJetbrains = { module = "com.arkivanov.decompose:extensions-compose-jetbrains", version.ref = "decompose" } +decompose-extensionsCompose = { module = "com.arkivanov.decompose:extensions-compose", version.ref = "decompose" } encoding-base32 = { module = "io.matthewnelson.encoding:base32", version.ref = "encoding" } essenty-instanceKeeper = { module = "com.arkivanov.essenty:instance-keeper", version.ref = "essenty" } essenty-lifecycle = { module = "com.arkivanov.essenty:lifecycle", version.ref = "essenty" } -essenty-parcelable = { module = "com.arkivanov.essenty:parcelable", version.ref = "essenty" } essenty-stateKeeper = { module = "com.arkivanov.essenty:state-keeper", version.ref = "essenty" } kermit = { module = "co.touchlab:kermit", version.ref = "kermit" } koin-compose = { module = "io.insert-koin:koin-compose", version.ref = "koin-compose" } @@ -84,7 +82,6 @@ moko-resoures = { module = "dev.icerock.moko:resources", version.ref = "moko-res moko-resoures-compose = { module = "dev.icerock.moko:resources-compose", version.ref = "moko-resources" } multiplatform-settings = { module = "com.russhwolf:multiplatform-settings", version.ref = "multiplatform-settings" } multiplatform-settings-coroutines = { module = "com.russhwolf:multiplatform-settings-coroutines", version.ref = "multiplatform-settings" } -parcelize-darwinRuntime = { module = "com.arkivanov.parcelize.darwin:runtime", version.ref = "parcelize-darwin" } uriKmp = { module = "com.eygraber:uri-kmp", version.ref = "uri-kmp" } uuid = { module = "com.benasher44:uuid", version.ref = "uuid" } webcam-capture = { module = "com.github.sarxos:webcam-capture", version.ref = "webcamCapture" } @@ -98,8 +95,6 @@ android-library = { id = "com.android.library", version.ref = "android-gradle-pl compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "compose" } gradle-versions = { id = "com.github.ben-manes.versions", version.ref = "gradle-versions" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } -kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } moko-resources = { id = "dev.icerock.mobile.multiplatform-resources", version.ref = "moko-resources" } -parcelize-darwin = { id = "com.arkivanov.parcelize.darwin", version.ref = "parcelize-darwin" } version-catalog-update = { id = "nl.littlerobots.version-catalog-update", version.ref = "version-catalog-update" } \ No newline at end of file diff --git a/iosApp/iosApp/ContentView.swift b/iosApp/iosApp/ContentView.swift index 769cb44..e331d25 100644 --- a/iosApp/iosApp/ContentView.swift +++ b/iosApp/iosApp/ContentView.swift @@ -22,8 +22,8 @@ struct ContentView: View { var body: some View { let backgroundColor = Color( colorScheme == .dark - ? SwiftHelpersKt.MD_THEME_DARK_BACKGROUND - : SwiftHelpersKt.MD_THEME_LIGHT_BACKGROUND + ? ThemeHelpersKt.MD_THEME_DARK_BACKGROUND + : ThemeHelpersKt.MD_THEME_LIGHT_BACKGROUND ) ZStack { backgroundColor diff --git a/iosApp/iosApp/iOSApp.swift b/iosApp/iosApp/iOSApp.swift index 099e686..9c17495 100644 --- a/iosApp/iosApp/iOSApp.swift +++ b/iosApp/iosApp/iOSApp.swift @@ -5,7 +5,7 @@ import shared struct iOSApp: App { init() { - SwiftHelpersKt.doInitIOSKoin() + KoinHelpersKt.doInitIOSKoin() } @UIApplicationDelegateAdaptor(AppDelegate.self) @@ -33,26 +33,19 @@ struct iOSApp: App { } } -private let STATE_KEY: String = "open-otp-saved-state" - class AppDelegate: NSObject, UIApplicationDelegate { private var rootHolder: RootHolder? func application(_ application: UIApplication, shouldSaveSecureApplicationState coder: NSCoder) -> Bool { - let savedState = rootHolder!.stateKeeper.save() - CodingKt.encodeParcelable(coder, value: savedState, key: STATE_KEY) + StateKeeperUtilsKt.save(coder: coder, state: rootHolder!.stateKeeper.save()) return true } func application(_ application: UIApplication, shouldRestoreSecureApplicationState coder: NSCoder) -> Bool { - do { - let savedState = try CodingKt.decodeParcelable(coder, key: STATE_KEY) as! ParcelableParcelableContainer - rootHolder = RootHolder(savedState: savedState) - return true - } catch { - return false - } + let savedState = StateKeeperUtilsKt.restore(coder: coder) + rootHolder = RootHolder(savedState: savedState) + return true } fileprivate func getRootHolder() -> RootHolder { @@ -68,7 +61,7 @@ private class RootHolder { let stateKeeper: StateKeeperDispatcher let root: OpenOtpAppComponent - init(savedState: ParcelableParcelableContainer?) { + init(savedState: SerializableContainer?) { lifecycle = LifecycleRegistryKt.LifecycleRegistry() stateKeeper = StateKeeperDispatcherKt.StateKeeperDispatcher(savedState: savedState) diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 9451d1f..24ee944 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -7,8 +7,6 @@ plugins { alias(libs.plugins.android.library) alias(libs.plugins.compose.multiplatform) alias(libs.plugins.kotlin.serialization) - alias(libs.plugins.kotlin.parcelize) - alias(libs.plugins.parcelize.darwin) alias(libs.plugins.moko.resources) } @@ -28,7 +26,6 @@ kotlin { export(libs.decompose) export(libs.essenty.lifecycle) export(libs.essenty.stateKeeper) - export(libs.parcelize.darwinRuntime) } } @@ -84,14 +81,13 @@ kotlin { implementation(libs.multiplatform.settings.coroutines) api(libs.decompose) - api(libs.decompose.extensionsComposeJetbrains) + api(libs.decompose.extensionsCompose) implementation(libs.kotlinx.serialization.json) implementation(libs.kotlinx.serialization.cbor) api(libs.essenty.lifecycle) api(libs.essenty.stateKeeper) - api(libs.essenty.parcelable) api(libs.essenty.instanceKeeper) api(libs.moko.resoures) @@ -137,8 +133,6 @@ kotlin { dependencies { implementation(libs.ktor.client.darwin) - - api(libs.parcelize.darwinRuntime) } } diff --git a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/OpenOtpApp.kt b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/OpenOtpApp.kt index d8f215a..638efaf 100644 --- a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/OpenOtpApp.kt +++ b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/OpenOtpApp.kt @@ -8,10 +8,10 @@ import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier -import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children -import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.slide -import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.stackAnimation -import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState +import com.arkivanov.decompose.extensions.compose.stack.Children +import com.arkivanov.decompose.extensions.compose.stack.animation.slide +import com.arkivanov.decompose.extensions.compose.stack.animation.stackAnimation +import com.arkivanov.decompose.extensions.compose.subscribeAsState import `in`.procyk.compose.util.OnceLaunchedEffect import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.serialization.builtins.ListSerializer diff --git a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/FilteredOtpCodeItems.kt b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/FilteredOtpCodeItems.kt index 7d9831d..689da47 100644 --- a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/FilteredOtpCodeItems.kt +++ b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/FilteredOtpCodeItems.kt @@ -7,7 +7,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.offset import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Search import androidx.compose.material.icons.filled.Settings @@ -88,7 +88,7 @@ internal fun FilteredOtpCodeItems( }, ) { Icon( - imageVector = Icons.Default.ArrowBack, + imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(OpenOtpResources.strings.back_icon_name) ) } diff --git a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/OtpCodeItems.kt b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/OtpCodeItems.kt index f0c0c4d..839128a 100644 --- a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/OtpCodeItems.kt +++ b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/OtpCodeItems.kt @@ -6,14 +6,17 @@ import androidx.compose.animation.core.* import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.DismissDirection.EndToStart +import androidx.compose.material.DismissDirection.StartToEnd +import androidx.compose.material.DismissState +import androidx.compose.material.DismissValue.* +import androidx.compose.material.SwipeToDismiss import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Cached import androidx.compose.material.icons.filled.ContentCopy import androidx.compose.material.icons.filled.Delete +import androidx.compose.material.rememberDismissState import androidx.compose.material3.* -import androidx.compose.material3.DismissDirection.EndToStart -import androidx.compose.material3.DismissDirection.StartToEnd -import androidx.compose.material3.DismissValue.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -71,7 +74,7 @@ internal fun OtpCodeItems( val currentItem by rememberUpdatedState(item) val localClipboardManager = LocalClipboardManager.current val dismissState = rememberDismissState( - confirmValueChange = { + confirmStateChange = { when (it) { DismissedToEnd -> localClipboardManager.copyOtpCode(currentItem, currentTimestamp).letTrue() DismissedToStart -> when (confirmCodeDismiss) { diff --git a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/SearchBar.kt b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/SearchBar.kt index b226c84..1723f3f 100644 --- a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/SearchBar.kt +++ b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/component/SearchBar.kt @@ -39,6 +39,7 @@ import kotlinx.coroutines.delay import ml.dev.kotlin.openotp.ui.component.SearchBarDefaults.InputFieldHeight import kotlin.math.max import kotlin.math.min +import androidx.compose.foundation.layout.MutableWindowInsets as UnconsumedInsets @Composable @@ -86,7 +87,7 @@ internal fun SearchBar( else -> shape } } - val unconsumedInsets = remember { MutableWindowInsets() } + val unconsumedInsets = remember { UnconsumedInsets() } val topPadding = remember(density) { derivedStateOf { SearchBarVerticalPadding + unconsumedInsets.asPaddingValues(density).calculateTopPadding() diff --git a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/AddProviderScreen.kt b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/AddProviderScreen.kt index ec65e96..abdbe65 100644 --- a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/AddProviderScreen.kt +++ b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/AddProviderScreen.kt @@ -14,7 +14,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState +import com.arkivanov.decompose.extensions.compose.subscribeAsState import dev.icerock.moko.resources.compose.stringResource import ml.dev.kotlin.openotp.component.AddHotpProviderComponent import ml.dev.kotlin.openotp.component.AddOtpProviderComponent diff --git a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/LinkAccountScreen.kt b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/LinkAccountScreen.kt index a7500bf..a49ea16 100644 --- a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/LinkAccountScreen.kt +++ b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/LinkAccountScreen.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.rotate import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.unit.dp -import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState +import com.arkivanov.decompose.extensions.compose.subscribeAsState import dev.icerock.moko.resources.compose.stringResource import ml.dev.kotlin.openotp.component.LinkAccountComponent import ml.dev.kotlin.openotp.shared.OpenOtpResources diff --git a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/MainScreen.kt b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/MainScreen.kt index 896fbeb..39bf877 100644 --- a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/MainScreen.kt +++ b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/MainScreen.kt @@ -13,7 +13,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.ClipboardManager import androidx.compose.ui.unit.dp -import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState +import com.arkivanov.decompose.extensions.compose.subscribeAsState import dev.icerock.moko.resources.compose.stringResource import `in`.procyk.compose.camera.permission.CameraPermission.Denied import `in`.procyk.compose.camera.permission.CameraPermission.Granted diff --git a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/SettingsScreen.kt b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/SettingsScreen.kt index 7c49cb9..632fc6e 100644 --- a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/SettingsScreen.kt +++ b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/SettingsScreen.kt @@ -16,7 +16,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState +import com.arkivanov.decompose.extensions.compose.subscribeAsState import dev.icerock.moko.resources.compose.stringResource import ml.dev.kotlin.openotp.component.OpenOtpAppTheme import ml.dev.kotlin.openotp.component.SettingsComponent @@ -123,7 +123,7 @@ private fun CodesManagementSettingsGroup(component: SettingsComponent) { checked = confirmOtpDataDelete, onCheckedChange = component::onConfirmOtpDataDeleteChange, ) - Divider() + HorizontalDivider() val sortOtpDataBy by component.sortOtpDataBy.subscribeAsState() NamedDropdownMenu( diff --git a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/theme/Theme.kt b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/theme/Theme.kt index 2a6b280..04ad0b1 100644 --- a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/theme/Theme.kt +++ b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/theme/Theme.kt @@ -3,7 +3,7 @@ package ml.dev.kotlin.openotp.ui.theme import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState +import com.arkivanov.decompose.extensions.compose.subscribeAsState import ml.dev.kotlin.openotp.component.OpenOtpAppComponent @Composable diff --git a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/util/Material3ComposeUtil.kt b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/util/Material3ComposeUtil.kt index eb7884b..59768b6 100644 --- a/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/util/Material3ComposeUtil.kt +++ b/shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/util/Material3ComposeUtil.kt @@ -2,10 +2,8 @@ package ml.dev.kotlin.openotp.util import androidx.compose.foundation.background import androidx.compose.foundation.layout.* -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -57,7 +55,7 @@ internal fun TopBarClickableIconScreen( ) { ClickableIconButton(onClick = onIconClick) { Icon( - imageVector = Icons.Default.ArrowBack, + imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(OpenOtpResources.strings.back_icon_name), tint = contentColorFor(accent), ) diff --git a/shared/src/desktopMain/kotlin/main.desktop.kt b/shared/src/desktopMain/kotlin/main.desktop.kt index 07f1df6..a58e42e 100644 --- a/shared/src/desktopMain/kotlin/main.desktop.kt +++ b/shared/src/desktopMain/kotlin/main.desktop.kt @@ -7,7 +7,7 @@ import androidx.compose.ui.window.Window import androidx.compose.ui.window.application import androidx.compose.ui.window.rememberWindowState import com.arkivanov.decompose.DefaultComponentContext -import com.arkivanov.decompose.extensions.compose.jetbrains.lifecycle.LifecycleController +import com.arkivanov.decompose.extensions.compose.lifecycle.LifecycleController import com.arkivanov.essenty.lifecycle.LifecycleRegistry import ml.dev.kotlin.openotp.OpenOtpApp import ml.dev.kotlin.openotp.component.OpenOtpAppComponentContext diff --git a/shared/src/iosMain/kotlin/KoinHelpers.kt b/shared/src/iosMain/kotlin/KoinHelpers.kt new file mode 100644 index 0000000..c7f0fb6 --- /dev/null +++ b/shared/src/iosMain/kotlin/KoinHelpers.kt @@ -0,0 +1,14 @@ +import ml.dev.kotlin.openotp.component.OpenOtpAppComponentContext +import ml.dev.kotlin.openotp.initOpenOtpKoin +import ml.dev.kotlin.openotp.util.BiometryAuthenticator +import org.koin.dsl.module + +@Suppress("UNUSED") +fun initIOSKoin() { + initOpenOtpKoin { + modules(module { + single { OpenOtpAppComponentContext() } + single { BiometryAuthenticator() } + }) + } +} diff --git a/shared/src/iosMain/kotlin/StateKeeperUtils.kt b/shared/src/iosMain/kotlin/StateKeeperUtils.kt new file mode 100644 index 0000000..4a31e74 --- /dev/null +++ b/shared/src/iosMain/kotlin/StateKeeperUtils.kt @@ -0,0 +1,30 @@ +import com.arkivanov.essenty.statekeeper.SerializableContainer +import kotlinx.cinterop.BetaInteropApi +import kotlinx.cinterop.ExperimentalForeignApi +import kotlinx.serialization.json.Json +import platform.Foundation.NSCoder +import platform.Foundation.NSString +import platform.Foundation.decodeTopLevelObjectOfClass +import platform.Foundation.encodeObject + +private val json: Json = Json { + allowStructuredMapKeys = true +} + +private const val STATE_KEY = "open-otp-saved-state" + +@Suppress("UNUSED") +fun save(coder: NSCoder, state: SerializableContainer) { + coder.encodeObject(`object` = json.encodeToString(SerializableContainer.serializer(), state), forKey = STATE_KEY) +} + +@Suppress("UNUSED") +@OptIn(ExperimentalForeignApi::class, BetaInteropApi::class) +fun restore(coder: NSCoder): SerializableContainer? { + val string = coder.decodeTopLevelObjectOfClass(aClass = NSString, forKey = STATE_KEY, error = null) as? String? ?: return null + return try { + json.decodeFromString(SerializableContainer.serializer(), string) + } catch (e: Exception) { + null + } +} \ No newline at end of file diff --git a/shared/src/iosMain/kotlin/SwiftHelpers.kt b/shared/src/iosMain/kotlin/ThemeHelpers.kt similarity index 64% rename from shared/src/iosMain/kotlin/SwiftHelpers.kt rename to shared/src/iosMain/kotlin/ThemeHelpers.kt index 7a59204..a4ec01e 100644 --- a/shared/src/iosMain/kotlin/SwiftHelpers.kt +++ b/shared/src/iosMain/kotlin/ThemeHelpers.kt @@ -1,20 +1,8 @@ -import ml.dev.kotlin.openotp.component.OpenOtpAppComponentContext -import ml.dev.kotlin.openotp.initOpenOtpKoin import ml.dev.kotlin.openotp.ui.theme.md_theme_dark_background import ml.dev.kotlin.openotp.ui.theme.md_theme_light_background -import ml.dev.kotlin.openotp.util.BiometryAuthenticator -import org.koin.dsl.module import platform.UIKit.UIColor -fun initIOSKoin() { - initOpenOtpKoin { - modules(module { - single { OpenOtpAppComponentContext() } - single { BiometryAuthenticator() } - }) - } -} - +@Suppress("UNUSED") val MD_THEME_LIGHT_BACKGROUND: UIColor = UIColor( red = md_theme_light_background.red.toDouble(), green = md_theme_light_background.green.toDouble(), @@ -22,6 +10,7 @@ val MD_THEME_LIGHT_BACKGROUND: UIColor = UIColor( alpha = md_theme_light_background.alpha.toDouble(), ) +@Suppress("UNUSED") val MD_THEME_DARK_BACKGROUND: UIColor = UIColor( red = md_theme_dark_background.red.toDouble(), green = md_theme_dark_background.green.toDouble(),