taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

TransactionDepositFragment.kt (2486B)


      1 /*
      2  * This file is part of GNU Taler
      3  * (C) 2022 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.runtime.remember
     25 import androidx.compose.ui.platform.ComposeView
     26 import androidx.core.os.bundleOf
     27 import androidx.navigation.fragment.findNavController
     28 import net.taler.wallet.R
     29 import net.taler.wallet.compose.TalerSurface
     30 import net.taler.wallet.compose.collectAsStateLifecycleAware
     31 import net.taler.wallet.deposit.TransactionDepositComposable
     32 
     33 class TransactionDepositFragment : TransactionDetailFragment() {
     34 
     35     override fun onCreateView(
     36         inflater: LayoutInflater,
     37         container: ViewGroup?,
     38         savedInstanceState: Bundle?,
     39     ): View = ComposeView(requireContext()).apply {
     40         setContent {
     41             TalerSurface {
     42                 val t by transactionManager.selectedTransaction.collectAsStateLifecycleAware()
     43                 val tx = remember(t) { t }
     44                 if (tx is TransactionDeposit) TransactionDepositComposable(
     45                     t = tx,
     46                     devMode = devMode,
     47                     spec = exchangeManager.getSpecForCurrency(tx.amountRaw.currency, tx.scopes),
     48                     onWireTransfer = { onConfirmManual() },
     49                     onShowQrCodes = { onShowQrCodes() },
     50                 ) {
     51                     onTransitionButtonClicked(tx, it)
     52                 }
     53             }
     54         }
     55     }
     56 
     57     fun onConfirmManual(showQrCodes: Boolean = false) {
     58         findNavController().navigate(
     59             R.id.action_global_wireTransferDetails,
     60             bundleOf("showQrCodes" to showQrCodes)
     61         )
     62     }
     63 
     64     fun onShowQrCodes() {
     65         onConfirmManual(showQrCodes = true)
     66     }
     67 }