diff options
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt')
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt | 57 |
1 files changed, 17 insertions, 40 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt index 9c30609..b4a3be8 100644 --- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt @@ -19,55 +19,32 @@ package net.taler.wallet.transactions import android.os.Bundle import android.view.LayoutInflater import android.view.View -import android.view.View.VISIBLE import android.view.ViewGroup -import androidx.core.content.ContextCompat.getColor -import net.taler.common.toAbsoluteTime -import net.taler.wallet.R -import net.taler.wallet.databinding.FragmentTransactionPaymentBinding +import androidx.compose.runtime.livedata.observeAsState +import androidx.compose.ui.platform.ComposeView +import net.taler.wallet.compose.TalerSurface +import net.taler.wallet.launchInAppBrowser +import net.taler.wallet.payment.TransactionPaymentComposable class TransactionRefundFragment : TransactionDetailFragment() { - private lateinit var ui: FragmentTransactionPaymentBinding - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?, - ): View { - ui = FragmentTransactionPaymentBinding.inflate(inflater, container, false) - return ui.root - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - transactionManager.selectedTransaction.observe(viewLifecycleOwner) { t -> - if (t !is TransactionRefund) return@observe - ui.timeView.text = t.timestamp.ms.toAbsoluteTime(requireContext()) - - ui.amountPaidWithFeesLabel.text = getString(R.string.transaction_refund) - ui.amountPaidWithFeesView.setTextColor(getColor(requireContext(), R.color.green)) - ui.amountPaidWithFeesView.text = - getString(R.string.amount_positive, t.amountEffective.toString()) - val fee = t.amountRaw - t.amountEffective - bindOrderAndFee( - ui.orderSummaryView, - ui.orderAmountView, - ui.orderIdView, - ui.feeView, - t.info, - t.amountRaw, - fee - ) - ui.deleteButton.setOnClickListener { - onDeleteButtonClicked(t) - } - if (devMode.value == true && t.error != null) { - ui.showErrorButton.visibility = VISIBLE - ui.showErrorButton.setOnClickListener { - onShowErrorButtonClicked(t) - } + ): View = ComposeView(requireContext()).apply { + setContent { + TalerSurface { + val t = transactionManager.selectedTransaction.observeAsState().value + if (t is TransactionRefund) TransactionPaymentComposable(t, devMode.value, + onFulfill = { url -> + launchInAppBrowser(requireContext(), url) + }, + onDelete = { + onDeleteButtonClicked(t) + } + ) } } } - } |