Updated on 2026-08-14
This commit is contained in:
parent
eef7bac933
commit
fc173d3a1f
18 changed files with 190 additions and 7 deletions
|
|
@ -32,6 +32,7 @@ dependencies {
|
|||
implementation(projects.domain.settings)
|
||||
implementation(projects.domain.tokens)
|
||||
implementation(projects.domain.txhistory)
|
||||
implementation(projects.domain.appCurrency)
|
||||
|
||||
implementation(project(":common"))
|
||||
implementation(project(":core:analytics"))
|
||||
|
|
@ -51,6 +52,7 @@ dependencies {
|
|||
implementation(projects.data.settings)
|
||||
implementation(projects.data.tokens)
|
||||
implementation(projects.data.txhistory)
|
||||
implementation(projects.data.appCurrency)
|
||||
|
||||
/** Features */
|
||||
implementation(project(":features:onboarding"))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package com.tangem.tap.di.domain
|
||||
|
||||
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
||||
import com.tangem.domain.appcurrency.repository.AppCurrencyRepository
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.components.ViewModelComponent
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
|
||||
@Module
|
||||
@InstallIn(ViewModelComponent::class)
|
||||
internal object AppCurrencyDomainModule {
|
||||
|
||||
@Provides
|
||||
@ViewModelScoped
|
||||
fun provideGetSelectedAppCurrencyUseCase(
|
||||
appCurrencyRepository: AppCurrencyRepository,
|
||||
): GetSelectedAppCurrencyUseCase {
|
||||
return GetSelectedAppCurrencyUseCase(appCurrencyRepository)
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,6 @@ dependencies {
|
|||
/** Project */
|
||||
implementation(projects.core.utils)
|
||||
implementation(projects.libs.auth)
|
||||
implementation(projects.domain.core)
|
||||
implementation(projects.domain.tokens.models)
|
||||
implementation(projects.domain.wallets.models)
|
||||
|
||||
|
|
|
|||
1
data/app-currency/.gitignore
vendored
Normal file
1
data/app-currency/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
33
data/app-currency/build.gradle.kts
Normal file
33
data/app-currency/build.gradle.kts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
plugins {
|
||||
alias(deps.plugins.android.library)
|
||||
alias(deps.plugins.kotlin.android)
|
||||
alias(deps.plugins.kotlin.kapt)
|
||||
id("configuration")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.tangem.data.appcurrency"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
/** Project - Domain */
|
||||
implementation(projects.domain.core)
|
||||
implementation(projects.domain.appCurrency)
|
||||
implementation(projects.domain.appCurrency.models)
|
||||
|
||||
/** Project - Data */
|
||||
implementation(projects.core.datasource)
|
||||
implementation(projects.data.common)
|
||||
|
||||
/** Project - Utils */
|
||||
implementation(projects.core.utils)
|
||||
|
||||
/** DI */
|
||||
implementation(deps.hilt.core)
|
||||
kapt(deps.hilt.kapt)
|
||||
|
||||
/** Other */
|
||||
implementation(deps.kotlin.coroutines)
|
||||
implementation(deps.timber)
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.tangem.data.appcurrency
|
||||
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.appcurrency.repository.AppCurrencyRepository
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
|
||||
internal class MockAppCurrencyRepository : AppCurrencyRepository {
|
||||
|
||||
private val mockAppCurrencies = listOf(AppCurrency(code = "USD", name = "US Dollar", symbol = "$"))
|
||||
|
||||
override fun getSelectedAppCurrency(): Flow<AppCurrency> {
|
||||
return flowOf(mockAppCurrencies.first())
|
||||
}
|
||||
|
||||
override suspend fun getAvailableAppCurrencies(): List<AppCurrency> {
|
||||
return mockAppCurrencies
|
||||
}
|
||||
|
||||
override suspend fun changeAppCurrency(appCurrency: AppCurrency) {
|
||||
/* no-op */
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.data.appcurrency.di
|
||||
|
||||
import com.tangem.data.appcurrency.MockAppCurrencyRepository
|
||||
import com.tangem.domain.appcurrency.repository.AppCurrencyRepository
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal object AppCurrencyDataModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAppCurrencyRepository(): AppCurrencyRepository {
|
||||
return MockAppCurrencyRepository()
|
||||
}
|
||||
}
|
||||
|
|
@ -13,10 +13,10 @@ dependencies {
|
|||
|
||||
/** Project - Domain */
|
||||
implementation(projects.domain.core)
|
||||
implementation(projects.domain.demo)
|
||||
implementation(projects.domain.models)
|
||||
implementation(projects.domain.tokens)
|
||||
implementation(projects.domain.tokens.models)
|
||||
implementation(projects.domain.demo)
|
||||
implementation(projects.domain.wallets.models)
|
||||
|
||||
/** Project - Data */
|
||||
|
|
@ -37,7 +37,6 @@ dependencies {
|
|||
|
||||
/** Other */
|
||||
implementation(deps.kotlin.coroutines)
|
||||
implementation(deps.arrow.core)
|
||||
implementation(deps.moshi.kotlin)
|
||||
implementation(deps.jodatime)
|
||||
implementation(deps.timber)
|
||||
|
|
|
|||
1
domain/app-currency/.gitignore
vendored
Normal file
1
domain/app-currency/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
12
domain/app-currency/build.gradle.kts
Normal file
12
domain/app-currency/build.gradle.kts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
plugins {
|
||||
alias(deps.plugins.kotlin.jvm)
|
||||
id("configuration")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
/** Project - Domain */
|
||||
implementation(projects.core.utils)
|
||||
implementation(projects.domain.core)
|
||||
implementation(projects.domain.appCurrency.models)
|
||||
}
|
||||
1
domain/app-currency/models/.gitignore
vendored
Normal file
1
domain/app-currency/models/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
4
domain/app-currency/models/build.gradle.kts
Normal file
4
domain/app-currency/models/build.gradle.kts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
plugins {
|
||||
alias(deps.plugins.kotlin.jvm)
|
||||
id("configuration")
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.tangem.domain.appcurrency.model
|
||||
|
||||
data class AppCurrency(
|
||||
val code: String,
|
||||
val name: String,
|
||||
val symbol: String,
|
||||
) {
|
||||
|
||||
companion object {
|
||||
val Default = AppCurrency(
|
||||
code = "USD",
|
||||
name = "US Dollar",
|
||||
symbol = "$",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.tangem.domain.appcurrency
|
||||
|
||||
import arrow.core.Either
|
||||
import arrow.core.left
|
||||
import arrow.core.right
|
||||
import com.tangem.domain.appcurrency.error.SelectedAppCurrencyError
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.appcurrency.repository.AppCurrencyRepository
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEmpty
|
||||
|
||||
class GetSelectedAppCurrencyUseCase(
|
||||
private val appCurrencyRepository: AppCurrencyRepository,
|
||||
) {
|
||||
|
||||
operator fun invoke(): Flow<Either<SelectedAppCurrencyError, AppCurrency>> {
|
||||
return appCurrencyRepository.getSelectedAppCurrency()
|
||||
.map<AppCurrency, Either<SelectedAppCurrencyError, AppCurrency>> { it.right() }
|
||||
.catch { emit(SelectedAppCurrencyError.DataError(it).left()) }
|
||||
.onEmpty { emit(SelectedAppCurrencyError.NoAppCurrencySelected.left()) }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.tangem.domain.appcurrency.error
|
||||
|
||||
sealed class SelectedAppCurrencyError {
|
||||
|
||||
object NoAppCurrencySelected : SelectedAppCurrencyError()
|
||||
|
||||
data class DataError(val cause: Throwable) : SelectedAppCurrencyError()
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.tangem.domain.appcurrency.repository
|
||||
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface AppCurrencyRepository {
|
||||
|
||||
fun getSelectedAppCurrency(): Flow<AppCurrency>
|
||||
|
||||
suspend fun getAvailableAppCurrencies(): List<AppCurrency>
|
||||
|
||||
suspend fun changeAppCurrency(appCurrency: AppCurrency)
|
||||
}
|
||||
|
|
@ -20,12 +20,14 @@ internal fun BaseExtension.configureCompilerOptions() {
|
|||
internal fun BaseExtension.configureCompose(project: Project) {
|
||||
val useCompose = with(project.path) {
|
||||
contains(":ui") ||
|
||||
contains(":onboarding") || // TODO: divide on api/impl after migrating all onboarding to module
|
||||
contains(":presentation") ||
|
||||
contains(":app") || // TODO: [REDACTED_JIRA]
|
||||
contains(":impl")
|
||||
contains(Regex(pattern = ":onboarding\$")) || // TODO: divide on api/impl after migrating all onboarding to module
|
||||
contains(Regex(pattern = ":presentation\$")) ||
|
||||
contains(Regex(pattern = ":app\$")) || // TODO: [REDACTED_JIRA]
|
||||
contains(Regex(pattern = ":impl\$"))
|
||||
}
|
||||
|
||||
buildFeatures.compose = useCompose
|
||||
|
||||
if (useCompose) {
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = project.findVersion(alias = "compose-compiler").requiredVersion
|
||||
|
|
|
|||
|
|
@ -108,6 +108,8 @@ include(":domain:wallets")
|
|||
include(":domain:wallets:models")
|
||||
include(":domain:txhistory")
|
||||
include(":domain:txhistory:models")
|
||||
include(":domain:app-currency")
|
||||
include(":domain:app-currency:models")
|
||||
// endregion Domain modules
|
||||
|
||||
// region Data modules
|
||||
|
|
@ -117,4 +119,5 @@ include(":data:tokens")
|
|||
include(":data:source:preferences")
|
||||
include(":data:settings")
|
||||
include(":data:txhistory")
|
||||
include(":data:app-currency")
|
||||
// endregion Data modules
|
||||
Loading…
Add table
Add a link
Reference in a new issue