Setting app title depending on selected account
This commit is contained in:
parent
333c66c2a2
commit
7d3a30ca7f
|
@ -1,16 +1,18 @@
|
||||||
package net.codinux.banking.ui.appskeleton
|
package net.codinux.banking.ui.appskeleton
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.material.BottomAppBar
|
import androidx.compose.material.*
|
||||||
import androidx.compose.material.Icon
|
|
||||||
import androidx.compose.material.IconButton
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Menu
|
import androidx.compose.material.icons.filled.Menu
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.collectAsState
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import net.codinux.banking.ui.config.Colors
|
import net.codinux.banking.ui.config.Colors
|
||||||
|
@ -21,6 +23,8 @@ private val uiState = DI.uiState
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BottomBar() {
|
fun BottomBar() {
|
||||||
|
val accountFilter by uiState.accountFilter.collectAsState()
|
||||||
|
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +37,21 @@ fun BottomBar() {
|
||||||
Icon(Icons.Filled.Menu, contentDescription = "Open Navigation Drawer with sidebar menu")
|
Icon(Icons.Filled.Menu, contentDescription = "Open Navigation Drawer with sidebar menu")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
val title = if (accountFilter.isEmpty()) {
|
||||||
|
"Bankmeister"
|
||||||
|
} else {
|
||||||
|
val filter = accountFilter.first()
|
||||||
|
if (filter.bankAccount != null) {
|
||||||
|
filter.bankAccount.productName ?: filter.bankAccount.identifier
|
||||||
|
} else {
|
||||||
|
filter.userAccount.bankName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text(title, color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current), maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(Modifier.weight(1f))
|
Spacer(Modifier.weight(1f))
|
||||||
|
|
||||||
Spacer(Modifier.width(72.dp)) // space for Floating Action Button
|
Spacer(Modifier.width(72.dp)) // space for Floating Action Button
|
||||||
|
|
Loading…
Reference in New Issue