mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-10 23:04:30 +02:00
Added support for multiple icons for a single row (backwards compatible)
This commit is contained in:
@@ -51,6 +51,7 @@ import androidx.compose.material.icons.outlined.CloudUpload
|
|||||||
import androidx.compose.material.icons.outlined.Drafts
|
import androidx.compose.material.icons.outlined.Drafts
|
||||||
import androidx.compose.material.icons.outlined.GroupAdd
|
import androidx.compose.material.icons.outlined.GroupAdd
|
||||||
import androidx.compose.material.icons.outlined.Key
|
import androidx.compose.material.icons.outlined.Key
|
||||||
|
import androidx.compose.material.icons.outlined.Person
|
||||||
import androidx.compose.material.icons.outlined.Security
|
import androidx.compose.material.icons.outlined.Security
|
||||||
import androidx.compose.material.icons.outlined.Settings
|
import androidx.compose.material.icons.outlined.Settings
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
@@ -66,7 +67,6 @@ import androidx.compose.runtime.derivedStateOf
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@@ -74,7 +74,6 @@ import androidx.compose.ui.draw.clip
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.platform.LocalContext
|
|
||||||
import androidx.compose.ui.platform.LocalFocusManager
|
import androidx.compose.ui.platform.LocalFocusManager
|
||||||
import androidx.compose.ui.text.LinkAnnotation
|
import androidx.compose.ui.text.LinkAnnotation
|
||||||
import androidx.compose.ui.text.SpanStyle
|
import androidx.compose.ui.text.SpanStyle
|
||||||
@@ -427,8 +426,6 @@ fun ListContent(
|
|||||||
|
|
||||||
var backupDialogOpen by remember { mutableStateOf(false) }
|
var backupDialogOpen by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val context = LocalContext.current
|
|
||||||
|
|
||||||
Column(modifier) {
|
Column(modifier) {
|
||||||
NavigationRow(
|
NavigationRow(
|
||||||
title = R.string.profile,
|
title = R.string.profile,
|
||||||
@@ -510,7 +507,7 @@ fun ListContent(
|
|||||||
|
|
||||||
NavigationRow(
|
NavigationRow(
|
||||||
title = R.string.user_preferences,
|
title = R.string.user_preferences,
|
||||||
icon = Icons.Outlined.Settings,
|
icons = listOf(Icons.Outlined.Person, Icons.Outlined.Settings),
|
||||||
tint = MaterialTheme.colorScheme.onBackground,
|
tint = MaterialTheme.colorScheme.onBackground,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
route = Route.UserSettings,
|
route = Route.UserSettings,
|
||||||
@@ -592,11 +589,28 @@ fun NavigationRow(
|
|||||||
tint: Color,
|
tint: Color,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
route: Route,
|
route: Route,
|
||||||
|
) {
|
||||||
|
NavigationRow(
|
||||||
|
title = title,
|
||||||
|
icons = listOf(icon),
|
||||||
|
tint = tint,
|
||||||
|
nav = nav,
|
||||||
|
route = route,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun NavigationRow(
|
||||||
|
title: Int,
|
||||||
|
icons: List<ImageVector>,
|
||||||
|
tint: Color,
|
||||||
|
nav: INav,
|
||||||
|
route: Route,
|
||||||
) {
|
) {
|
||||||
IconRow(
|
IconRow(
|
||||||
title,
|
title = title,
|
||||||
icon,
|
icons = icons,
|
||||||
tint,
|
tint = tint,
|
||||||
onClick = {
|
onClick = {
|
||||||
nav.closeDrawer()
|
nav.closeDrawer()
|
||||||
nav.nav(route)
|
nav.nav(route)
|
||||||
@@ -644,6 +658,21 @@ fun IconRow(
|
|||||||
icon: ImageVector,
|
icon: ImageVector,
|
||||||
tint: Color,
|
tint: Color,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
|
) {
|
||||||
|
IconRow(
|
||||||
|
title = title,
|
||||||
|
icons = listOf(icon),
|
||||||
|
tint = tint,
|
||||||
|
onClick = onClick,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun IconRow(
|
||||||
|
title: Int,
|
||||||
|
icons: List<ImageVector>,
|
||||||
|
tint: Color,
|
||||||
|
onClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier =
|
modifier =
|
||||||
@@ -658,12 +687,15 @@ fun IconRow(
|
|||||||
modifier = IconRowModifier,
|
modifier = IconRowModifier,
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
|
icons.forEach { icon ->
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = icon,
|
imageVector = icon,
|
||||||
contentDescription = stringRes(title),
|
contentDescription = stringRes(title),
|
||||||
modifier = Size22Modifier,
|
modifier = Size22Modifier.padding(end = 4.dp),
|
||||||
tint = tint,
|
tint = tint,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
modifier = IconRowTextModifier,
|
modifier = IconRowTextModifier,
|
||||||
text = stringRes(title),
|
text = stringRes(title),
|
||||||
@@ -717,8 +749,6 @@ fun BottomContent(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
val coroutineScope = rememberCoroutineScope()
|
|
||||||
|
|
||||||
// store the dialog open or close state
|
// store the dialog open or close state
|
||||||
var dialogOpen by remember { mutableStateOf(false) }
|
var dialogOpen by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user