Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-2040 added tx type to the review screen #2048

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading