TransactionPaymentFragment.kt (2116B)
1 /* 2 * This file is part of GNU Taler 3 * (C) 2020 Taler Systems S.A. 4 * 5 * GNU Taler is free software; you can redistribute it and/or modify it under the 6 * terms of the GNU General Public License as published by the Free Software 7 * Foundation; either version 3, or (at your option) any later version. 8 * 9 * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License along with 14 * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 17 package net.taler.wallet.transactions 18 19 import android.os.Bundle 20 import android.view.LayoutInflater 21 import android.view.View 22 import android.view.ViewGroup 23 import androidx.compose.runtime.getValue 24 import androidx.compose.ui.platform.ComposeView 25 import net.taler.wallet.compose.TalerSurface 26 import net.taler.wallet.compose.collectAsStateLifecycleAware 27 import net.taler.wallet.launchInAppBrowser 28 import net.taler.wallet.payment.TransactionPaymentComposable 29 30 class TransactionPaymentFragment : TransactionDetailFragment() { 31 32 override fun onCreateView( 33 inflater: LayoutInflater, 34 container: ViewGroup?, 35 savedInstanceState: Bundle?, 36 ): View = ComposeView(requireContext()).apply { 37 setContent { 38 TalerSurface { 39 val t by transactionManager.selectedTransaction.collectAsStateLifecycleAware() 40 (t as? TransactionPayment)?.let { tx -> 41 TransactionPaymentComposable(tx, devMode, 42 exchangeManager.getSpecForCurrency(tx.amountRaw.currency, tx.scopes), 43 onFulfill = { url -> 44 launchInAppBrowser(requireContext(), url) 45 }, 46 onTransition = { 47 onTransitionButtonClicked(tx, it) 48 } 49 ) 50 } 51 } 52 } 53 } 54 }