Skip to content

Commit

Permalink
Merge pull request #443 from sora-xor/mwr-911
Browse files Browse the repository at this point in the history
Mwr 911
  • Loading branch information
arvifox authored Oct 30, 2024
2 parents 2ab4a95 + ffbe2de commit d5ac6d4
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 37 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ kotlin {
jvmToolchain(17)
}

// soralution 141 3.8.6.1 2024.10.29
// soralution 142 3.8.6.2 2024.10.30
// sora dae 118 3.8.5.3 2024.10.23

android {
Expand All @@ -30,8 +30,8 @@ android {
applicationId = "jp.co.soramitsu.sora"
minSdk = 26
targetSdk = 34
versionCode = System.getenv("CI_BUILD_ID")?.toInt() ?: 141
versionName = "3.8.6.1"
versionCode = System.getenv("CI_BUILD_ID")?.toInt() ?: 142
versionName = "3.8.6.2"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
// resConfigs "en", "ru", "es", "fr", "de", "nb", "in", "tr", "ar"
Expand Down Expand Up @@ -172,7 +172,7 @@ play {
serviceAccountCredentials = file(System.getenv("CI_PLAY_KEY") ?: "../key/fake.json")
track = "internal"
releaseStatus = ReleaseStatus.DRAFT
releaseName = "3.8.6.1 - SORA Card Improvements"
releaseName = "3.8.6.2 - SORA Card Improvements"
defaultToAppBundles = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ fun BasicBannerCard(
title: String,
description: String,
button: String,
buttonEnabled: Boolean = true,
onButtonClicked: () -> Unit,
closeEnabled: Boolean,
onCloseCard: () -> Unit,
) {
ContentCard(
modifier = Modifier.fillMaxWidth(),
onClick = onButtonClicked,
onClick = if (buttonEnabled) onButtonClicked else null,
) {
Box(
modifier = Modifier
Expand All @@ -103,6 +104,7 @@ fun BasicBannerCard(
description = description,
button = button,
onStartClicked = onButtonClicked,
buttonEnabled = buttonEnabled,
)

Image(
Expand Down Expand Up @@ -144,6 +146,7 @@ private fun CardContent(
title: String,
description: String,
button: String,
buttonEnabled: Boolean,
onStartClicked: () -> Unit,
) {
Column(
Expand Down Expand Up @@ -174,6 +177,7 @@ private fun CardContent(
.padding(top = Dimens.x1_5),
text = button,
size = Size.ExtraSmall,
enabled = buttonEnabled,
order = Order.PRIMARY,
onClick = onStartClicked,
)
Expand All @@ -188,6 +192,7 @@ private fun PreviewBasicBannerCard1() {
title = "Some title of banner card, let it be longeeerr",
description = "Long description of banner card, The quick brown fox jumps over the lazy dog, The quick brown fox jumps over the lazy dog.And I, even I Artaxerxes the king, do make a decree to all the treasurers which are beyond the river, that whatsoever Ezra the priest, the scribe of the law of the God of heaven, shall require of you, it be done speedily",
button = "Just button title",
buttonEnabled = true,
closeEnabled = true,
onCloseCard = {},
onButtonClicked = {},
Expand All @@ -202,6 +207,7 @@ private fun PreviewBasicBannerCard12() {
title = "Some title",
description = "Long description of banner",
button = "Just button title",
buttonEnabled = true,
closeEnabled = false,
onCloseCard = {},
onButtonClicked = {},
Expand All @@ -216,6 +222,7 @@ private fun PreviewBasicBannerCard2() {
title = "Title",
description = "Description",
button = "Button",
buttonEnabled = true,
closeEnabled = true,
onCloseCard = {},
onButtonClicked = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ data class SoraCardState(
override val loading: Boolean,
) : BasicBannerCardState(loading)

data object BuyXorState : BasicBannerCardState(false)
data class BuyXorState(val canStartGatehub: Boolean) : BasicBannerCardState(false)

data object ReferralState : BasicBannerCardState(false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class AssetDetailsViewModel @AssistedInject constructor(
null
},
isTransferableBalanceAvailable = asset.balance.transferable > BigDecimal.ZERO,
buyCryptoAvailable = soraCard && (asset.token.id == SubstrateOptionsProvider.feeAssetId),
buyCryptoAvailable = soraCard && (asset.token.id == SubstrateOptionsProvider.feeAssetId) && soraCardInteractor.basicStatus.value.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding(),
)
)
}
Expand Down Expand Up @@ -319,7 +319,6 @@ class AssetDetailsViewModel @AssistedInject constructor(
}

fun onBuyCrypto() {
if (soraCardInteractor.basicStatus.value.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding())
_launchSoraCardSignIn.value = createSoraCardGateHubContract()
_launchSoraCardSignIn.value = createSoraCardGateHubContract()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,17 @@ internal fun ProfileItems(
icon = R.drawable.ic_buy_crypto,
onClick = onSoraCardClick,
)
CategoryItem(
modifier = Modifier
.testTagAsId("BuyXor")
.padding(top = Dimens.x2),
title = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_title),
subtitle = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_subtitle),
icon = R.drawable.ic_settings_buy_crypto,
onClick = onBuyCrypto,
)
if (state.canStartGatehubOnboarding) {
CategoryItem(
modifier = Modifier
.testTagAsId("BuyXor")
.padding(top = Dimens.x2),
title = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_title),
subtitle = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_subtitle),
icon = R.drawable.ic_settings_buy_crypto,
onClick = onBuyCrypto,
)
}
}
CategoryItem(
modifier = Modifier
Expand Down Expand Up @@ -179,6 +181,7 @@ private fun PreviewProfile() {
soraCardStatusStringRes = R.string.more_menu_sora_card_subtitle,
soraCardStatusIconDrawableRes = R.drawable.ic_connection_indicator_green,
soraCardIbanError = null,
canStartGatehubOnboarding = true,
),
onAccountsClick = { },
onSoraCardClick = { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ internal data class ProfileScreenState(
val soraCardStatusStringRes: Int,
val soraCardIbanError: String?,
val soraCardStatusIconDrawableRes: Int?,
val canStartGatehubOnboarding: Boolean,
)

internal val initialProfileScreenState =
Expand All @@ -56,4 +57,5 @@ internal val initialProfileScreenState =
soraCardStatusIconDrawableRes = null,
soraCardNeedUpdate = false,
soraCardIbanError = null,
canStartGatehubOnboarding = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class ProfileViewModel @Inject constructor(
soraCardStatusIconDrawableRes = soraCardStatusIconDrawableRes,
soraCardEnabled = soraConfigManager.getSoraCard(),
soraCardNeedUpdate = it.needInstallUpdate,
canStartGatehubOnboarding = it.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding(),
)
}
.launchIn(viewModelScope)
Expand Down Expand Up @@ -201,9 +202,7 @@ class ProfileViewModel @Inject constructor(
}

fun showBuyCrypto() {
if (soraCardInteractor.basicStatus.value.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding()) {
_launchSoraCardSignIn.value = createSoraCardGateHubContract()
}
_launchSoraCardSignIn.value = createSoraCardGateHubContract()
}

fun showSelectNode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ private fun PreviewSoraCardDetailsScreen() {
balance = "3665.50",
phone = "987654",
soraCardMenuActions = SoraCardMenuAction.entries,
canStartGatehubFlow = true,
),
soraCardReferralBannerCardState = true,
soraCardRecentActivitiesCardState = SoraCardRecentActivitiesCardState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class SoraCardDetailsViewModel @Inject constructor(
balance = null,
phone = null,
soraCardMenuActions = SoraCardMenuAction.entries,
canStartGatehubFlow = false,
),
soraCardSettingsCard = SoraCardSettingsCardState(
soraCardSettingsOptions = SoraCardSettingsOption.entries,
Expand Down Expand Up @@ -116,10 +117,11 @@ class SoraCardDetailsViewModel @Inject constructor(
soraCardMainSoraContentCardState = local.soraCardMainSoraContentCardState.copy(
balance = basicStatus.ibanInfo?.balance,
phone = phoneFormatted,
canStartGatehubFlow = basicStatus.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding(),
),
soraCardSettingsCard = local.soraCardSettingsCard?.copy(
phone = phoneFormatted.orEmpty(),
)
),
)
}
}
Expand Down Expand Up @@ -165,10 +167,11 @@ class SoraCardDetailsViewModel @Inject constructor(
}
}

/**
* only clickable if IBAN is issued
*/
fun onExchangeXorClick() {
if (soraCardInteractor.basicStatus.value.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding()) {
_launchSoraCard.value = createSoraCardGateHubContract()
}
_launchSoraCard.value = createSoraCardGateHubContract()
}

fun onSettingsOptionClick(position: Int, context: Context?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ data class SoraCardMainSoraContentCardState(
val phone: String?,
val actionsEnabled: Boolean = false,
val soraCardMenuActions: List<SoraCardMenuAction>,
val canStartGatehubFlow: Boolean,
) {

val menuState: List<IconButtonMenuState>
Expand Down Expand Up @@ -180,7 +181,7 @@ fun SoraCardMainSoraContentCard(
.padding(horizontal = Dimens.x1)
.weight(1f),
size = Size.Large,
enabled = true,
enabled = soraCardMainSoraContentCardState.canStartGatehubFlow,
order = Order.PRIMARY,
onClick = onExchangeXor,
text = stringResource(id = jp.co.soramitsu.oauth.R.string.exchange_xor),
Expand All @@ -206,7 +207,8 @@ private fun PreviewMainSoraContentCard() {
soraCardMainSoraContentCardState = SoraCardMainSoraContentCardState(
balance = "3644.50",
phone = "",
soraCardMenuActions = SoraCardMenuAction.entries
soraCardMenuActions = SoraCardMenuAction.entries,
canStartGatehubFlow = true,
),
onShowMoreClick = {},
onIconButtonClick = { _ -> },
Expand All @@ -222,7 +224,8 @@ private fun PreviewMainSoraContentCard2() {
soraCardMainSoraContentCardState = SoraCardMainSoraContentCardState(
balance = "3644.50",
phone = "",
soraCardMenuActions = SoraCardMenuAction.entries
soraCardMenuActions = SoraCardMenuAction.entries,
canStartGatehubFlow = true,
),
onShowMoreClick = {},
onIconButtonClick = { _ -> },
Expand All @@ -238,7 +241,8 @@ private fun PreviewMainSoraContentCard3() {
soraCardMainSoraContentCardState = SoraCardMainSoraContentCardState(
balance = null,
phone = "",
soraCardMenuActions = SoraCardMenuAction.entries
soraCardMenuActions = SoraCardMenuAction.entries,
canStartGatehubFlow = true,
),
onShowMoreClick = {},
onIconButtonClick = { _ -> },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import jp.co.soramitsu.common.presentation.compose.theme.SoraAppTheme

@Composable
fun BuyXorCard(
buttonEnabled: Boolean,
onCloseCard: () -> Unit,
onBuyXorClicked: () -> Unit,
) {
Expand All @@ -50,6 +51,7 @@ fun BuyXorCard(
title = stringResource(id = R.string.buy_crypto_buy_xor_banner_title),
description = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_subtitle),
button = stringResource(id = R.string.common_buy_xor),
buttonEnabled = buttonEnabled,
closeEnabled = true,
onButtonClicked = onBuyXorClicked,
onCloseCard = onCloseCard,
Expand All @@ -61,6 +63,7 @@ fun BuyXorCard(
private fun PreviewBuyXorCard01() {
SoraAppTheme {
BuyXorCard(
buttonEnabled = true,
onCloseCard = {},
onBuyXorClicked = {},
)
Expand All @@ -72,6 +75,7 @@ private fun PreviewBuyXorCard01() {
private fun PreviewBuyXorCard02() {
SoraAppTheme {
BuyXorCard(
buttonEnabled = true,
onCloseCard = {},
onBuyXorClicked = {},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ private fun CardsMainScreen(
onStartClicked = onBackupBannerClick,
)
}
BuyXorState -> {
is BuyXorState -> {
BuyXorCard(
buttonEnabled = cardState.canStartGatehub,
onBuyXorClicked = onBuyXorClick,
onCloseCard = onBuyXorClose,
)
Expand Down Expand Up @@ -260,7 +261,7 @@ private fun PreviewCardsMainScreen() {
accountAddress = "",
loading = true,
cards = listOf(
BuyXorState, ReferralState, BackupWalletState,
BuyXorState(true), ReferralState, BackupWalletState,
),
),
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import jp.co.soramitsu.feature_main_api.launcher.MainRouter
import jp.co.soramitsu.feature_polkaswap_api.domain.interfaces.PoolsInteractor
import jp.co.soramitsu.feature_polkaswap_api.launcher.PolkaswapRouter
import jp.co.soramitsu.feature_referral_api.ReferralRouter
import jp.co.soramitsu.feature_sora_card_api.domain.SoraCardBasicStatus
import jp.co.soramitsu.feature_sora_card_api.domain.SoraCardInteractor
import jp.co.soramitsu.feature_sora_card_api.util.createSoraCardContract
import jp.co.soramitsu.feature_sora_card_api.util.createSoraCardGateHubContract
Expand Down Expand Up @@ -218,9 +219,13 @@ class CardsHubViewModel @Inject constructor(
}

CardHubType.BUY_XOR_TOKEN -> {
flowOf(
cardHub to BuyXorState
)
soraCardInteractor.basicStatus
.map { soraCardBasicStatus: SoraCardBasicStatus ->
cardHub to BuyXorState(soraCardBasicStatus.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding())
}
.onStart {
cardHub to BuyXorState(false)
}
}
}
}
Expand Down Expand Up @@ -454,9 +459,7 @@ class CardsHubViewModel @Inject constructor(
if (!connectionManager.isConnected) return
if (soraCardInteractor.basicStatus.value.initialized) {
_state.value.cards.filterIsInstance<SoraCardState>().firstOrNull()?.let { card ->
if (card.ibanBalance?.ibanStatus.readyToStartGatehubOnboarding()) {
_launchSoraCardSignIn.value = createSoraCardGateHubContract()
}
_launchSoraCardSignIn.value = createSoraCardGateHubContract()
}
}
}
Expand Down

0 comments on commit d5ac6d4

Please sign in to comment.