Skip to content

Commit

Permalink
Add success screen for transaction execution submission (#1944)
Browse files Browse the repository at this point in the history
* Add success screen for transaction execution submission

* Adjust navigation
  • Loading branch information
elgatovital authored Jun 22, 2023
1 parent 5618217 commit b6329c0
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 21 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/io/gnosis/safe/Tracker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class Tracker internal constructor(
val TRANSACTION_EXEC_EDIT_FEE_FIELDS = "user_edit_exec_tx_fee_fields"
val TRANSACTION_EXEC_KEY_CHANGE = "user_select_exec_key_change"
val TRANSACTION_EXEC_FAILED = "user_exec_tx_failed"
val TRANSACTIONS_EXEC_SUBMITTED = "user_transaction_exec_submitted"
val BANNER_PASSCODE_SKIP = "user_banner_passcode_skip"
val BANNER_PASSCODE_CREATE = "user_banner_passcode_create"
val BANNER_OWNER_SKIP = "user_banner_owner_skip"
Expand Down Expand Up @@ -314,7 +315,7 @@ enum class ScreenId(val value: String) {
TRANSACTIONS_EXEC_REVIEW_ADVANCED("screen_exec_tx_review_advanced"),
TRANSACTIONS_EXEC_EDIT_FEE("screen_edit_exec_tx_fee"),
TRANSACTIONS_EXEC_SELECT_KEY("screen_select_exec_key"),
TRANSACTIONS_EXEC_SUBMITTED("screen_exec_tx_submitted"),
TRANSACTIONS_SUCCESS_SIGNER("screen_tx_signer_success"),
SETTINGS_APP("screen_settings_app"),
SETTINGS_APP_ADVANCED("screen_settings_app_advanced"),
SETTINGS_APP_APPEARANCE("screen_settings_app_appearance"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import io.gnosis.safe.ui.transactions.details.*
import io.gnosis.safe.ui.transactions.execution.TxAdvancedParamsFragment
import io.gnosis.safe.ui.transactions.execution.TxEditFee1559Fragment
import io.gnosis.safe.ui.transactions.execution.TxEditFeeLegacyFragment
import io.gnosis.safe.ui.transactions.execution.TxSuccessFragment
import io.gnosis.safe.ui.updates.UpdatesFragment
import io.gnosis.safe.ui.whatsnew.WhatsNewDialog

Expand Down Expand Up @@ -95,6 +96,8 @@ interface ViewComponent {

fun inject(fragment: ConfirmRejectionFragment)

fun inject(fragment: TxSuccessFragment)

fun inject(fragment: SettingsFragment)

fun inject(fragment: OwnerAddOptionsFragment)
Expand Down Expand Up @@ -151,7 +154,7 @@ interface ViewComponent {

fun inject(fragment: EditAdvancedParamsFragment)

fun inject(fragment: SuccessFragment)
fun inject(fragment: SendAssetSuccessFragment)

fun inject(fragment: AddOwnerFirstFragment)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class SendAssetReviewViewModel
updateState {
SendAssetReviewState(
ViewAction.NavigateTo(
SendAssetReviewFragmentDirections.actionSendAssetReviewFragmentToSuccessFragment(
SendAssetReviewFragmentDirections.actionSendAssetReviewFragmentToSendAssetSuccessFragment(
activeSafe.chain,
safeTxHash,
amountString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import io.gnosis.safe.R
import io.gnosis.safe.ScreenId
import io.gnosis.safe.databinding.FragmentSuccessBinding
import io.gnosis.safe.databinding.FragmentSendAssetSuccessBinding
import io.gnosis.safe.di.components.ViewComponent
import io.gnosis.safe.ui.base.fragment.BaseViewBindingFragment
import io.gnosis.safe.ui.transactions.TransactionsFragmentDirections
import io.gnosis.safe.ui.transactions.TxPagerAdapter

class SuccessFragment : BaseViewBindingFragment<FragmentSuccessBinding>() {
class SendAssetSuccessFragment : BaseViewBindingFragment<FragmentSendAssetSuccessBinding>() {

private val navArgs by navArgs<SuccessFragmentArgs>()
private val navArgs by navArgs<SendAssetSuccessFragmentArgs>()
private val chain by lazy { navArgs.chain }
private val txId by lazy { navArgs.txId }
private val amount by lazy { navArgs.amount }
Expand All @@ -32,8 +32,8 @@ class SuccessFragment : BaseViewBindingFragment<FragmentSuccessBinding>() {
override fun inflateBinding(
inflater: LayoutInflater,
container: ViewGroup?
): FragmentSuccessBinding =
FragmentSuccessBinding.inflate(inflater, container, false)
): FragmentSendAssetSuccessBinding =
FragmentSendAssetSuccessBinding.inflate(inflater, container, false)

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand All @@ -44,7 +44,7 @@ class SuccessFragment : BaseViewBindingFragment<FragmentSuccessBinding>() {
override fun handleOnBackPressed() {}
})
with(binding) {
description.text = getString(R.string.tx_submitted_desc, amount, token)
description.text = getString(R.string.tx_queued_desc, amount, token)
viewDetailsButton.setOnClickListener {
findNavController().popBackStack(R.id.assetsFragment, false)
with(findNavController()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.gnosis.safe.ui.transactions.execution

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.OnBackPressedCallback
import androidx.navigation.fragment.findNavController
import io.gnosis.safe.R
import io.gnosis.safe.ScreenId
import io.gnosis.safe.databinding.FragmentTxSuccessBinding
import io.gnosis.safe.di.components.ViewComponent
import io.gnosis.safe.ui.base.fragment.BaseViewBindingFragment

class TxSuccessFragment: BaseViewBindingFragment<FragmentTxSuccessBinding>() {

override fun screenId() = ScreenId.TRANSACTIONS_SUCCESS_SIGNER

override fun inject(component: ViewComponent) {
component.inject(this)
}

override fun inflateBinding(
inflater: LayoutInflater,
container: ViewGroup?
): FragmentTxSuccessBinding =
FragmentTxSuccessBinding.inflate(inflater, container, false)

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// disable default back navigation
requireActivity().onBackPressedDispatcher.addCallback(
viewLifecycleOwner,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {}
})
with(binding) {
doneButton.setOnClickListener {
findNavController().popBackStack(R.id.transactionDetailsFragment, false)
}
}
}

override fun onResume() {
super.onResume()
binding.lottieSuccess.playAnimation()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/tx_submitted"
android:text="@string/tx_queued"
android:textSize="17sp"
app:layout_constraintBottom_toTopOf="@+id/description"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -40,7 +40,7 @@
android:layout_marginTop="12dp"
android:layout_marginEnd="56dp"
android:gravity="center"
android:text="@string/tx_submitted_desc"
android:text="@string/tx_queued_desc"
android:textSize="17sp"
app:layout_constraintBottom_toTopOf="@+id/view_details_button"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -55,7 +55,7 @@
android:layout_marginStart="@dimen/default_margin"
android:layout_marginTop="24dp"
android:layout_marginEnd="@dimen/default_margin"
android:text="@string/tx_submitted_view_details"
android:text="@string/tx_queued_view_details"
app:layout_constraintBottom_toTopOf="@+id/done_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
65 changes: 65 additions & 0 deletions app/src/main/res/layout/fragment_tx_success.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie_success"
android:layout_width="112dp"
android:layout_height="112dp"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintBottom_toTopOf="@+id/title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_rawRes="@raw/success" />

<TextView
android:id="@+id/title"
style="@style/H6Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/tx_submitted"
android:textSize="17sp"
app:layout_constraintBottom_toTopOf="@+id/description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lottie_success"
app:layout_constraintVertical_chainStyle="packed" />

<TextView
android:id="@+id/description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="56dp"
android:gravity="center"
android:text="@string/tx_submitted_desc"
android:textSize="17sp"
app:layout_constraintBottom_toTopOf="@+id/done_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title"
app:layout_constraintVertical_chainStyle="packed" />

<Button
android:id="@+id/done_button"
style="@style/PrimaryButton"
android:layout_width="0dp"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginTop="24dp"
android:layout_marginEnd="@dimen/default_margin"
android:text="@string/tx_submitted_done"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/description"
app:layout_constraintVertical_chainStyle="packed" />

</androidx.constraintlayout.widget.ConstraintLayout>
21 changes: 15 additions & 6 deletions app/src/main/res/navigation/main_nav.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
app:destination="@id/signingOwnerSelectionFragment" />

<action
android:id="@+id/action_sendAssetReviewFragment_to_successFragment"
app:destination="@id/successFragment" />
android:id="@+id/action_sendAssetReviewFragment_to_sendAssetSuccessFragment"
app:destination="@id/sendAssetSuccessFragment" />

</fragment>

Expand Down Expand Up @@ -197,10 +197,10 @@
</fragment>

<fragment
android:id="@+id/successFragment"
android:name="io.gnosis.safe.ui.safe.send_funds.SuccessFragment"
android:label="SuccessFragment"
tools:layout="@layout/fragment_success">
android:id="@+id/sendAssetSuccessFragment"
android:name="io.gnosis.safe.ui.safe.send_funds.SendAssetSuccessFragment"
android:label="SendAssetSuccessFragment"
tools:layout="@layout/fragment_send_asset_success">

<argument
android:name="chain"
Expand Down Expand Up @@ -283,6 +283,7 @@
<action
android:id="@+id/action_ownerAddOptionsFragment_to_ownerInfoLedgerFragment"
app:destination="@id/ownerInfoLedgerFragment" />

</fragment>

<fragment
Expand Down Expand Up @@ -369,6 +370,7 @@
app:destination="@id/ownerEnterNameFragment" />

</fragment>

<fragment
android:id="@+id/ownerEnterNameFragment"
android:name="io.gnosis.safe.ui.settings.owner.OwnerEnterNameFragment"
Expand Down Expand Up @@ -553,6 +555,7 @@
<argument
android:name="passcodeCommand"
app:argType="io.gnosis.safe.ui.settings.app.passcode.PasscodeCommand" />

</fragment>

<fragment
Expand Down Expand Up @@ -1159,6 +1162,12 @@

</fragment>

<fragment
android:id="@+id/txSuccessFragment"
android:name="io.gnosis.safe.ui.transactions.execution.TxSuccessFragment"
android:label="TxSuccessFragment"
tools:layout="@layout/fragment_tx_success" />

<fragment
android:id="@+id/selectChainFragment"
android:name="io.gnosis.safe.ui.settings.chain.ChainSelectionFragment"
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,13 @@
<string name="tx_exec_estimated_fee_price">Total esimated fee: %1$s</string>
<string name="value_not_available">n/a</string>

<string name="tx_submitted">Your transaction is queued!</string>
<string name="tx_submitted_desc">Your request to send %1$s %2$s is submitted and needs to be confirmed by other owners.</string>
<string name="tx_submitted_view_details">View details</string>
<string name="tx_queued">Your transaction is queued!</string>
<string name="tx_queued_desc">Your request to send %1$s %2$s is submitted and needs to be confirmed by other owners.</string>
<string name="tx_queued_view_details">View details</string>
<string name="tx_queued_done">Done</string>

<string name="tx_submitted">Your transaction is submitted!</string>
<string name="tx_submitted_desc">It normally takes some time for a transaction to be executed.</string>
<string name="tx_submitted_done">Done</string>

<string name="tx_exec_edit_fee">Edit transaction fee</string>
Expand Down

0 comments on commit b6329c0

Please sign in to comment.