Updated on 2026-08-14
This commit is contained in:
parent
22141e15d8
commit
c4f743745c
6 changed files with 25 additions and 9 deletions
|
|
@ -33,7 +33,7 @@ internal class DefaultLearn2earnInteractor(
|
|||
private val webViewUriBuilder: WebViewUriBuilder by lazy {
|
||||
WebViewUriBuilder(
|
||||
authCredentialsProvider = dependencyProvider.getWebViewAuthCredentialsProvider(),
|
||||
userCountryCodeProvider = dependencyProvider.getLocaleProvider(),
|
||||
localeLanguageProvider = dependencyProvider.getLocaleProvider(),
|
||||
promoCodeProvider = { repository.getUserData().promoCode },
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.tangem.feature.learn2earn.impl.BuildConfig
|
|||
*/
|
||||
internal class WebViewUriBuilder(
|
||||
private val authCredentialsProvider: () -> String?,
|
||||
private val userCountryCodeProvider: () -> String,
|
||||
private val localeLanguageProvider: () -> String,
|
||||
private val promoCodeProvider: () -> String?,
|
||||
) {
|
||||
|
||||
|
|
@ -46,10 +46,19 @@ internal class WebViewUriBuilder(
|
|||
} else {
|
||||
authority(BASE_URL)
|
||||
}
|
||||
appendPath(userCountryCodeProvider.invoke())
|
||||
appendPath(getLocaleLanguage(localeLanguageProvider.invoke()))
|
||||
appendPath(PATH_PROMOTION)
|
||||
}
|
||||
|
||||
// TODO: locale: This can be used by another feature. Move it to the appropriate location
|
||||
private fun getLocaleLanguage(language: String): String {
|
||||
return if (LOCALE_LANG_RU.equals(language, true) || LOCALE_LANG_BY.equals(language, true)) {
|
||||
LOCALE_LANG_RU
|
||||
} else {
|
||||
LOCALE_LANG_EN
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val SCHEME = "https"
|
||||
|
||||
|
|
@ -60,5 +69,9 @@ internal class WebViewUriBuilder(
|
|||
const val QUERY_EXISTED_CARD = "existed-card"
|
||||
|
||||
const val DEV_BASE_URL = "devweb.tangem.com"
|
||||
|
||||
const val LOCALE_LANG_RU = "ru"
|
||||
const val LOCALE_LANG_BY = "by"
|
||||
const val LOCALE_LANG_EN = "en"
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,14 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.feature.learn2earn.analytics.AnalyticsParam
|
||||
import com.tangem.feature.learn2earn.analytics.Learn2earnEvents
|
||||
import com.tangem.feature.learn2earn.domain.api.Learn2earnInteractor
|
||||
import com.tangem.feature.learn2earn.domain.api.WebViewResult
|
||||
import com.tangem.feature.learn2earn.domain.api.WebViewResultHandler
|
||||
import com.tangem.feature.learn2earn.domain.models.PromotionError
|
||||
import com.tangem.feature.learn2earn.impl.R
|
||||
import com.tangem.feature.learn2earn.presentation.ui.state.*
|
||||
import com.tangem.lib.crypto.models.errors.UserCancelledException
|
||||
import com.tangem.utils.coroutines.AppCoroutineDispatcherProvider
|
||||
|
|
@ -191,7 +193,7 @@ class Learn2earnViewModel @Inject constructor(
|
|||
.updateGetBonusVisibility(isVisible = false)
|
||||
}
|
||||
MainScreenState.Dialog.Error(
|
||||
error = error,
|
||||
textReference = TextReference.Str(error.description),
|
||||
onOk = onHideDialog,
|
||||
onDismissRequest = onHideDialog,
|
||||
)
|
||||
|
|
@ -199,7 +201,7 @@ class Learn2earnViewModel @Inject constructor(
|
|||
is PromotionError.UnknownError, PromotionError.NetworkUnreachable -> {
|
||||
val onHideDialog = { uiState = uiState.hideDialog() }
|
||||
MainScreenState.Dialog.Error(
|
||||
error = error,
|
||||
textReference = TextReference.Res(R.string.common_server_unavailable),
|
||||
onOk = onHideDialog,
|
||||
onDismissRequest = onHideDialog,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import androidx.compose.material.Text
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.tangem.core.ui.components.TextButton
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.feature.learn2earn.impl.R
|
||||
import com.tangem.feature.learn2earn.presentation.ui.state.MainScreenState
|
||||
|
||||
|
|
@ -72,7 +73,7 @@ private fun ErrorDialog(dialog: MainScreenState.Dialog.Error) {
|
|||
Text(text = stringResource(id = R.string.common_error))
|
||||
},
|
||||
text = {
|
||||
Text(text = dialog.error.description)
|
||||
Text(text = dialog.textReference.resolveReference())
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.tangem.feature.learn2earn.presentation.ui.state
|
|||
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.WrappedList
|
||||
import com.tangem.feature.learn2earn.domain.models.PromotionError
|
||||
import com.tangem.feature.learn2earn.impl.R
|
||||
|
||||
/**
|
||||
|
|
@ -62,7 +61,7 @@ data class MainScreenState(
|
|||
) : Dialog()
|
||||
|
||||
data class Error(
|
||||
val error: PromotionError,
|
||||
val textReference: TextReference,
|
||||
val onOk: () -> Unit,
|
||||
val onDismissRequest: () -> Unit,
|
||||
) : Dialog()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class Learn2earnWebViewActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("TopLevelComposableFunctions")
|
||||
@Composable
|
||||
private fun ScreenContent(webViewData: WebViewData) {
|
||||
Column {
|
||||
|
|
@ -47,7 +48,7 @@ class Learn2earnWebViewActivity : AppCompatActivity() {
|
|||
WebView(
|
||||
state = rememberWebViewState(
|
||||
url = webViewData.uri.toString(),
|
||||
additionalHttpHeaders = webViewData.headers
|
||||
additionalHttpHeaders = webViewData.headers,
|
||||
),
|
||||
onCreated = {
|
||||
it.settings.apply {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue