diff --git a/core/res/src/main/res/values-de/strings.xml b/core/res/src/main/res/values-de/strings.xml index 4313234fb9..198db71cec 100644 --- a/core/res/src/main/res/values-de/strings.xml +++ b/core/res/src/main/res/values-de/strings.xml @@ -774,6 +774,7 @@ Belohnungen Stake gesperrt Mehr staken + Gestakeder Betrag Du setzt %1$s ein und ethältst Deine Belohnung %2$s Zum Entsperren antippen Tippe zum Entsperren oder Abstimmen diff --git a/core/res/src/main/res/values-es/strings.xml b/core/res/src/main/res/values-es/strings.xml index a8fc4365c8..3dc04b55bb 100644 --- a/core/res/src/main/res/values-es/strings.xml +++ b/core/res/src/main/res/values-es/strings.xml @@ -856,6 +856,7 @@ desde: %s a: %s validador: %s + El monto mínimo para realizar esta transacción es %1$s. Inténtelo de nuevo Ha escaneado la misma tarjeta. Para crear una billetera gemela, necesite escanear la tarjeta con no. %d Ha escaneado la tarjeta gemela incorrecta. Por favor, intente con otra diff --git a/core/res/src/main/res/values-fr/strings.xml b/core/res/src/main/res/values-fr/strings.xml index 42eb2abac8..2f534dd458 100644 --- a/core/res/src/main/res/values-fr/strings.xml +++ b/core/res/src/main/res/values-fr/strings.xml @@ -856,6 +856,7 @@ de : %s à : %s validateur : %s + Le montant minimum pour effectuer cette transaction est %1$s. Réessayez Vous avez scanné la même carte. Pour créer un portefeuille jumeau, vous devez scanner la carte portant le numéro %d Vous avez scanné une mauvaise carte jumelle. S\'il vous plaît, essayez-en un autre diff --git a/core/res/src/main/res/values-ja/strings.xml b/core/res/src/main/res/values-ja/strings.xml index 8cdaeffe4a..d64d288ba7 100644 --- a/core/res/src/main/res/values-ja/strings.xml +++ b/core/res/src/main/res/values-ja/strings.xml @@ -764,6 +764,7 @@ 報酬 ステーキングはロックされています もっとステーキングする + ステーキング中の金額 %1$sをステーキングし、報酬%2$sを受け取ります タップしてロック解除 タップしてロック解除もしくは投票 diff --git a/core/res/src/main/res/values-ru/strings.xml b/core/res/src/main/res/values-ru/strings.xml index c600ccc00e..50fe9580e5 100644 --- a/core/res/src/main/res/values-ru/strings.xml +++ b/core/res/src/main/res/values-ru/strings.xml @@ -714,6 +714,7 @@ Имя Сумма для стейкинга должна быть не менее %s Согласно правилам сети, сумма стейкинга будет округлена до %1$sTRX. + Сумма для вывода из стейкинга будет округлена до %1$s TRX ввиду особенностей сети. Забрать средства Комиссия за стейкинг аккаунт Стейкинг аккаунт — это специальный счет, на котором хранятся застейканные токены SOL. Он создается при делегировании ваших токенов валидатору для участия в подтверждении транзакций и получении наград. За создание стейкинг аккаунта взимается небольшая комиссия, которая возвращается после завершения стейкинга. @@ -756,6 +757,7 @@ Стейкинг дает возможность вам получать %1$s. Награда будет зачисляться каждую неделю. Стейкайте безопасно и начинайте получать еженедельные награды. Получите награду за стейкинг + Оставшийся застейканный баланс будет слишком мал для вывода. Вам потребуется застейкать больше средств, чтобы достичь минимальной суммы для вывода. Стейкинг временно недоступен из-за проблем в сети. Пожалуйста, попробуйте позже. Стейкинг в сети %1$s с новым валидатором автоматически переведет ваши текущие застейканные средства на него. Реинвестируйте свои заработанные награды в вашу застейканную сумму, увеличивая потенциальный доход @@ -798,7 +800,7 @@ Отзыв Разблокировать Разблокировка - Сумма для стейкинга должна быть не менее %s + Сумма для вывода из стейкинга должна быть не менее %s Сумма превышает застейканный баланс Вывод из стейкинга Завершение стейкинга @@ -874,6 +876,7 @@ от: %s на: %s валидатор: %s + Минимальная сумма транзакции равна %1$s. Попробовать снова Вы отсканировали ту же карту. Для создания twin-кошелька вам необходимо отсканировать карту с номером %d Вы отсканировали не ту twin-карту. Пожалуйста, попробуйте отсканировать другую diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index 3a507e68ab..1e4d43cba5 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -551,10 +551,16 @@ Access code restore Identical cards Access code + Search by country + Unavailable + Search by currency Pay with Our services are not available in this country Change or confirm it Your residence has been identified as + Residence + Please select the correct country to ensure accurate payment options and services. + Settings Via Group By balance @@ -741,6 +747,8 @@ Staking allows you to earn %1$s. Your staking rewards arrive every week. Stake securely and start earning weekly rewards Earn staking rewards + Your remaining staked balance will be too low to unstake. You’ll need to stake more to meet the minimum unstake amount. + Low staked balance Staking is currently unavailable due to network conditions. Please try again later. Staking in the %1$s network with a new validator will automatically transfer all previously staked funds to this validator Reinvests your earned rewards in your staked amount, increasing potential earnings. @@ -861,6 +869,7 @@ from: %s to: %s validator: %s + The minimum transaction amount is %1$s. Try again You\'ve scanned the same card. To create a twin wallet you need to scan the card with number %d You\'ve scanned wrong twin card. Please try another one diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/component/impl/DefaultOnrampComponent.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/component/impl/DefaultOnrampComponent.kt index 7ec0fb692a..1957c1def4 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/component/impl/DefaultOnrampComponent.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/component/impl/DefaultOnrampComponent.kt @@ -1,61 +1,62 @@ package com.tangem.features.onramp.component.impl -import androidx.activity.compose.BackHandler import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import com.arkivanov.decompose.ComponentContext +import com.arkivanov.decompose.extensions.compose.jetpack.stack.Children +import com.arkivanov.decompose.extensions.compose.jetpack.stack.animation.stackAnimation import com.arkivanov.decompose.extensions.compose.jetpack.subscribeAsState -import com.arkivanov.decompose.router.slot.childSlot -import com.arkivanov.decompose.router.slot.dismiss +import com.arkivanov.decompose.router.stack.StackNavigation +import com.arkivanov.decompose.router.stack.childStack import com.tangem.core.decompose.context.AppComponentContext import com.tangem.core.decompose.context.childByContext -import com.tangem.core.decompose.model.getOrCreateModel -import com.tangem.core.ui.decompose.ComposableBottomSheetComponent +import com.tangem.core.ui.decompose.ComposableContentComponent import com.tangem.features.onramp.component.OnrampComponent -import com.tangem.features.onramp.component.ConfirmResidencyComponent -import com.tangem.features.onramp.entity.OnrampBottomSheetConfig -import com.tangem.features.onramp.model.OnrampModel +import com.tangem.features.onramp.entity.OnrampChild +import com.tangem.features.onramp.settings.OnrampSettingsComponent import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject +@Suppress("UnusedPrivateMember") internal class DefaultOnrampComponent @AssistedInject constructor( @Assisted context: AppComponentContext, - @Assisted private val params: OnrampComponent.Params, - private val confirmResidencyComponentFactory: ConfirmResidencyComponent.Factory, + @Assisted params: OnrampComponent.Params, + private val settingsComponentFactory: OnrampSettingsComponent.Factory, ) : OnrampComponent, AppComponentContext by context { - private val model: OnrampModel = getOrCreateModel(params) - private val confirmResidencyBottomSheetSlot = childSlot( - source = model.bottomSheetNavigation, - serializer = null, + private val navigation = StackNavigation() + private val contentStack = childStack( + key = "onramp_content_stack", + source = navigation, + serializer = OnrampChild.serializer(), + initialConfiguration = OnrampChild.Settings, handleBackButton = false, - childFactory = ::bottomSheetChild, + childFactory = ::screenChild, ) @Composable override fun Content(modifier: Modifier) { - val bottomSheet by confirmResidencyBottomSheetSlot.subscribeAsState() - BackHandler(onBack = router::pop) + val childStack by contentStack.subscribeAsState() - bottomSheet.child?.instance?.BottomSheet() + Children( + stack = childStack, + animation = stackAnimation(), + ) { child -> + child.instance.Content(modifier = modifier) + } } - private fun bottomSheetChild( - config: OnrampBottomSheetConfig, - componentContext: ComponentContext, - ): ComposableBottomSheetComponent = when (config) { - OnrampBottomSheetConfig.ConfirmResidency -> confirmResidencyComponentFactory.create( - context = childByContext(componentContext), - params = ConfirmResidencyComponent.Params( - countryName = "United States", - isOnrampSupported = true, - countryFlagUrl = "https://hatscripts.github.io/circle-flags/flags/us.svg", - onDismiss = model.bottomSheetNavigation::dismiss, - ), - ) - } + private fun screenChild(config: OnrampChild, componentContext: ComponentContext): ComposableContentComponent = + when (config) { + OnrampChild.Settings -> settingsComponentFactory.create( + context = childByContext(componentContext), + // params = OnrampSettingsComponent.Params(navigation::pop) // todo uncomment after [REDACTED_JIRA] + params = OnrampSettingsComponent.Params(router::pop), + ) + OnrampChild.Main -> TODO("[REDACTED_JIRA]") + } @AssistedFactory interface Factory : OnrampComponent.Factory { diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/di/OnrampModelModule.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/di/OnrampModelModule.kt deleted file mode 100644 index 41f90f6d5a..0000000000 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/di/OnrampModelModule.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.tangem.features.onramp.di - -import com.tangem.core.decompose.di.DecomposeComponent -import com.tangem.core.decompose.model.Model -import com.tangem.features.onramp.model.OnrampModel -import com.tangem.features.onramp.model.ConfirmResidencyModel -import dagger.Binds -import dagger.Module -import dagger.hilt.InstallIn -import dagger.multibindings.ClassKey -import dagger.multibindings.IntoMap - -@Module -@InstallIn(DecomposeComponent::class) -internal interface OnrampModelModule { - - @Binds - @IntoMap - @ClassKey(OnrampModel::class) - fun provideOnrampModel(model: OnrampModel): Model - - @Binds - @IntoMap - @ClassKey(ConfirmResidencyModel::class) - fun provideConfirmResidencyModel(model: ConfirmResidencyModel): Model -} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/entity/OnrampBottomSheetConfig.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/entity/OnrampBottomSheetConfig.kt deleted file mode 100644 index 81289b4cdf..0000000000 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/entity/OnrampBottomSheetConfig.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.tangem.features.onramp.entity - -import kotlinx.serialization.Serializable - -@Serializable -internal sealed class OnrampBottomSheetConfig { - - @Serializable - data object ConfirmResidency : OnrampBottomSheetConfig() -} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/entity/OnrampChild.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/entity/OnrampChild.kt new file mode 100644 index 0000000000..e18f168bff --- /dev/null +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/entity/OnrampChild.kt @@ -0,0 +1,12 @@ +package com.tangem.features.onramp.entity + +import kotlinx.serialization.Serializable + +@Serializable +internal sealed class OnrampChild { + @Serializable + data object Main : OnrampChild() + + @Serializable + data object Settings : OnrampChild() +} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/model/OnrampModel.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/model/OnrampModel.kt deleted file mode 100644 index d1f35e1fca..0000000000 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/model/OnrampModel.kt +++ /dev/null @@ -1,38 +0,0 @@ -package com.tangem.features.onramp.model - -import com.arkivanov.decompose.router.slot.SlotNavigation -import com.arkivanov.decompose.router.slot.activate -import com.tangem.core.decompose.di.ComponentScoped -import com.tangem.core.decompose.model.Model -import com.tangem.core.decompose.model.ParamsContainer -import com.tangem.core.decompose.navigation.Router -import com.tangem.features.onramp.component.OnrampComponent -import com.tangem.features.onramp.entity.OnrampBottomSheetConfig -import com.tangem.utils.coroutines.CoroutineDispatcherProvider -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch -import javax.inject.Inject - -@Suppress("MagicNumber") -@ComponentScoped -internal class OnrampModel @Inject constructor( - override val dispatchers: CoroutineDispatcherProvider, - private val router: Router, - paramsContainer: ParamsContainer, -) : Model() { - - @Suppress("UnusedPrivateMember") - private val params: OnrampComponent.Params = paramsContainer.require() - val bottomSheetNavigation: SlotNavigation = SlotNavigation() - - init { - modelScope.launch { - delay(1500) - bottomSheetNavigation.activate(OnrampBottomSheetConfig.ConfirmResidency) - } - } - - fun pop() { - router.pop() - } -} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/SelectCountryComponent.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/SelectCountryComponent.kt index 8e089ec3d4..96a98be090 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/SelectCountryComponent.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/SelectCountryComponent.kt @@ -3,7 +3,7 @@ package com.tangem.features.onramp.selectcountry import com.tangem.core.decompose.factory.ComponentFactory import com.tangem.core.ui.decompose.ComposableBottomSheetComponent -interface SelectCountryComponent : ComposableBottomSheetComponent { +internal interface SelectCountryComponent : ComposableBottomSheetComponent { data class Params(val onDismiss: () -> Unit) diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/DefaultOnrampSettingsComponent.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/DefaultOnrampSettingsComponent.kt new file mode 100644 index 0000000000..2fff47ec00 --- /dev/null +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/DefaultOnrampSettingsComponent.kt @@ -0,0 +1,63 @@ +package com.tangem.features.onramp.settings + +import androidx.activity.compose.BackHandler +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Modifier +import com.arkivanov.decompose.ComponentContext +import com.arkivanov.decompose.extensions.compose.jetpack.subscribeAsState +import com.arkivanov.decompose.router.slot.childSlot +import com.arkivanov.decompose.router.slot.dismiss +import com.tangem.core.decompose.context.AppComponentContext +import com.tangem.core.decompose.context.childByContext +import com.tangem.core.decompose.model.getOrCreateModel +import com.tangem.core.ui.decompose.ComposableBottomSheetComponent +import com.tangem.features.onramp.selectcountry.SelectCountryComponent +import com.tangem.features.onramp.settings.entity.OnrampSettingsConfig +import com.tangem.features.onramp.settings.model.OnrampSettingsModel +import com.tangem.features.onramp.settings.ui.OnrampSettingsContent +import dagger.assisted.Assisted +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject + +internal class DefaultOnrampSettingsComponent @AssistedInject constructor( + @Assisted appComponentContext: AppComponentContext, + @Assisted private val params: OnrampSettingsComponent.Params, + private val selectCountryComponentFactory: SelectCountryComponent.Factory, +) : OnrampSettingsComponent, AppComponentContext by appComponentContext { + + private val model: OnrampSettingsModel = getOrCreateModel(params) + private val bottomSheetSlot = childSlot( + source = model.bottomSheetNavigation, + serializer = null, + handleBackButton = false, + childFactory = ::bottomSheetChild, + ) + + @Composable + override fun Content(modifier: Modifier) { + BackHandler(onBack = params.onBack) + OnrampSettingsContent(modifier = modifier, state = model.state) + + val bottomSheet by bottomSheetSlot.subscribeAsState() + bottomSheet.child?.instance?.BottomSheet() + } + + private fun bottomSheetChild( + config: OnrampSettingsConfig, + componentContext: ComponentContext, + ): ComposableBottomSheetComponent = when (config) { + OnrampSettingsConfig.SelectCountry -> selectCountryComponentFactory.create( + context = childByContext(componentContext), + params = SelectCountryComponent.Params(model.bottomSheetNavigation::dismiss), + ) + } + + @AssistedFactory + interface Factory : OnrampSettingsComponent.Factory { + override fun create( + context: AppComponentContext, + params: OnrampSettingsComponent.Params, + ): DefaultOnrampSettingsComponent + } +} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/OnrampSettingsComponent.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/OnrampSettingsComponent.kt new file mode 100644 index 0000000000..2514bbb00b --- /dev/null +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/OnrampSettingsComponent.kt @@ -0,0 +1,11 @@ +package com.tangem.features.onramp.settings + +import com.tangem.core.decompose.factory.ComponentFactory +import com.tangem.core.ui.decompose.ComposableContentComponent + +internal interface OnrampSettingsComponent : ComposableContentComponent { + + data class Params(val onBack: () -> Unit) + + interface Factory : ComponentFactory +} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/di/OnrampSettingsComponentModule.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/di/OnrampSettingsComponentModule.kt new file mode 100644 index 0000000000..648bf03301 --- /dev/null +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/di/OnrampSettingsComponentModule.kt @@ -0,0 +1,20 @@ +package com.tangem.features.onramp.settings.di + +import com.tangem.features.onramp.settings.DefaultOnrampSettingsComponent +import com.tangem.features.onramp.settings.OnrampSettingsComponent +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal interface OnrampSettingsComponentModule { + + @Binds + @Singleton + fun bindOnrampSettingsComponentFactory( + factory: DefaultOnrampSettingsComponent.Factory, + ): OnrampSettingsComponent.Factory +} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/di/OnrampSettingsModelModule.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/di/OnrampSettingsModelModule.kt new file mode 100644 index 0000000000..f62678e7ee --- /dev/null +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/di/OnrampSettingsModelModule.kt @@ -0,0 +1,20 @@ +package com.tangem.features.onramp.settings.di + +import com.tangem.core.decompose.di.DecomposeComponent +import com.tangem.core.decompose.model.Model +import com.tangem.features.onramp.settings.model.OnrampSettingsModel +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.multibindings.ClassKey +import dagger.multibindings.IntoMap + +@Module +@InstallIn(DecomposeComponent::class) +internal interface OnrampSettingsModelModule { + + @Binds + @IntoMap + @ClassKey(OnrampSettingsModel::class) + fun bindOnrampSettingsModelModel(model: OnrampSettingsModel): Model +} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/entity/OnrampSettingsConfig.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/entity/OnrampSettingsConfig.kt new file mode 100644 index 0000000000..11ba9a2f0b --- /dev/null +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/entity/OnrampSettingsConfig.kt @@ -0,0 +1,9 @@ +package com.tangem.features.onramp.settings.entity + +import kotlinx.serialization.Serializable + +@Serializable +sealed class OnrampSettingsConfig { + + data object SelectCountry : OnrampSettingsConfig() +} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/entity/OnrampSettingsItemUM.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/entity/OnrampSettingsItemUM.kt new file mode 100644 index 0000000000..f957739a26 --- /dev/null +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/entity/OnrampSettingsItemUM.kt @@ -0,0 +1,5 @@ +package com.tangem.features.onramp.settings.entity + +sealed class OnrampSettingsItemUM { + data class Residence(val countryName: String, val flagUrl: String, val onClick: () -> Unit) : OnrampSettingsItemUM() +} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/entity/OnrampSettingsUM.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/entity/OnrampSettingsUM.kt new file mode 100644 index 0000000000..0997eb67d1 --- /dev/null +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/entity/OnrampSettingsUM.kt @@ -0,0 +1,8 @@ +package com.tangem.features.onramp.settings.entity + +import kotlinx.collections.immutable.ImmutableList + +internal data class OnrampSettingsUM( + val onBack: () -> Unit, + val items: ImmutableList, +) \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/model/OnrampSettingsModel.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/model/OnrampSettingsModel.kt new file mode 100644 index 0000000000..edff4909ee --- /dev/null +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/model/OnrampSettingsModel.kt @@ -0,0 +1,34 @@ +package com.tangem.features.onramp.settings.model + +import com.arkivanov.decompose.router.slot.SlotNavigation +import com.arkivanov.decompose.router.slot.activate +import com.tangem.core.decompose.di.ComponentScoped +import com.tangem.core.decompose.model.Model +import com.tangem.core.decompose.model.ParamsContainer +import com.tangem.features.onramp.settings.OnrampSettingsComponent +import com.tangem.features.onramp.settings.entity.OnrampSettingsConfig +import com.tangem.features.onramp.settings.entity.OnrampSettingsItemUM +import com.tangem.features.onramp.settings.entity.OnrampSettingsUM +import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import kotlinx.collections.immutable.toImmutableList +import javax.inject.Inject + +@ComponentScoped +internal class OnrampSettingsModel @Inject constructor( + override val dispatchers: CoroutineDispatcherProvider, + paramsContainer: ParamsContainer, +) : Model() { + + private val params: OnrampSettingsComponent.Params = paramsContainer.require() + val bottomSheetNavigation: SlotNavigation = SlotNavigation() + val state = OnrampSettingsUM( + onBack = params.onBack, + items = listOf( + OnrampSettingsItemUM.Residence( + countryName = "United States of America", + flagUrl = "", + onClick = { bottomSheetNavigation.activate(OnrampSettingsConfig.SelectCountry) }, + ), + ).toImmutableList(), + ) +} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/ui/OnrampSettingsContent.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/ui/OnrampSettingsContent.kt new file mode 100644 index 0000000000..949a3af30e --- /dev/null +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/ui/OnrampSettingsContent.kt @@ -0,0 +1,111 @@ +package com.tangem.features.onramp.settings.ui + +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Icon +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.key +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.util.fastForEach +import coil.compose.AsyncImage +import com.tangem.core.ui.components.SpacerWMax +import com.tangem.core.ui.components.appbar.AppBarWithBackButton +import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.utils.WindowInsetsZero +import com.tangem.features.onramp.impl.R +import com.tangem.features.onramp.settings.entity.OnrampSettingsItemUM +import com.tangem.features.onramp.settings.entity.OnrampSettingsUM +import kotlinx.collections.immutable.ImmutableList + +@Composable +internal fun OnrampSettingsContent(state: OnrampSettingsUM, modifier: Modifier = Modifier) { + Scaffold( + modifier = modifier, + contentWindowInsets = WindowInsetsZero, + containerColor = TangemTheme.colors.background.secondary, + topBar = { + AppBarWithBackButton( + modifier = Modifier.statusBarsPadding(), + onBackClick = state.onBack, + text = stringResource(id = R.string.onramp_settings_title), + iconRes = R.drawable.ic_close_24, + ) + }, + content = { innerPadding -> + Content( + modifier = Modifier + .padding(innerPadding) + .fillMaxSize() + .padding(horizontal = TangemTheme.dimens.spacing16), + items = state.items, + ) + }, + ) +} + +@Composable +private fun Content(items: ImmutableList, modifier: Modifier = Modifier) { + Column(modifier = modifier) { + items.fastForEach { model -> + key(model) { + when (model) { + is OnrampSettingsItemUM.Residence -> ResidenceSection(model) + } + } + } + } +} + +@Composable +private fun ResidenceSection(state: OnrampSettingsItemUM.Residence, modifier: Modifier = Modifier) { + Column( + modifier = modifier, + verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8), + ) { + Row( + modifier = Modifier + .clip(RoundedCornerShape(TangemTheme.dimens.radius16)) + .background(TangemTheme.colors.background.primary) + .clickable(onClick = state.onClick) + .padding(TangemTheme.dimens.spacing12) + .fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8), + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = stringResource(id = R.string.onramp_settings_residence), + color = TangemTheme.colors.text.tertiary, + style = TangemTheme.typography.subtitle2, + ) + SpacerWMax() + AsyncImage( + modifier = Modifier.size(TangemTheme.dimens.size20), + model = state.flagUrl, + contentDescription = null, + ) + Text( + text = state.countryName, + color = TangemTheme.colors.text.primary1, + style = TangemTheme.typography.body2, + ) + Icon( + painter = painterResource(id = R.drawable.ic_chevron_right_24), + contentDescription = null, + tint = TangemTheme.colors.icon.informative, + ) + } + Text( + text = stringResource(id = R.string.onramp_settings_residence_description), + color = TangemTheme.colors.text.tertiary, + style = TangemTheme.typography.caption2, + ) + } +} \ No newline at end of file