TransactionDummyFragment.kt (2442B)
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.foundation.layout.Column 24 import androidx.compose.foundation.layout.fillMaxWidth 25 import androidx.compose.foundation.layout.padding 26 import androidx.compose.foundation.rememberScrollState 27 import androidx.compose.foundation.verticalScroll 28 import androidx.compose.runtime.Composable 29 import androidx.compose.runtime.getValue 30 import androidx.compose.ui.Alignment.Companion.CenterHorizontally 31 import androidx.compose.ui.Modifier 32 import androidx.compose.ui.platform.ComposeView 33 import androidx.compose.ui.unit.dp 34 import net.taler.wallet.BottomInsetsSpacer 35 import net.taler.wallet.compose.TalerSurface 36 import net.taler.wallet.compose.collectAsStateLifecycleAware 37 38 class TransactionDummyFragment : TransactionDetailFragment() { 39 40 override fun onCreateView( 41 inflater: LayoutInflater, 42 container: ViewGroup?, 43 savedInstanceState: Bundle?, 44 ): View = ComposeView(requireContext()).apply { 45 setContent { 46 TalerSurface { 47 val t by transactionManager.selectedTransaction.collectAsStateLifecycleAware() 48 (t as? DummyTransaction)?.let { TransactionDummyComposable(it) } 49 } 50 } 51 } 52 } 53 54 @Composable 55 fun TransactionDummyComposable(t: DummyTransaction) { 56 val scrollState = rememberScrollState() 57 Column( 58 modifier = Modifier 59 .fillMaxWidth() 60 .padding(16.dp) 61 .verticalScroll(scrollState), 62 horizontalAlignment = CenterHorizontally, 63 ) { 64 ErrorTransactionButton(error = t.error) 65 BottomInsetsSpacer() 66 } 67 }