Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add finalizing account state for account creation
Browse files Browse the repository at this point in the history
zaiatsartem committed Dec 12, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 6c78b30 commit a894670
Showing 7 changed files with 55 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -105,6 +105,9 @@ class AccountsOverviewViewModel(application: Application) : AndroidViewModel(app
App.appCore.session.setAccountsBackedUp(false)
}
}
viewModelScope.launch {
postState(OnboardingState.DONE)
}
}

override fun onError(stringRes: Int) {
@@ -185,10 +188,7 @@ class AccountsOverviewViewModel(application: Application) : AndroidViewModel(app
_identityFlow.emit(identity)
postState(OnboardingState.CREATE_ACCOUNT, zeroAccountBalances, notifyWaitingLiveData)
} else {
App.appCore.session.hasCompletedOnboarding()
postState(OnboardingState.DONE, notifyWaitingLiveData = notifyWaitingLiveData)
showSingleDialogIfNeeded()
updateSubmissionStatesAndBalances()
handleAccountCreation(notifyWaitingLiveData)
}
}

@@ -204,6 +204,18 @@ class AccountsOverviewViewModel(application: Application) : AndroidViewModel(app
}
}

private suspend fun handleAccountCreation(notifyWaitingLiveData: Boolean) {
val allAccounts = accountRepository.getAll()
if (allAccounts.isNotEmpty() && allAccounts.any { it.transactionStatus == TransactionStatus.FINALIZED }) {
App.appCore.session.hasCompletedOnboarding()
postState(OnboardingState.DONE, notifyWaitingLiveData = notifyWaitingLiveData)
showSingleDialogIfNeeded()
} else {
postState(OnboardingState.FINALIZING_ACCOUNT, notifyWaitingLiveData = notifyWaitingLiveData)
}
updateSubmissionStatesAndBalances()
}

private fun updateSubmissionStatesAndBalances(notifyWaitingLiveData: Boolean = true) {
if (notifyWaitingLiveData) {
_waitingLiveData.postValue(true)
Original file line number Diff line number Diff line change
@@ -82,6 +82,22 @@ class OnboardingDataProvider(val context: Context) {
showInnerActionButton = true,
innerActionButtonTitle = context.getString(R.string.accounts_overview_create_account),
innerActionButtonBackground = R.drawable.ccx_button_primary_green_background
),
OnboardingStateModel(
state = OnboardingState.FINALIZING_ACCOUNT,
statusTitle = context.getString(R.string.onboarding_finalizing_account),
statusTextColor = context.getColor(R.color.cryptox_green_main),
statusDescription = "",
verificationStatusIcon = context.getDrawable(R.drawable.ccx_finalizing_account),
showVerificationStatusIcon = true,
identityVerificationStatus = IdentityStatus.DONE,
animateStatusIcon = true,
showProgressBar = false,
showActionButton = false,
actionButtonTitle = "",
showInnerActionButton = true,
innerActionButtonTitle = context.getString(R.string.accounts_overview_create_account),
innerActionButtonBackground = R.drawable.ccx_button_primary_green_inactive_background
)
)

Original file line number Diff line number Diff line change
@@ -142,6 +142,10 @@ class OnboardingFragment @JvmOverloads constructor(
}
}

OnboardingState.FINALIZING_ACCOUNT -> {
binding.onboardingInnerActionButton.setOnClickListener(null)
}

else -> {}
}
}
Original file line number Diff line number Diff line change
@@ -6,5 +6,6 @@ enum class OnboardingState {
IDENTITY_IN_PROGRESS,
IDENTITY_UNSUCCESSFUL,
CREATE_ACCOUNT,
FINALIZING_ACCOUNT,
DONE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#067258" />
<corners android:radius="28dp" />
<stroke
android:width="1dp"
android:color="#1A0C0E11" />
</shape>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ccx_finalizing_account.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="11dp"
android:height="12dp"
android:viewportWidth="11"
android:viewportHeight="12">
<path
android:pathData="M11,6C11,9.038 8.538,11.5 5.5,11.5C2.462,11.5 0,9.038 0,6C0,2.962 2.462,0.5 5.5,0.5C8.538,0.5 11,2.962 11,6Z"
android:fillColor="#09CFA0"/>
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1181,5 +1181,6 @@
<string name="onboarding_identity_verification_in_progress">Verification in progress</string>
<string name="onboarding_identity_verification_completed">Verification completed</string>
<string name="onboarding_identity_verification_unsuccessful">Verification unsuccessful</string>
<string name="onboarding_finalizing_account">Finalizing account</string>
<string name="onboarding_identity_verification_status_icon">Identity verification status icon</string>
</resources>

0 comments on commit a894670

Please sign in to comment.