SelectionModeTopAppBar.kt (3207B)
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.compose 18 19 import androidx.compose.foundation.layout.WindowInsets 20 import androidx.compose.material.icons.Icons 21 import androidx.compose.material.icons.rounded.Close 22 import androidx.compose.material.icons.rounded.Delete 23 import androidx.compose.material.icons.rounded.SelectAll 24 import androidx.compose.material3.ExperimentalMaterial3Api 25 import androidx.compose.material3.Icon 26 import androidx.compose.material3.IconButton 27 import androidx.compose.material3.MaterialTheme 28 import androidx.compose.material3.Text 29 import androidx.compose.material3.TopAppBar 30 import androidx.compose.material3.TopAppBarDefaults 31 import androidx.compose.runtime.Composable 32 import androidx.compose.runtime.snapshots.SnapshotStateList 33 import androidx.compose.ui.res.stringResource 34 import androidx.compose.ui.unit.dp 35 import net.taler.wallet.R 36 37 @Composable 38 @OptIn(ExperimentalMaterial3Api::class) 39 fun SelectionModeTopAppBar( 40 selectedItems: SnapshotStateList<String>, 41 resetSelectionMode: () -> Unit, 42 onSelectAllClicked: () -> Unit, 43 onDeleteClicked: () -> Unit, 44 ) { 45 TopAppBar( 46 title = { 47 Text( 48 text = "${selectedItems.size} selected", 49 style = MaterialTheme.typography.titleLarge.copy( 50 color = MaterialTheme.colorScheme.onSurface, 51 ), 52 ) 53 }, 54 55 navigationIcon = { 56 IconButton(resetSelectionMode) { 57 Icon( 58 imageVector = Icons.Rounded.Close, 59 contentDescription = null, 60 tint = MaterialTheme.colorScheme.onSurface, 61 ) 62 } 63 }, 64 65 actions = { 66 IconButton(onDeleteClicked) { 67 Icon( 68 imageVector = Icons.Rounded.Delete, 69 contentDescription = stringResource(R.string.transactions_delete), 70 tint = MaterialTheme.colorScheme.onSurface, 71 ) 72 } 73 74 IconButton(onSelectAllClicked) { 75 Icon( 76 imageVector = Icons.Rounded.SelectAll, 77 contentDescription = stringResource(R.string.transactions_select_all), 78 tint = MaterialTheme.colorScheme.onSurface, 79 ) 80 } 81 }, 82 83 colors = TopAppBarDefaults.topAppBarColors( 84 containerColor = MaterialTheme.colorScheme.surfaceContainer, 85 ), 86 87 windowInsets = WindowInsets(0.dp), 88 ) 89 }