taler-android

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

AddAccountBitcoin.kt (2500B)


      1 /*
      2  * This file is part of GNU Taler
      3  * (C) 2024 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.deposit
     18 
     19 import androidx.compose.foundation.layout.fillMaxWidth
     20 import androidx.compose.foundation.layout.padding
     21 import androidx.compose.foundation.text.KeyboardActions
     22 import androidx.compose.foundation.text.KeyboardOptions
     23 import androidx.compose.material3.MaterialTheme
     24 import androidx.compose.material3.OutlinedTextField
     25 import androidx.compose.material3.Text
     26 import androidx.compose.runtime.Composable
     27 import androidx.compose.ui.Modifier
     28 import androidx.compose.ui.focus.FocusDirection
     29 import androidx.compose.ui.graphics.Color
     30 import androidx.compose.ui.platform.LocalFocusManager
     31 import androidx.compose.ui.res.stringResource
     32 import androidx.compose.ui.text.input.ImeAction
     33 import androidx.compose.ui.unit.dp
     34 import net.taler.wallet.R
     35 
     36 @Composable
     37 fun AddAccountBitcoin(
     38     bitcoinAddress: String,
     39     onFormEdited: (bitcoinAddress: String) -> Unit,
     40 ) {
     41     val focusManager = LocalFocusManager.current
     42     OutlinedTextField(
     43         modifier = Modifier
     44             .fillMaxWidth()
     45             .padding(
     46                 bottom = 16.dp,
     47                 start = 16.dp,
     48                 end = 16.dp,
     49             ),
     50         value = bitcoinAddress,
     51         singleLine = true,
     52         onValueChange = { input ->
     53             onFormEdited(input)
     54         },
     55         isError = bitcoinAddress.isBlank(),
     56         label = {
     57             Text(
     58                 stringResource(R.string.send_deposit_bitcoin_address),
     59                 color = if (bitcoinAddress.isBlank()) {
     60                     MaterialTheme.colorScheme.error
     61                 } else Color.Unspecified,
     62             )
     63         },
     64         keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
     65         keyboardActions = KeyboardActions(onNext = { focusManager.moveFocus(FocusDirection.Next) }),
     66     )
     67 }