diff --git a/desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/Main.kt b/desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/Main.kt index dad9ef4d..d2f17f3a 100644 --- a/desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/Main.kt +++ b/desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/Main.kt @@ -72,6 +72,7 @@ fun main() = application { val sentryDns = properties["sentry_dns"] ?.toString() + val version = properties["version"] ?.toString() @@ -136,7 +137,9 @@ fun main() = application { aboutDialogState = false }, ) { - AboutContent() + AboutContent( + versionLabel = "Version: ${version ?: "N/A"}", + ) } FeedFlowMenuBar( diff --git a/desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/about/AboutContent.kt b/desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/about/AboutContent.kt index b37d59b0..889db680 100644 --- a/desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/about/AboutContent.kt +++ b/desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/about/AboutContent.kt @@ -7,12 +7,15 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.rememberScrollbarAdapter +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.getValue @@ -21,6 +24,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.prof18.feedflow.MR import com.prof18.feedflow.core.utils.Websites.FEED_FLOW_WEBSITE @@ -35,7 +39,9 @@ import com.prof18.feedflow.ui.style.Spacing import dev.icerock.moko.resources.compose.stringResource @Composable -fun AboutContent() { +fun AboutContent( + versionLabel: String, +) { FeedFlowTheme { Scaffold { paddingValues -> @@ -62,6 +68,7 @@ fun AboutContent() { ) { SettingsItemList( listState = listState, + versionLabel = versionLabel, showLicensesScreen = { showLicensesScreen = true }, @@ -92,6 +99,7 @@ fun AboutContent() { @Composable private fun SettingsItemList( listState: LazyListState, + versionLabel: String, showLicensesScreen: () -> Unit, ) { LazyColumn( @@ -119,6 +127,15 @@ private fun SettingsItemList( buttonText = stringResource(MR.strings.open_source_licenses), ) } + + item { + Text( + modifier = Modifier.fillMaxWidth(), + text = versionLabel, + style = MaterialTheme.typography.labelSmall, + textAlign = TextAlign.Center, + ) + } } } @@ -126,6 +143,8 @@ private fun SettingsItemList( @Composable private fun AboutContentPreview() { FeedFlowTheme { - AboutContent() + AboutContent( + versionLabel = "Version: 1.0.0", + ) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a3e4c7cb..311f88bb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -30,7 +30,7 @@ lifecycle-runtime-compose = "2.6.1" kotlinx-serialization = "1.5.1" org-robolectric = "4.9" sql-delight = "2.0.0" -rss-parser = "6.0.1" +rss-parser = "6.0.2" kotlinx-date-time = "0.4.0" accompanist = "0.28.0" jsoup = "1.15.3" diff --git a/shared/src/desktopMain/kotlin/com/prof18/feedflow/AppDataPathBuilder.kt b/shared/src/desktopMain/kotlin/com/prof18/feedflow/AppDataPathBuilder.kt index 9a17b13b..bf7b1fcd 100644 --- a/shared/src/desktopMain/kotlin/com/prof18/feedflow/AppDataPathBuilder.kt +++ b/shared/src/desktopMain/kotlin/com/prof18/feedflow/AppDataPathBuilder.kt @@ -1,5 +1,6 @@ package com.prof18.feedflow +import com.prof18.feedflow.utils.AppEnvironment import java.io.File internal object AppDataPathBuilder { @@ -16,8 +17,12 @@ internal object AppDataPathBuilder { } } - fun getAppDataPath(): String { - val appPath = appDataPath + fun getAppDataPath(appEnvironment: AppEnvironment): String { + val appPath = if (appEnvironment.isDebug()) { + "$appDataPath-dev" + } else { + appDataPath + } if (!File(appPath).exists()) { File(appPath).mkdirs() } diff --git a/shared/src/desktopMain/kotlin/com/prof18/feedflow/DbInitializer.kt b/shared/src/desktopMain/kotlin/com/prof18/feedflow/DbInitializer.kt index 0fee2400..2f50e962 100644 --- a/shared/src/desktopMain/kotlin/com/prof18/feedflow/DbInitializer.kt +++ b/shared/src/desktopMain/kotlin/com/prof18/feedflow/DbInitializer.kt @@ -6,11 +6,15 @@ import app.cash.sqldelight.driver.jdbc.sqlite.JdbcSqliteDriver import co.touchlab.kermit.Logger import com.prof18.feedflow.data.DatabaseHelper import com.prof18.feedflow.db.FeedFlowDB +import com.prof18.feedflow.utils.AppEnvironment import java.io.File import java.util.Properties -internal fun initDatabase(logger: Logger): SqlDriver { - val appPath = AppDataPathBuilder.getAppDataPath() +internal fun initDatabase( + appEnvironment: AppEnvironment, + logger: Logger, +): SqlDriver { + val appPath = AppDataPathBuilder.getAppDataPath(appEnvironment) val databasePath = File(appPath, "/${DatabaseHelper.DB_FILE_NAME_WITH_EXTENSION}") @@ -29,12 +33,12 @@ internal fun initDatabase(logger: Logger): SqlDriver { if (currentVer == 0L) { FeedFlowDB.Schema.create(driver) - setVersion(driver, 1) - logger.d("init: created tables, setVersion to 1") + setVersion(driver, FeedFlowDB.Schema.version) + logger.d("init: created tables, setVersion to ${FeedFlowDB.Schema.version}") } else { val schemaVer = FeedFlowDB.Schema.version if (schemaVer > currentVer) { - FeedFlowDB.Schema.migrate(driver, currentVer, schemaVer) + FeedFlowDB.Schema.migrate(driver, oldVersion = currentVer, newVersion = schemaVer) setVersion(driver, schemaVer) logger.d("init: migrated from $currentVer to $schemaVer") } else { diff --git a/shared/src/desktopMain/kotlin/com/prof18/feedflow/di/KoinDesktop.kt b/shared/src/desktopMain/kotlin/com/prof18/feedflow/di/KoinDesktop.kt index e1bce46f..dc281381 100644 --- a/shared/src/desktopMain/kotlin/com/prof18/feedflow/di/KoinDesktop.kt +++ b/shared/src/desktopMain/kotlin/com/prof18/feedflow/di/KoinDesktop.kt @@ -27,7 +27,7 @@ fun initKoinDesktop( modules: List, ): KoinApplication = initKoin( appEnvironment = appEnvironment, - modules = modules, + modules = modules + getDatabaseModule(appEnvironment), ) internal actual inline fun Module.viewModel( @@ -35,13 +35,17 @@ internal actual inline fun Module.viewModel( noinline definition: Definition, ): KoinDefinition = factory(qualifier, definition) -internal actual val platformModule: Module = module { - single { - initDatabase( - logger = getWith("initDatabase"), - ) +private fun getDatabaseModule(appEnvironment: AppEnvironment): Module = + module { + single { + initDatabase( + appEnvironment = appEnvironment, + logger = getWith("initDatabase"), + ) + } } +internal actual val platformModule: Module = module { factory { OpmlFeedHandler( dispatcherProvider = get(),