Moved now all Sqldelight related classes and settings over to BankingPersistence - and finally it compiles on iOS!
This commit is contained in:
parent
0f89314ba3
commit
6564a9d33d
|
@ -30,8 +30,8 @@ kotlin {
|
||||||
iosSimulatorArm64()
|
iosSimulatorArm64()
|
||||||
).forEach { iosTarget ->
|
).forEach { iosTarget ->
|
||||||
iosTarget.binaries.framework {
|
iosTarget.binaries.framework {
|
||||||
baseName = "ComposeApp"
|
baseName = "BankingPersistence"
|
||||||
isStatic = false
|
isStatic = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,9 +40,14 @@ kotlin {
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
commonMain.dependencies {
|
commonMain.dependencies {
|
||||||
|
implementation(libs.banking.client.model)
|
||||||
|
implementation(libs.kotlinx.datetime)
|
||||||
|
|
||||||
implementation(libs.sqldelight.runtime)
|
implementation(libs.sqldelight.runtime)
|
||||||
implementation(libs.sqldelight.coroutines.extensions)
|
implementation(libs.sqldelight.coroutines.extensions)
|
||||||
implementation(libs.sqldelight.paging.extensions)
|
implementation(libs.sqldelight.paging.extensions)
|
||||||
|
|
||||||
|
implementation(libs.klf)
|
||||||
}
|
}
|
||||||
|
|
||||||
commonTest.dependencies {
|
commonTest.dependencies {
|
||||||
|
@ -51,20 +56,20 @@ kotlin {
|
||||||
implementation(libs.coroutines.test)
|
implementation(libs.coroutines.test)
|
||||||
}
|
}
|
||||||
|
|
||||||
androidMain.dependencies {
|
jvmMain.dependencies {
|
||||||
implementation(libs.sqldelight.android.driver)
|
implementation(libs.sqldelight.sqlite.driver)
|
||||||
}
|
|
||||||
|
|
||||||
iosMain.dependencies {
|
|
||||||
implementation(libs.sqldelight.native.driver)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jvmTest.dependencies {
|
jvmTest.dependencies {
|
||||||
implementation(libs.kotlin.test.junit)
|
implementation(libs.kotlin.test.junit)
|
||||||
}
|
}
|
||||||
|
|
||||||
jvmMain.dependencies {
|
androidMain.dependencies {
|
||||||
implementation(libs.sqldelight.sqlite.driver)
|
implementation(libs.sqldelight.android.driver)
|
||||||
|
}
|
||||||
|
|
||||||
|
iosMain.dependencies {
|
||||||
|
implementation(libs.sqldelight.native.driver)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package net.codinux.banking.dataaccess
|
package net.codinux.banking.persistence
|
||||||
|
|
||||||
import net.codinux.banking.client.model.AccountTransaction
|
import net.codinux.banking.client.model.AccountTransaction
|
||||||
import net.codinux.banking.client.model.BankAccess
|
import net.codinux.banking.client.model.BankAccess
|
||||||
import net.codinux.banking.client.model.securitiesaccount.Holding
|
import net.codinux.banking.client.model.securitiesaccount.Holding
|
||||||
import net.codinux.banking.dataaccess.entities.AccountTransactionEntity
|
import net.codinux.banking.persistence.entities.AccountTransactionEntity
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccountEntity
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
import net.codinux.banking.dataaccess.entities.HoldingEntity
|
import net.codinux.banking.persistence.entities.HoldingEntity
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
|
import net.codinux.banking.persistence.entities.UiSettingsEntity
|
||||||
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
||||||
import net.codinux.banking.ui.model.settings.AppSettings
|
import net.codinux.banking.ui.model.settings.AppSettings
|
||||||
import net.codinux.banking.ui.settings.UiSettings
|
|
||||||
|
|
||||||
interface BankingRepository {
|
interface BankingRepository {
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ interface BankingRepository {
|
||||||
|
|
||||||
suspend fun saveAppSettings(settings: AppSettings)
|
suspend fun saveAppSettings(settings: AppSettings)
|
||||||
|
|
||||||
fun getUiSettings(settings: UiSettings)
|
fun getUiSettings(): UiSettingsEntity?
|
||||||
|
|
||||||
suspend fun saveUiSettings(settings: UiSettings)
|
suspend fun saveUiSettings(settings: UiSettingsEntity)
|
||||||
|
|
||||||
|
|
||||||
fun getAllBanks(): List<BankAccessEntity>
|
fun getAllBanks(): List<BankAccessEntity>
|
|
@ -1,16 +0,0 @@
|
||||||
package net.codinux.banking.persistence
|
|
||||||
|
|
||||||
import app.cash.sqldelight.db.QueryResult
|
|
||||||
import app.cash.sqldelight.db.SqlDriver
|
|
||||||
import app.cash.sqldelight.db.SqlSchema
|
|
||||||
|
|
||||||
expect fun createSqlDriverDriver(dbName: String, schema: SqlSchema<QueryResult.AsyncValue<Unit>>, version: Long): SqlDriver
|
|
||||||
|
|
||||||
|
|
||||||
class BankingRepositoryNewStart {
|
|
||||||
|
|
||||||
private val schema = BankmeisterDb.Schema
|
|
||||||
|
|
||||||
private val sqlDriver = createSqlDriverDriver("Bankmeister.db", schema, 1L)
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,15 +1,16 @@
|
||||||
package net.codinux.banking.dataaccess
|
package net.codinux.banking.persistence
|
||||||
|
|
||||||
import net.codinux.banking.client.model.AccountTransaction
|
import net.codinux.banking.client.model.AccountTransaction
|
||||||
import net.codinux.banking.client.model.BankAccess
|
import net.codinux.banking.client.model.BankAccess
|
||||||
import net.codinux.banking.client.model.securitiesaccount.Holding
|
import net.codinux.banking.client.model.securitiesaccount.Holding
|
||||||
import net.codinux.banking.dataaccess.entities.AccountTransactionEntity
|
import net.codinux.banking.persistence.entities.AccountTransactionEntity
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccountEntity
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
import net.codinux.banking.dataaccess.entities.HoldingEntity
|
import net.codinux.banking.persistence.entities.HoldingEntity
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
|
import net.codinux.banking.persistence.entities.UiSettingsEntity
|
||||||
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
||||||
import net.codinux.banking.ui.model.settings.AppSettings
|
import net.codinux.banking.ui.model.settings.AppSettings
|
||||||
import net.codinux.banking.ui.settings.UiSettings
|
import net.codinux.banking.ui.model.settings.TransactionsGrouping
|
||||||
|
|
||||||
class InMemoryBankingRepository(
|
class InMemoryBankingRepository(
|
||||||
banks: Collection<BankAccess> = emptyList(),
|
banks: Collection<BankAccess> = emptyList(),
|
||||||
|
@ -23,7 +24,7 @@ class InMemoryBankingRepository(
|
||||||
|
|
||||||
private val transactions = transactions.map { map(it) }.toMutableList()
|
private val transactions = transactions.map { map(it) }.toMutableList()
|
||||||
|
|
||||||
private lateinit var uiSettings: UiSettings
|
private var uiSettings: UiSettingsEntity = UiSettingsEntity(true, TransactionsGrouping.Month, true, true, true)
|
||||||
|
|
||||||
|
|
||||||
override fun getAppSettings(): AppSettings? = appSettings
|
override fun getAppSettings(): AppSettings? = appSettings
|
||||||
|
@ -32,11 +33,9 @@ class InMemoryBankingRepository(
|
||||||
this.appSettings = settings
|
this.appSettings = settings
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getUiSettings(settings: UiSettings) {
|
override fun getUiSettings() = this.uiSettings
|
||||||
this.uiSettings = settings
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun saveUiSettings(settings: UiSettings) {
|
override suspend fun saveUiSettings(settings: UiSettingsEntity) {
|
||||||
this.uiSettings = settings
|
this.uiSettings = settings
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,45 @@
|
||||||
package net.codinux.banking.dataaccess
|
package net.codinux.banking.persistence
|
||||||
|
|
||||||
|
import app.cash.sqldelight.db.QueryResult
|
||||||
import app.cash.sqldelight.db.SqlDriver
|
import app.cash.sqldelight.db.SqlDriver
|
||||||
|
import app.cash.sqldelight.db.SqlSchema
|
||||||
import kotlinx.datetime.Instant
|
import kotlinx.datetime.Instant
|
||||||
import kotlinx.datetime.LocalDate
|
import kotlinx.datetime.LocalDate
|
||||||
import net.codinux.banking.client.model.*
|
import net.codinux.banking.client.model.AccountTransaction
|
||||||
|
import net.codinux.banking.client.model.Amount
|
||||||
|
import net.codinux.banking.client.model.BankAccess
|
||||||
|
import net.codinux.banking.client.model.BankAccount
|
||||||
|
import net.codinux.banking.client.model.BankAccountFeatures
|
||||||
|
import net.codinux.banking.client.model.BankAccountType
|
||||||
|
import net.codinux.banking.client.model.BankingGroup
|
||||||
import net.codinux.banking.client.model.securitiesaccount.Holding
|
import net.codinux.banking.client.model.securitiesaccount.Holding
|
||||||
import net.codinux.banking.client.model.tan.*
|
import net.codinux.banking.client.model.tan.AllowedTanFormat
|
||||||
import net.codinux.banking.dataaccess.entities.*
|
import net.codinux.banking.client.model.tan.MobilePhoneTanMedium
|
||||||
|
import net.codinux.banking.client.model.tan.TanGeneratorTanMedium
|
||||||
|
import net.codinux.banking.client.model.tan.TanMedium
|
||||||
|
import net.codinux.banking.client.model.tan.TanMediumStatus
|
||||||
|
import net.codinux.banking.client.model.tan.TanMediumType
|
||||||
|
import net.codinux.banking.client.model.tan.TanMethod
|
||||||
|
import net.codinux.banking.client.model.tan.TanMethodType
|
||||||
|
import net.codinux.banking.persistence.entities.*
|
||||||
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
||||||
import net.codinux.banking.ui.model.TransactionsGrouping
|
|
||||||
import net.codinux.banking.ui.model.settings.AppAuthenticationMethod
|
import net.codinux.banking.ui.model.settings.AppAuthenticationMethod
|
||||||
import net.codinux.banking.ui.model.settings.AppSettings
|
import net.codinux.banking.ui.model.settings.AppSettings
|
||||||
import net.codinux.banking.ui.settings.UiSettings
|
import net.codinux.banking.ui.model.settings.TransactionsGrouping
|
||||||
import net.codinux.log.logger
|
import net.codinux.log.logger
|
||||||
import kotlin.enums.EnumEntries
|
import kotlin.enums.EnumEntries
|
||||||
import kotlin.js.JsName
|
import kotlin.js.JsName
|
||||||
import kotlin.jvm.JvmName
|
import kotlin.jvm.JvmName
|
||||||
|
|
||||||
open class SqliteBankingRepository(
|
|
||||||
sqlDriver: SqlDriver
|
expect fun createSqlDriverDriver(dbName: String, schema: SqlSchema<QueryResult.AsyncValue<Unit>>, version: Long): SqlDriver
|
||||||
) : BankingRepository {
|
|
||||||
|
|
||||||
|
open class SqliteBankingRepository : BankingRepository {
|
||||||
|
|
||||||
|
private val schema = BankmeisterDb.Schema
|
||||||
|
|
||||||
|
private val sqlDriver = createSqlDriverDriver("Bankmeister.db", schema, 1L)
|
||||||
|
|
||||||
private val database = BankmeisterDb(sqlDriver)
|
private val database = BankmeisterDb(sqlDriver)
|
||||||
|
|
||||||
|
@ -52,18 +72,20 @@ open class SqliteBankingRepository(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun getUiSettings(settings: UiSettings) {
|
override fun getUiSettings(): UiSettingsEntity? {
|
||||||
settingsQueries.getUiSettings { _, transactionsGrouping, showBalance, showBankIcons, showColoredAmounts, showTransactionsInAlternatingColors ->
|
return settingsQueries.getUiSettings { _, transactionsGrouping, showBalance, showBankIcons, showColoredAmounts, showTransactionsInAlternatingColors ->
|
||||||
settings.transactionsGrouping.value = mapToEnum(transactionsGrouping, TransactionsGrouping.entries)
|
UiSettingsEntity(
|
||||||
settings.showBalance.value = showBalance
|
showBalance,
|
||||||
settings.showBankIcons.value = showBankIcons
|
mapToEnum(transactionsGrouping, TransactionsGrouping.entries),
|
||||||
settings.showColoredAmounts.value = showColoredAmounts
|
showTransactionsInAlternatingColors,
|
||||||
settings.showTransactionsInAlternatingColors.value = showTransactionsInAlternatingColors
|
showBankIcons,
|
||||||
|
showColoredAmounts
|
||||||
|
)
|
||||||
}.executeAsOneOrNull()
|
}.executeAsOneOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun saveUiSettings(settings: UiSettings) {
|
override suspend fun saveUiSettings(settings: UiSettingsEntity) {
|
||||||
settingsQueries.upsertUiSettings(mapEnum(settings.transactionsGrouping.value), settings.showBalance.value, settings.showBankIcons.value, settings.showColoredAmounts.value, settings.showTransactionsInAlternatingColors.value)
|
settingsQueries.upsertUiSettings(mapEnum(settings.transactionsGrouping), settings.showBalance, settings.showBankIcons, settings.showColoredAmounts, settings.showTransactionsInAlternatingColors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.codinux.banking.dataaccess.entities
|
package net.codinux.banking.persistence.entities
|
||||||
|
|
||||||
import kotlinx.datetime.LocalDate
|
import kotlinx.datetime.LocalDate
|
||||||
import net.codinux.banking.client.model.AccountTransaction
|
import net.codinux.banking.client.model.AccountTransaction
|
|
@ -1,8 +1,7 @@
|
||||||
package net.codinux.banking.dataaccess.entities
|
package net.codinux.banking.persistence.entities
|
||||||
|
|
||||||
import net.codinux.banking.client.model.BankAccess
|
import net.codinux.banking.client.model.BankAccess
|
||||||
import net.codinux.banking.client.model.BankingGroup
|
import net.codinux.banking.client.model.BankingGroup
|
||||||
import net.codinux.banking.client.model.tan.TanMedium
|
|
||||||
|
|
||||||
class BankAccessEntity(
|
class BankAccessEntity(
|
||||||
val id: Long,
|
val id: Long,
|
|
@ -1,4 +1,4 @@
|
||||||
package net.codinux.banking.dataaccess.entities
|
package net.codinux.banking.persistence.entities
|
||||||
|
|
||||||
import kotlinx.datetime.Instant
|
import kotlinx.datetime.Instant
|
||||||
import kotlinx.datetime.LocalDate
|
import kotlinx.datetime.LocalDate
|
|
@ -1,4 +1,4 @@
|
||||||
package net.codinux.banking.dataaccess.entities
|
package net.codinux.banking.persistence.entities
|
||||||
|
|
||||||
import kotlinx.datetime.Instant
|
import kotlinx.datetime.Instant
|
||||||
import kotlinx.datetime.LocalDate
|
import kotlinx.datetime.LocalDate
|
|
@ -1,4 +1,4 @@
|
||||||
package net.codinux.banking.dataaccess.entities
|
package net.codinux.banking.persistence.entities
|
||||||
|
|
||||||
import net.codinux.banking.client.model.tan.*
|
import net.codinux.banking.client.model.tan.*
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.codinux.banking.dataaccess.entities
|
package net.codinux.banking.persistence.entities
|
||||||
|
|
||||||
import net.codinux.banking.client.model.tan.AllowedTanFormat
|
import net.codinux.banking.client.model.tan.AllowedTanFormat
|
||||||
import net.codinux.banking.client.model.tan.TanMethod
|
import net.codinux.banking.client.model.tan.TanMethod
|
|
@ -0,0 +1,17 @@
|
||||||
|
package net.codinux.banking.persistence.entities
|
||||||
|
|
||||||
|
import net.codinux.banking.ui.model.settings.TransactionsGrouping
|
||||||
|
|
||||||
|
class UiSettingsEntity(
|
||||||
|
|
||||||
|
val showBalance: Boolean,
|
||||||
|
|
||||||
|
val transactionsGrouping: TransactionsGrouping,
|
||||||
|
|
||||||
|
val showTransactionsInAlternatingColors: Boolean,
|
||||||
|
|
||||||
|
val showBankIcons: Boolean,
|
||||||
|
|
||||||
|
val showColoredAmounts: Boolean
|
||||||
|
|
||||||
|
)
|
|
@ -3,7 +3,7 @@ package net.codinux.banking.ui.model
|
||||||
import kotlinx.datetime.LocalDate
|
import kotlinx.datetime.LocalDate
|
||||||
import net.codinux.banking.client.model.AccountTransaction
|
import net.codinux.banking.client.model.AccountTransaction
|
||||||
import net.codinux.banking.client.model.Amount
|
import net.codinux.banking.client.model.Amount
|
||||||
import net.codinux.banking.dataaccess.entities.AccountTransactionEntity
|
import net.codinux.banking.persistence.entities.AccountTransactionEntity
|
||||||
|
|
||||||
data class AccountTransactionViewModel(
|
data class AccountTransactionViewModel(
|
||||||
val id: Long,
|
val id: Long,
|
|
@ -1,4 +1,4 @@
|
||||||
package net.codinux.banking.ui.model
|
package net.codinux.banking.ui.model.settings
|
||||||
|
|
||||||
enum class TransactionsGrouping {
|
enum class TransactionsGrouping {
|
||||||
None,
|
None,
|
|
@ -1,23 +1,18 @@
|
||||||
package net.codinux.banking.dataaccess
|
package net.codinux.banking.dataaccess
|
||||||
|
|
||||||
import app.cash.sqldelight.async.coroutines.synchronous
|
|
||||||
import app.cash.sqldelight.driver.jdbc.sqlite.JdbcSqliteDriver
|
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import kotlinx.datetime.LocalDate
|
import kotlinx.datetime.LocalDate
|
||||||
import net.codinux.banking.client.model.*
|
import net.codinux.banking.client.model.*
|
||||||
import net.codinux.banking.dataaccess.entities.AccountTransactionEntity
|
import net.codinux.banking.persistence.SqliteBankingRepository
|
||||||
|
import net.codinux.banking.persistence.entities.AccountTransactionEntity
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertNotNull
|
import kotlin.test.assertNotNull
|
||||||
|
|
||||||
class SqliteBankingRepositoryTest {
|
class SqliteBankingRepositoryTest {
|
||||||
|
|
||||||
private val sqlDriver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY).apply {
|
private val underTest = object : SqliteBankingRepository() {
|
||||||
BankmeisterDb.Schema.synchronous().create(this)
|
public override suspend fun persistTransaction(bankId: Long, accountId: Long, transaction: AccountTransaction): AccountTransactionEntity =
|
||||||
}
|
|
||||||
|
|
||||||
private val underTest = object : SqliteBankingRepository(sqlDriver) {
|
|
||||||
override public suspend fun persistTransaction(bankId: Long, accountId: Long, transaction: AccountTransaction): AccountTransactionEntity =
|
|
||||||
super.persistTransaction(bankId, accountId, transaction)
|
super.persistTransaction(bankId, accountId, transaction)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,6 @@ plugins {
|
||||||
alias(libs.plugins.compose.compiler)
|
alias(libs.plugins.compose.compiler)
|
||||||
|
|
||||||
alias(libs.plugins.kotlinxSerialization)
|
alias(libs.plugins.kotlinxSerialization)
|
||||||
|
|
||||||
alias(libs.plugins.sqldelight)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +48,14 @@ kotlin {
|
||||||
).forEach { iosTarget ->
|
).forEach { iosTarget ->
|
||||||
iosTarget.binaries.framework {
|
iosTarget.binaries.framework {
|
||||||
baseName = "ComposeApp"
|
baseName = "ComposeApp"
|
||||||
isStatic = true
|
isStatic = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// don't know why but this has to be added here, adding it in BankingPersistence.build.gradle.kt does not work
|
||||||
|
iosTarget.binaries.forEach { binary ->
|
||||||
|
if (binary is org.jetbrains.kotlin.gradle.plugin.mpp.Framework) {
|
||||||
|
binary.linkerOpts.add("-lsqlite3") // without this we get a lot of "Undefined symbol _co_touchlab_sqliter..." errors in Xcode
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +63,8 @@ kotlin {
|
||||||
val desktopMain by getting
|
val desktopMain by getting
|
||||||
|
|
||||||
commonMain.dependencies {
|
commonMain.dependencies {
|
||||||
|
implementation(project(":BankingPersistence"))
|
||||||
|
|
||||||
implementation(libs.banking.client.model)
|
implementation(libs.banking.client.model)
|
||||||
implementation(libs.fints4k.banking.client)
|
implementation(libs.fints4k.banking.client)
|
||||||
|
|
||||||
|
@ -65,10 +72,6 @@ kotlin {
|
||||||
implementation(libs.klf)
|
implementation(libs.klf)
|
||||||
implementation(libs.kotlinx.serializable)
|
implementation(libs.kotlinx.serializable)
|
||||||
|
|
||||||
implementation(libs.sqldelight.runtime)
|
|
||||||
implementation(libs.sqldelight.coroutines.extensions)
|
|
||||||
implementation(libs.sqldelight.paging.extensions)
|
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
implementation(compose.runtime)
|
implementation(compose.runtime)
|
||||||
implementation(compose.foundation)
|
implementation(compose.foundation)
|
||||||
|
@ -93,13 +96,11 @@ kotlin {
|
||||||
implementation(libs.androidx.activity.compose)
|
implementation(libs.androidx.activity.compose)
|
||||||
implementation(libs.androidx.biometric)
|
implementation(libs.androidx.biometric)
|
||||||
|
|
||||||
implementation(libs.sqldelight.android.driver)
|
|
||||||
|
|
||||||
implementation(libs.favre.bcrypt)
|
implementation(libs.favre.bcrypt)
|
||||||
}
|
}
|
||||||
|
|
||||||
iosMain.dependencies {
|
iosMain.dependencies {
|
||||||
implementation(libs.sqldelight.native.driver)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jvmTest.dependencies {
|
jvmTest.dependencies {
|
||||||
|
@ -110,8 +111,6 @@ kotlin {
|
||||||
implementation(compose.desktop.currentOs)
|
implementation(compose.desktop.currentOs)
|
||||||
implementation(libs.kotlinx.coroutines.swing)
|
implementation(libs.kotlinx.coroutines.swing)
|
||||||
|
|
||||||
implementation(libs.sqldelight.sqlite.driver)
|
|
||||||
|
|
||||||
implementation(libs.favre.bcrypt)
|
implementation(libs.favre.bcrypt)
|
||||||
|
|
||||||
implementation(libs.logback)
|
implementation(libs.logback)
|
||||||
|
@ -120,18 +119,6 @@ kotlin {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sqldelight {
|
|
||||||
databases {
|
|
||||||
create("BankmeisterDb") {
|
|
||||||
packageName.set("net.codinux.banking.dataaccess")
|
|
||||||
generateAsync = true
|
|
||||||
|
|
||||||
schemaOutputDirectory = file("src/commonMain/sqldelight/databases")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "net.codinux.banking.ui"
|
namespace = "net.codinux.banking.ui"
|
||||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||||
|
|
|
@ -5,9 +5,8 @@ import androidx.activity.compose.setContent
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import app.cash.sqldelight.async.coroutines.synchronous
|
import net.codinux.banking.persistence.AndroidContext
|
||||||
import app.cash.sqldelight.driver.android.AndroidSqliteDriver
|
import net.codinux.banking.persistence.SqliteBankingRepository
|
||||||
import net.codinux.banking.dataaccess.BankmeisterDb
|
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
import net.codinux.banking.ui.service.AuthenticationService
|
import net.codinux.banking.ui.service.AuthenticationService
|
||||||
import net.codinux.banking.ui.service.BiometricAuthenticationService
|
import net.codinux.banking.ui.service.BiometricAuthenticationService
|
||||||
|
@ -17,10 +16,12 @@ class MainActivity : FragmentActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
AndroidContext.applicationContext = this.applicationContext
|
||||||
|
|
||||||
ImageService.context = this.applicationContext
|
ImageService.context = this.applicationContext
|
||||||
AuthenticationService.biometricAuthenticationService = BiometricAuthenticationService(this)
|
AuthenticationService.biometricAuthenticationService = BiometricAuthenticationService(this)
|
||||||
|
|
||||||
DI.setRepository(AndroidSqliteDriver(BankmeisterDb.Schema.synchronous(), this, "Bankmeister.db"))
|
DI.setRepository(SqliteBankingRepository())
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
App()
|
App()
|
||||||
|
|
|
@ -13,7 +13,7 @@ import net.codinux.banking.ui.config.DI
|
||||||
import net.codinux.banking.ui.config.Internationalization
|
import net.codinux.banking.ui.config.Internationalization
|
||||||
import net.codinux.banking.ui.forms.RoundedCornersCard
|
import net.codinux.banking.ui.forms.RoundedCornersCard
|
||||||
import net.codinux.banking.ui.forms.Select
|
import net.codinux.banking.ui.forms.Select
|
||||||
import net.codinux.banking.ui.model.TransactionsGrouping
|
import net.codinux.banking.ui.model.settings.TransactionsGrouping
|
||||||
|
|
||||||
private val uiState = DI.uiState
|
private val uiState = DI.uiState
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccountEntity
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
|
|
||||||
private val uiState = DI.uiState
|
private val uiState = DI.uiState
|
||||||
|
|
|
@ -19,8 +19,8 @@ import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccountEntity
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
import net.codinux.banking.ui.config.Colors
|
import net.codinux.banking.ui.config.Colors
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import net.codinux.banking.ui.config.DI
|
||||||
import net.codinux.banking.ui.config.Internationalization
|
import net.codinux.banking.ui.config.Internationalization
|
||||||
import net.codinux.banking.ui.forms.BooleanOption
|
import net.codinux.banking.ui.forms.BooleanOption
|
||||||
import net.codinux.banking.ui.forms.Select
|
import net.codinux.banking.ui.forms.Select
|
||||||
import net.codinux.banking.ui.model.TransactionsGrouping
|
import net.codinux.banking.ui.model.settings.TransactionsGrouping
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun UiSettings(modifier: Modifier, textColor: Color = Color.Unspecified) {
|
fun UiSettings(modifier: Modifier, textColor: Color = Color.Unspecified) {
|
||||||
|
|
|
@ -14,13 +14,13 @@ import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import net.codinux.banking.client.model.Amount
|
import net.codinux.banking.client.model.Amount
|
||||||
import net.codinux.banking.client.model.securitiesaccount.Holding
|
import net.codinux.banking.client.model.securitiesaccount.Holding
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
import net.codinux.banking.ui.config.Colors
|
import net.codinux.banking.ui.config.Colors
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
import net.codinux.banking.ui.config.Style
|
import net.codinux.banking.ui.config.Style
|
||||||
import net.codinux.banking.ui.forms.RoundedCornersCard
|
import net.codinux.banking.ui.forms.RoundedCornersCard
|
||||||
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
||||||
import net.codinux.banking.ui.model.TransactionsGrouping
|
import net.codinux.banking.ui.model.settings.TransactionsGrouping
|
||||||
import net.codinux.banking.ui.service.TransactionsGroupingService
|
import net.codinux.banking.ui.service.TransactionsGroupingService
|
||||||
|
|
||||||
private val calculator = DI.calculator
|
private val calculator = DI.calculator
|
||||||
|
|
|
@ -12,7 +12,7 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import net.codinux.banking.ui.config.Colors
|
import net.codinux.banking.ui.config.Colors
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
import net.codinux.banking.ui.model.TransactionsGrouping
|
import net.codinux.banking.ui.model.settings.TransactionsGrouping
|
||||||
import net.codinux.banking.ui.settings.UiSettings
|
import net.codinux.banking.ui.settings.UiSettings
|
||||||
import net.codinux.banking.ui.state.UiState
|
import net.codinux.banking.ui.state.UiState
|
||||||
import org.jetbrains.compose.ui.tooling.preview.Preview
|
import org.jetbrains.compose.ui.tooling.preview.Preview
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package net.codinux.banking.ui.config
|
package net.codinux.banking.ui.config
|
||||||
|
|
||||||
import app.cash.sqldelight.db.SqlDriver
|
import net.codinux.banking.persistence.BankingRepository
|
||||||
import net.codinux.banking.dataaccess.BankingRepository
|
import net.codinux.banking.persistence.InMemoryBankingRepository
|
||||||
import net.codinux.banking.dataaccess.InMemoryBankingRepository
|
|
||||||
import net.codinux.banking.dataaccess.SqliteBankingRepository
|
|
||||||
import net.codinux.banking.ui.Platform
|
import net.codinux.banking.ui.Platform
|
||||||
import net.codinux.banking.ui.getPlatform
|
import net.codinux.banking.ui.getPlatform
|
||||||
import net.codinux.banking.ui.service.*
|
import net.codinux.banking.ui.service.*
|
||||||
|
@ -39,8 +37,6 @@ object DI {
|
||||||
val bankingService by lazy { BankingService(uiState, uiSettings, bankingRepository, bankFinder) }
|
val bankingService by lazy { BankingService(uiState, uiSettings, bankingRepository, bankFinder) }
|
||||||
|
|
||||||
|
|
||||||
fun setRepository(sqlDriver: SqlDriver) = setRepository(SqliteBankingRepository(sqlDriver))
|
|
||||||
|
|
||||||
fun setRepository(repository: BankingRepository) {
|
fun setRepository(repository: BankingRepository) {
|
||||||
this.bankingRepository = repository
|
this.bankingRepository = repository
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package net.codinux.banking.ui.config
|
||||||
|
|
||||||
import net.codinux.banking.client.model.BankAccountType
|
import net.codinux.banking.client.model.BankAccountType
|
||||||
import net.codinux.banking.client.model.tan.ActionRequiringTan
|
import net.codinux.banking.client.model.tan.ActionRequiringTan
|
||||||
import net.codinux.banking.ui.model.TransactionsGrouping
|
import net.codinux.banking.ui.model.settings.TransactionsGrouping
|
||||||
import net.codinux.banking.ui.model.settings.AppAuthenticationMethod
|
import net.codinux.banking.ui.model.settings.AppAuthenticationMethod
|
||||||
|
|
||||||
object Internationalization {
|
object Internationalization {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package net.codinux.banking.ui.model
|
package net.codinux.banking.ui.model
|
||||||
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccountEntity
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
|
|
||||||
class AccountTransactionsFilter {
|
class AccountTransactionsFilter {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package net.codinux.banking.ui.model
|
package net.codinux.banking.ui.model
|
||||||
|
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccountEntity
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
|
|
||||||
data class BankAccountFilter(
|
data class BankAccountFilter(
|
||||||
val bank: BankAccessEntity,
|
val bank: BankAccessEntity,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package net.codinux.banking.ui.model
|
package net.codinux.banking.ui.model
|
||||||
|
|
||||||
import net.codinux.banking.client.model.Amount
|
import net.codinux.banking.client.model.Amount
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccountEntity
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
|
|
||||||
data class ShowTransferMoneyDialogData(
|
data class ShowTransferMoneyDialogData(
|
||||||
val senderAccount: BankAccountEntity? = null,
|
val senderAccount: BankAccountEntity? = null,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import net.codinux.banking.client.model.isNegative
|
import net.codinux.banking.client.model.isNegative
|
||||||
import net.codinux.banking.dataaccess.entities.AccountTransactionEntity
|
import net.codinux.banking.persistence.entities.AccountTransactionEntity
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
import net.codinux.banking.ui.extensions.verticalScroll
|
import net.codinux.banking.ui.extensions.verticalScroll
|
||||||
import net.codinux.banking.ui.forms.LabelledValue
|
import net.codinux.banking.ui.forms.LabelledValue
|
||||||
|
|
|
@ -6,7 +6,7 @@ import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccountEntity
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
import net.codinux.banking.ui.config.Internationalization
|
import net.codinux.banking.ui.config.Internationalization
|
||||||
import net.codinux.banking.ui.extensions.verticalScroll
|
import net.codinux.banking.ui.extensions.verticalScroll
|
||||||
import net.codinux.banking.ui.forms.*
|
import net.codinux.banking.ui.forms.*
|
||||||
|
|
|
@ -5,7 +5,7 @@ import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
import net.codinux.banking.ui.extensions.verticalScroll
|
import net.codinux.banking.ui.extensions.verticalScroll
|
||||||
import net.codinux.banking.ui.forms.*
|
import net.codinux.banking.ui.forms.*
|
||||||
|
|
|
@ -13,7 +13,7 @@ import androidx.compose.ui.text.style.TextAlign
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import net.codinux.banking.dataaccess.entities.AccountTransactionEntity
|
import net.codinux.banking.persistence.entities.AccountTransactionEntity
|
||||||
import net.codinux.banking.ui.IOorDefault
|
import net.codinux.banking.ui.IOorDefault
|
||||||
import net.codinux.banking.ui.config.Colors
|
import net.codinux.banking.ui.config.Colors
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package net.codinux.banking.ui.service
|
package net.codinux.banking.ui.service
|
||||||
|
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccountEntity
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
import net.codinux.banking.dataaccess.entities.HoldingEntity
|
import net.codinux.banking.persistence.entities.HoldingEntity
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
||||||
import net.codinux.banking.ui.model.AccountTransactionsFilter
|
import net.codinux.banking.ui.model.AccountTransactionsFilter
|
||||||
import net.codinux.banking.ui.model.BankAccountFilter
|
import net.codinux.banking.ui.model.BankAccountFilter
|
||||||
|
@ -46,7 +46,7 @@ class AccountTransactionsFilterService {
|
||||||
|
|
||||||
private fun matchesSearchTerm(transaction: AccountTransactionViewModel, searchTerm: String): Boolean =
|
private fun matchesSearchTerm(transaction: AccountTransactionViewModel, searchTerm: String): Boolean =
|
||||||
transaction.reference?.contains(searchTerm, true) == true
|
transaction.reference?.contains(searchTerm, true) == true
|
||||||
|| (transaction.otherPartyName != null && transaction.otherPartyName.contains(searchTerm, true))
|
|| transaction.otherPartyName?.contains(searchTerm, true) == true
|
||||||
|
|
||||||
|
|
||||||
fun filterHoldings(holdings: List<HoldingEntity>, filter: AccountTransactionsFilter): List<HoldingEntity> {
|
fun filterHoldings(holdings: List<HoldingEntity>, filter: AccountTransactionsFilter): List<HoldingEntity> {
|
||||||
|
|
|
@ -16,8 +16,12 @@ import net.codinux.banking.client.model.request.TransferMoneyRequestForUser
|
||||||
import net.codinux.banking.client.model.response.*
|
import net.codinux.banking.client.model.response.*
|
||||||
import net.codinux.banking.client.model.securitiesaccount.Holding
|
import net.codinux.banking.client.model.securitiesaccount.Holding
|
||||||
import net.codinux.banking.client.service.BankingModelService
|
import net.codinux.banking.client.service.BankingModelService
|
||||||
import net.codinux.banking.dataaccess.BankingRepository
|
import net.codinux.banking.persistence.BankingRepository
|
||||||
import net.codinux.banking.dataaccess.entities.*
|
import net.codinux.banking.persistence.entities.AccountTransactionEntity
|
||||||
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
|
import net.codinux.banking.persistence.entities.HoldingEntity
|
||||||
|
import net.codinux.banking.persistence.entities.UiSettingsEntity
|
||||||
import net.codinux.banking.ui.IOorDefault
|
import net.codinux.banking.ui.IOorDefault
|
||||||
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
||||||
import net.codinux.banking.ui.model.BankInfo
|
import net.codinux.banking.ui.model.BankInfo
|
||||||
|
@ -57,7 +61,13 @@ class BankingService(
|
||||||
}
|
}
|
||||||
uiState.appSettings.value = appSettings
|
uiState.appSettings.value = appSettings
|
||||||
|
|
||||||
bankingRepository.getUiSettings(uiSettings)
|
bankingRepository.getUiSettings()?.let {
|
||||||
|
uiSettings.showBalance.value = it.showBalance
|
||||||
|
uiSettings.transactionsGrouping.value = it.transactionsGrouping
|
||||||
|
uiSettings.showTransactionsInAlternatingColors.value = it.showTransactionsInAlternatingColors
|
||||||
|
uiSettings.showBankIcons.value = it.showBankIcons
|
||||||
|
uiSettings.showColoredAmounts.value = it.showColoredAmounts
|
||||||
|
}
|
||||||
|
|
||||||
updateOnChanges(uiSettings)
|
updateOnChanges(uiSettings)
|
||||||
|
|
||||||
|
@ -76,7 +86,9 @@ class BankingService(
|
||||||
|
|
||||||
suspend fun saveAppSettings(settings: AppSettings) = bankingRepository.saveAppSettings(settings)
|
suspend fun saveAppSettings(settings: AppSettings) = bankingRepository.saveAppSettings(settings)
|
||||||
|
|
||||||
suspend fun saveUiSettings(settings: UiSettings) = bankingRepository.saveUiSettings(settings)
|
suspend fun saveUiSettings(settings: UiSettings) = bankingRepository.saveUiSettings(UiSettingsEntity(
|
||||||
|
settings.showBalance.value, settings.transactionsGrouping.value, settings.showTransactionsInAlternatingColors.value, settings.showBankIcons.value, settings.showColoredAmounts.value
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
fun getAllBanks() = bankingRepository.getAllBanks()
|
fun getAllBanks() = bankingRepository.getAllBanks()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package net.codinux.banking.ui.service
|
package net.codinux.banking.ui.service
|
||||||
|
|
||||||
import net.codinux.banking.client.model.*
|
import net.codinux.banking.client.model.*
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
||||||
import net.codinux.banking.ui.model.AccountTransactionsFilter
|
import net.codinux.banking.ui.model.AccountTransactionsFilter
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import kotlinx.datetime.*
|
||||||
import net.codinux.banking.client.model.Amount
|
import net.codinux.banking.client.model.Amount
|
||||||
import net.codinux.banking.client.model.isNegative
|
import net.codinux.banking.client.model.isNegative
|
||||||
import net.codinux.banking.ui.config.Colors
|
import net.codinux.banking.ui.config.Colors
|
||||||
import net.codinux.banking.ui.model.TransactionsGrouping
|
import net.codinux.banking.ui.model.settings.TransactionsGrouping
|
||||||
|
|
||||||
class FormatUtil {
|
class FormatUtil {
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import kotlinx.datetime.LocalDate
|
||||||
import kotlinx.datetime.Month
|
import kotlinx.datetime.Month
|
||||||
import net.codinux.banking.client.model.extensions.minusDays
|
import net.codinux.banking.client.model.extensions.minusDays
|
||||||
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
import net.codinux.banking.ui.model.AccountTransactionViewModel
|
||||||
import net.codinux.banking.ui.model.TransactionsGrouping
|
import net.codinux.banking.ui.model.settings.TransactionsGrouping
|
||||||
|
|
||||||
class TransactionsGroupingService {
|
class TransactionsGroupingService {
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package net.codinux.banking.ui.settings
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import net.codinux.banking.ui.model.TransactionsGrouping
|
import net.codinux.banking.ui.model.settings.TransactionsGrouping
|
||||||
|
|
||||||
class UiSettings : ViewModel() {
|
class UiSettings : ViewModel() {
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import net.codinux.banking.client.model.tan.EnterTanResult
|
import net.codinux.banking.client.model.tan.EnterTanResult
|
||||||
import net.codinux.banking.client.model.tan.TanChallenge
|
import net.codinux.banking.client.model.tan.TanChallenge
|
||||||
import net.codinux.banking.dataaccess.entities.HoldingEntity
|
import net.codinux.banking.persistence.entities.HoldingEntity
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
import net.codinux.banking.dataaccess.entities.BankAccountEntity
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
import net.codinux.banking.ui.model.*
|
import net.codinux.banking.ui.model.*
|
||||||
import net.codinux.banking.ui.model.error.ApplicationError
|
import net.codinux.banking.ui.model.error.ApplicationError
|
||||||
import net.codinux.banking.ui.model.error.BankingClientError
|
import net.codinux.banking.ui.model.error.BankingClientError
|
||||||
|
|
|
@ -6,19 +6,15 @@ import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.unit.DpSize
|
import androidx.compose.ui.unit.DpSize
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.*
|
import androidx.compose.ui.window.*
|
||||||
import app.cash.sqldelight.async.coroutines.synchronous
|
|
||||||
import app.cash.sqldelight.db.SqlDriver
|
|
||||||
import app.cash.sqldelight.driver.jdbc.sqlite.JdbcSqliteDriver
|
|
||||||
import bankmeister.composeapp.generated.resources.AppIcon_svg
|
import bankmeister.composeapp.generated.resources.AppIcon_svg
|
||||||
import bankmeister.composeapp.generated.resources.Res
|
import bankmeister.composeapp.generated.resources.Res
|
||||||
import kotlinx.datetime.LocalDate
|
import kotlinx.datetime.LocalDate
|
||||||
import net.codinux.banking.client.model.AccountTransaction
|
import net.codinux.banking.client.model.AccountTransaction
|
||||||
import net.codinux.banking.client.model.Amount
|
import net.codinux.banking.client.model.Amount
|
||||||
import net.codinux.banking.dataaccess.BankmeisterDb
|
import net.codinux.banking.persistence.InMemoryBankingRepository
|
||||||
import net.codinux.banking.dataaccess.InMemoryBankingRepository
|
import net.codinux.banking.persistence.SqliteBankingRepository
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
import org.jetbrains.compose.resources.painterResource
|
import org.jetbrains.compose.resources.painterResource
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
fun main() = application {
|
fun main() = application {
|
||||||
Window(
|
Window(
|
||||||
|
@ -27,34 +23,22 @@ fun main() = application {
|
||||||
icon = painterResource(Res.drawable.AppIcon_svg),
|
icon = painterResource(Res.drawable.AppIcon_svg),
|
||||||
state = WindowState(position = WindowPosition(Alignment.Center), size = DpSize(1000.dp, 800.dp)),
|
state = WindowState(position = WindowPosition(Alignment.Center), size = DpSize(1000.dp, 800.dp)),
|
||||||
) {
|
) {
|
||||||
DI.setRepository(createSqlDriverDriver())
|
DI.setRepository(SqliteBankingRepository())
|
||||||
|
|
||||||
App()
|
App()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createSqlDriverDriver(): SqlDriver {
|
|
||||||
File("data/db").mkdirs()
|
|
||||||
|
|
||||||
return JdbcSqliteDriver("jdbc:sqlite:data/db/Bankmeister.db").also { driver ->
|
|
||||||
BankmeisterDb.Schema.synchronous().also { schema ->
|
|
||||||
if (File("data/db/Bankmeister.db").exists() == false) {
|
|
||||||
schema.create(driver)
|
|
||||||
}
|
|
||||||
|
|
||||||
schema.migrate(driver, schema.version, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun AppPreview() {
|
fun AppPreview() {
|
||||||
DI.setRepository(InMemoryBankingRepository(
|
DI.setRepository(
|
||||||
|
InMemoryBankingRepository(
|
||||||
emptyList(),
|
emptyList(),
|
||||||
listOf(AccountTransaction(Amount("12.34"), "EUR", "Lohn", LocalDate(2024, 7, 5), LocalDate(2024, 6, 15), "Dein Boss"))
|
listOf(AccountTransaction(Amount("12.34"), "EUR", "Lohn", LocalDate(2024, 7, 5), LocalDate(2024, 6, 15), "Dein Boss"))
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
App()
|
App()
|
||||||
}
|
}
|
|
@ -1,13 +1,11 @@
|
||||||
package net.codinux.banking.ui
|
package net.codinux.banking.ui
|
||||||
|
|
||||||
import androidx.compose.ui.window.ComposeUIViewController
|
import androidx.compose.ui.window.ComposeUIViewController
|
||||||
import app.cash.sqldelight.async.coroutines.synchronous
|
import net.codinux.banking.persistence.SqliteBankingRepository
|
||||||
import app.cash.sqldelight.driver.native.NativeSqliteDriver
|
|
||||||
import net.codinux.banking.dataaccess.BankmeisterDb
|
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
|
|
||||||
fun MainViewController() = ComposeUIViewController {
|
fun MainViewController() = ComposeUIViewController {
|
||||||
DI.setRepository(NativeSqliteDriver(BankmeisterDb.Schema.synchronous(), "Bankmeister.db"))
|
DI.setRepository(SqliteBankingRepository())
|
||||||
|
|
||||||
App()
|
App()
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ banking-client = "0.6.1-SNAPSHOT"
|
||||||
|
|
||||||
kcsv = "2.2.0"
|
kcsv = "2.2.0"
|
||||||
kotlinx-serializable = "1.7.1"
|
kotlinx-serializable = "1.7.1"
|
||||||
|
kotlinx-datetime = "0.5.0"
|
||||||
|
|
||||||
favre-bcrypt = "0.10.2"
|
favre-bcrypt = "0.10.2"
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ fints4k-banking-client = { group = "net.codinux.banking.client", name = "fints4k
|
||||||
kcsv = { group = "net.codinux.csv", name = "kcsv", version.ref = "kcsv" }
|
kcsv = { group = "net.codinux.csv", name = "kcsv", version.ref = "kcsv" }
|
||||||
coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
|
coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
|
||||||
kotlinx-serializable = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serializable" }
|
kotlinx-serializable = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serializable" }
|
||||||
|
kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-datetime" }
|
||||||
|
|
||||||
favre-bcrypt = { group = "at.favre.lib", name = "bcrypt", version.ref = "favre-bcrypt" }
|
favre-bcrypt = { group = "at.favre.lib", name = "bcrypt", version.ref = "favre-bcrypt" }
|
||||||
|
|
||||||
|
|
|
@ -33,4 +33,7 @@ dependencyResolutionManagement {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// had to extract Sql'delight' dependencies to an extra project as they conflict with Compose dependencies on iOS
|
||||||
|
include(":BankingPersistence")
|
||||||
|
|
||||||
include(":composeApp")
|
include(":composeApp")
|
Loading…
Reference in New Issue