From 7542a3ab803facf43b6bf4930e08ab470aa73288 Mon Sep 17 00:00:00 2001 From: nostrbuddha Date: Wed, 13 Nov 2024 18:17:55 +0530 Subject: [PATCH] First code review corrections 1/2 --- bisqapps/gradle/libs.versions.toml | 14 ++++--- bisqapps/shared/domain/build.gradle.kts | 8 +--- .../domain/data/repository/PriceRepository.kt | 32 +++++---------- bisqapps/shared/presentation/build.gradle.kts | 6 +-- .../bisq/mobile/presentation/i18n/Locales.kt | 39 ++++++++++++++++++- 5 files changed, 59 insertions(+), 40 deletions(-) diff --git a/bisqapps/gradle/libs.versions.toml b/bisqapps/gradle/libs.versions.toml index 608df9ad..791f6703 100644 --- a/bisqapps/gradle/libs.versions.toml +++ b/bisqapps/gradle/libs.versions.toml @@ -2,7 +2,7 @@ agp = "8.5.0" android-compileSdk = "34" android-targetSdk = "34" -android-minSdk = "28" +android-minSdk = "24" android-node-minSdk = "31" androidx-activityCompose = "1.9.2" androidx-appcompat = "1.7.0" @@ -20,8 +20,10 @@ kotlin = "2.0.20" kotlinx = "1.9.0" kermit = "2.0.4" buildconfig = "5.5.0" +navigationCompose = "2.7.0-alpha07" protobuf = "0.9.4" protoblite = "4.28.2" +ksp = "2.0.20-1.0.25" chimp-jsocks-lib = { strictly = '567e1cd6' } chimp-jtorctl-lib = { strictly = '9b5ba203' } @@ -45,8 +47,7 @@ grpc = { strictly = '1.61.0' } i2p-lib = { strictly = '1.8.0' } i2p-v2 = { strictly = '2.4.0' } jackson-lib = { strictly = '2.17.2' } -ktorClientCore = "3.0.0" -lyricist = "2.0.20-1.0.25" +lyricist = "1.7.0" [libraries] kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } @@ -65,10 +66,10 @@ androidx-activity-compose = { module = "androidx.activity:activity-compose", ver androidx-lifecycle-viewmodel = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-viewmodel", version.ref = "androidx-lifecycle" } androidx-lifecycle-runtime-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" } -ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktorClientCore" } logging-kermit = { group = "co.touchlab", name = "kermit", version.ref = "kermit" } -lyricist = { module = "cafe.adriel.lyricist:lyricist", version.ref = "lyricist" } +lyricist = { module = "cafe.adriel.lyricist:lyricist", version.ref = "lyricist" } +navigation-compose = { module = "org.jetbrains.androidx.navigation:navigation-compose", version.ref = "navigationCompose" } protobuf-lite = { group ="com.google.protobuf", name = "protobuf-javalite", version.ref = "protoblite"} protobuf-gradle-plugin = { module = 'com.google.protobuf:protobuf-gradle-plugin', version.ref = 'protobuf' } protoc = { module = "com.google.protobuf:protoc", version.ref = "protoblite" } @@ -143,4 +144,5 @@ jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } buildconfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildconfig" } -protobuf = { id = "com.google.protobuf", version.ref = "protobuf" } \ No newline at end of file +protobuf = { id = "com.google.protobuf", version.ref = "protobuf" } +ksp = { id = "com.google.devtools.ksp", version.ref="ksp" } \ No newline at end of file diff --git a/bisqapps/shared/domain/build.gradle.kts b/bisqapps/shared/domain/build.gradle.kts index dc10b8b1..f1b09502 100644 --- a/bisqapps/shared/domain/build.gradle.kts +++ b/bisqapps/shared/domain/build.gradle.kts @@ -35,13 +35,7 @@ kotlin { //put your multiplatform dependencies here // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") - - // Ktor client for HTTP requests - implementation("io.ktor:ktor-client-core:3.0.0") - implementation("io.ktor:ktor-client-cio:3.0.0") // Replace with the appropriate engine for your platform - implementation("io.ktor:ktor-client-content-negotiation:3.0.0") - implementation("io.ktor:ktor-serialization-kotlinx-json:3.0.0") + implementation(libs.kotlinx.coroutines) } commonTest.dependencies { implementation(libs.kotlin.test) diff --git a/bisqapps/shared/domain/src/commonMain/kotlin/network/bisq/mobile/domain/data/repository/PriceRepository.kt b/bisqapps/shared/domain/src/commonMain/kotlin/network/bisq/mobile/domain/data/repository/PriceRepository.kt index e41787df..e10c2b0b 100644 --- a/bisqapps/shared/domain/src/commonMain/kotlin/network/bisq/mobile/domain/data/repository/PriceRepository.kt +++ b/bisqapps/shared/domain/src/commonMain/kotlin/network/bisq/mobile/domain/data/repository/PriceRepository.kt @@ -1,27 +1,23 @@ -import io.ktor.client.* -import io.ktor.client.call.* -import io.ktor.client.request.* -import io.ktor.client.statement.* -import io.ktor.client.plugins.contentnegotiation.* -import io.ktor.serialization.kotlinx.json.* -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.IO -import kotlinx.coroutines.withContext -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.Json + class PriceRepository { + suspend fun fetchBtcPrice(): String = "$70,000" + fun getValue() = "$70,000" + + /* // Ktor client setup with ContentNegotiation plugin private val client = HttpClient { install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) // Configures JSON serialization } } + */ /** * Fetches the current BTC price in USD from CoinGecko API. */ + /* suspend fun fetchBtcPrice(): String { println("fetchBtcPrice()") return withContext(Dispatchers.IO) { @@ -39,16 +35,6 @@ class PriceRepository { } } } + */ - fun getValue() = "$70,000" -} - -@Serializable -data class CoinGeckoResponse( - val bitcoin: BitcoinPrice -) - -@Serializable -data class BitcoinPrice( - val usd: Double -) +} \ No newline at end of file diff --git a/bisqapps/shared/presentation/build.gradle.kts b/bisqapps/shared/presentation/build.gradle.kts index ec5a99b6..60a5d73e 100644 --- a/bisqapps/shared/presentation/build.gradle.kts +++ b/bisqapps/shared/presentation/build.gradle.kts @@ -9,7 +9,7 @@ plugins { alias(libs.plugins.jetbrainsCompose) alias(libs.plugins.compose.compiler) alias(libs.plugins.buildconfig) - id("com.google.devtools.ksp") version "2.0.20-1.0.25" + alias(libs.plugins.ksp) } dependencies { @@ -89,8 +89,8 @@ kotlin { implementation(libs.logging.kermit) implementation(libs.kotlinx.coroutines) - implementation("org.jetbrains.androidx.navigation:navigation-compose:2.7.0-alpha07") - implementation("cafe.adriel.lyricist:lyricist:1.7.0") + implementation(libs.navigation.compose) + implementation(libs.lyricist) } val commonTest by getting { diff --git a/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/i18n/Locales.kt b/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/i18n/Locales.kt index d9102ceb..002203eb 100644 --- a/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/i18n/Locales.kt +++ b/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/i18n/Locales.kt @@ -1,6 +1,43 @@ package network.bisq.mobile.presentation.i18n +/** + * An object that holds locale codes used for the application’s supported languages. + * + * Currently, this object supports English (`EN`) as the default language and French ('FR') only for testing. + * Additional languages can be added in the future. + * + * ## Usage + * ### Locales.kt + * Defines all the supported languages + * + * ### Strigs.kt + * A class that defines variable for all text resources used in the app. + * TODO: This is going to be an insanely huge file. Look for ways to modularize it (for later) + * + * ### {Lang}Strings.kt + * One file for each language. Assigns actual text for each variable in that specific language. + * + * ### Actual usage: + * 1. Each view should be enclosed by `ProviderStrings`. This is now done at top level in App.kt + * + * val lyricist = rememberStrings() + * ProvideStrings(lyricist) {} + * + * 2. And current language can be changed anytime by doing + * + * lyricist.languageTag = Locales.FR + * + * 3. In the views, string resources can be accessed by + * + * LocalStrings.current.{stringResourceName} + * + * + * ## References: + * For more detailed usage, please refer lyricist documentation @ + * https://github.com/adrielcafe/lyricist/ + * https://github.com/adrielcafe/lyricist/tree/main/sample-multiplatform/src/commonMain/kotlin/cafe/adriel/lyricist/sample/multiplatform (sample project) + */ object Locales { const val EN = "en" const val FR = "fr" -} \ No newline at end of file +}