Skip to content

Commit

Permalink
GH-2040 added tx type to the review screen
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryBespalov committed Jul 1, 2024
1 parent a9ba2a3 commit 434a7a0
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import io.gnosis.safe.ui.base.BaseStateViewModel.ViewAction.ShowError
import io.gnosis.safe.ui.base.SafeOverviewBaseFragment
import io.gnosis.safe.ui.base.fragment.BaseViewBindingFragment
import io.gnosis.safe.ui.settings.owner.details.OwnerDetailsFragment
import io.gnosis.safe.ui.transactions.details.view.ActionInfoItem
import io.gnosis.safe.ui.transactions.details.viewdata.TransactionInfoViewData
import io.gnosis.safe.utils.BalanceFormatter
import io.gnosis.safe.utils.ParamSerializer
Expand All @@ -40,6 +41,7 @@ import io.gnosis.safe.utils.setToCurrent
import io.gnosis.safe.utils.toColor
import io.gnosis.safe.utils.txActionInfoItems
import pm.gnosis.model.Solidity
import pm.gnosis.svalinn.common.utils.openUrl
import pm.gnosis.svalinn.common.utils.visible
import pm.gnosis.utils.asEthereumAddress
import java.math.BigDecimal
Expand Down Expand Up @@ -102,6 +104,9 @@ class TxReviewFragment : BaseViewBindingFragment<FragmentTxReviewBinding>() {
is TransactionInfoViewData.SettingsChange -> setupSettingsChangeUI(txInfo)
is TransactionInfoViewData.Custom -> setupCustomUI(txInfo)
is TransactionInfoViewData.Rejection -> setupRejectionUI(txInfo)
is TransactionInfoViewData.SwapOrder -> setupSwapOrderUI(txInfo)
is TransactionInfoViewData.SwapTransfer -> setupSwapTransferUI(txInfo)
is TransactionInfoViewData.TwapOrder -> setupTwapOrderUI(txInfo)
}

estimatedFee.setOnClickListener {
Expand Down Expand Up @@ -362,6 +367,83 @@ class TxReviewFragment : BaseViewBindingFragment<FragmentTxReviewBinding>() {
copyChainPrefix = viewModel.isChainPrefixCopyEnabled(),
actionInfoItems = txInfo.txActionInfoItems(requireContext().resources)
)

actionDivider.visible(false)
orderLink.visible(false)
}
}

private fun setupSwapOrderUI(txInfo: TransactionInfoViewData.SwapOrder) {
val viewStub = binding.stubSettingsChange
if (viewStub.parent != null) {
val inflate = viewStub.inflate()
contentBinding = TxReviewSettingsChangeBinding.bind(inflate)
}
val settingsChangeBinding = contentBinding as TxReviewSettingsChangeBinding
with(settingsChangeBinding) {
txAction.setActionInfoItems(
chain = chain,
showChainPrefix = viewModel.isChainPrefixPrependEnabled(),
copyChainPrefix = viewModel.isChainPrefixCopyEnabled(),
actionInfoItems = listOf<ActionInfoItem>(
ActionInfoItem.Value(
itemLabel = R.string.tx_status_type_custom,
value = "Swap order"))
)
orderLink.visible(true)
actionDivider.visible(true)

orderLink.setOnClickListener {
requireContext().openUrl(txInfo.explorerUrl)
}
}
}

private fun setupSwapTransferUI(txInfo: TransactionInfoViewData.SwapTransfer) {
val viewStub = binding.stubSettingsChange
if (viewStub.parent != null) {
val inflate = viewStub.inflate()
contentBinding = TxReviewSettingsChangeBinding.bind(inflate)
}
val settingsChangeBinding = contentBinding as TxReviewSettingsChangeBinding
with(settingsChangeBinding) {
txAction.setActionInfoItems(
chain = chain,
showChainPrefix = viewModel.isChainPrefixPrependEnabled(),
copyChainPrefix = viewModel.isChainPrefixCopyEnabled(),
actionInfoItems = listOf<ActionInfoItem>(
ActionInfoItem.Value(
itemLabel = R.string.tx_status_type_custom,
value = "Swap transfer"))
)
orderLink.visible(true)
actionDivider.visible(true)

orderLink.setOnClickListener {
requireContext().openUrl(txInfo.explorerUrl)
}
}
}

private fun setupTwapOrderUI(txInfo: TransactionInfoViewData.TwapOrder) {
val viewStub = binding.stubSettingsChange
if (viewStub.parent != null) {
val inflate = viewStub.inflate()
contentBinding = TxReviewSettingsChangeBinding.bind(inflate)
}
val settingsChangeBinding = contentBinding as TxReviewSettingsChangeBinding
with(settingsChangeBinding) {
txAction.setActionInfoItems(
chain = chain,
showChainPrefix = viewModel.isChainPrefixPrependEnabled(),
copyChainPrefix = viewModel.isChainPrefixCopyEnabled(),
actionInfoItems = listOf<ActionInfoItem>(
ActionInfoItem.Value(
itemLabel = R.string.tx_status_type_custom,
value = "Twap order"))
)
orderLink.visible(false)
actionDivider.visible(false)
}
}

Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/layout/tx_review_settings_change.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="@color/background_secondary">

Expand All @@ -12,4 +13,23 @@
android:layout_marginTop="@dimen/default_margin"
android:layout_marginBottom="-16dp"/>

<View
android:id="@+id/action_divider"
android:layout_width="match_parent"
android:layout_height="@dimen/item_separator_height"
android:visibility="invisible"
android:background="@color/separator" />

<TextView
android:id="@+id/order_link"
style="@style/TextLink"
android:layout_width="wrap_content"
android:layout_height="@dimen/item_setting_openable_height"
android:layout_marginStart="16dp"
app:drawableEndCompat="@drawable/ic_link_green_24dp"
android:drawablePadding="6dp"
android:visibility="invisible"
android:gravity="start|center_vertical"
android:text="@string/tx_details_view_swap_order" />

</LinearLayout>

0 comments on commit 434a7a0

Please sign in to comment.