Persist exchange rates, selected currencies, and price source via SQLDelight
Adds a SQLDelight-backed AppDatabase (Android, Desktop, iOS/macOS) so the converter survives restarts: the last-known rates per price source, the user's selected fiat currencies (with order preserved), and the last-used price source all reload before the first network fetch completes. Web isn't a shipped platform and SQLDelight's driver there needs a worker plus a wasm sqlite binary, so it gets a lighter localStorage-backed implementation of the same store interfaces instead. Android needs an app Context for its driver, wired via a new SatsPriceApplication. iOS/macOS need libsqlite3 linked explicitly (Swift's autolinking only covers Shared.framework itself, not its C library dependencies), plus two extension-loading symbols marked optional since macOS's system sqlite build omits them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QpjMKWGoiT5aJBzhxvXkwp
This commit is contained in:
+17
-1
@@ -8,6 +8,7 @@ plugins {
|
||||
alias(libs.plugins.composeCompiler)
|
||||
alias(libs.plugins.kotlinSerialization)
|
||||
alias(libs.plugins.mokoResources)
|
||||
alias(libs.plugins.sqldelight)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -64,6 +65,7 @@ kotlin {
|
||||
implementation(libs.compose.uiToolingPreview)
|
||||
implementation(libs.compose.uiTooling)
|
||||
implementation(libs.ktor.client.okhttp)
|
||||
implementation(libs.sqldelight.androidDriver)
|
||||
}
|
||||
commonMain.dependencies {
|
||||
implementation(libs.compose.runtime)
|
||||
@@ -82,6 +84,7 @@ kotlin {
|
||||
implementation(libs.ktor.client.contentNegotiation)
|
||||
implementation(libs.ktor.serialization.kotlinxJson)
|
||||
implementation(libs.bignum)
|
||||
implementation(libs.sqldelight.runtime)
|
||||
}
|
||||
commonTest.dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
@@ -90,9 +93,14 @@ kotlin {
|
||||
}
|
||||
appleMain.dependencies {
|
||||
implementation(libs.ktor.client.darwin)
|
||||
implementation(libs.sqldelight.nativeDriver)
|
||||
}
|
||||
jvmMain.dependencies {
|
||||
implementation(libs.ktor.client.cio)
|
||||
implementation(libs.sqldelight.sqliteDriver)
|
||||
}
|
||||
webMain.dependencies {
|
||||
implementation(libs.kotlinx.browser)
|
||||
}
|
||||
jsMain.dependencies {
|
||||
implementation(libs.wrappers.browser)
|
||||
@@ -110,4 +118,12 @@ dependencies {
|
||||
|
||||
multiplatformResources {
|
||||
resourcesPackage.set("xyz.tyiu.satsprice.shared")
|
||||
}
|
||||
}
|
||||
|
||||
sqldelight {
|
||||
databases {
|
||||
register("AppDatabase") {
|
||||
packageName.set("xyz.tyiu.satsprice.db")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user