Use different color for selected items
This commit is contained in:
1 parent
d91d333baa
commit
4381237eb3
4 files changed
+21
-13
No files matched your search
@@ -312,12 +312,11 @@ fun AnimatedVisibilityScope.DownloadsScreen(navigator: DestinationsNavigator) =
|
||||
switchLabel("")
|
||||
closeSheet()
|
||||
},
|
||||
tonalElevation = 1.dp,
|
||||
shadowElevation = 1.dp,
|
||||
headlineContent = {
|
||||
Text("$allName [$totalCount]")
|
||||
},
|
||||
colors = listItemOnDrawerColor(),
|
||||
colors = listItemOnDrawerColor(filterState.label == ""),
|
||||
)
|
||||
}
|
||||
item {
|
||||
@@ -326,12 +325,11 @@ fun AnimatedVisibilityScope.DownloadsScreen(navigator: DestinationsNavigator) =
|
||||
switchLabel(null)
|
||||
closeSheet()
|
||||
},
|
||||
tonalElevation = 1.dp,
|
||||
shadowElevation = 1.dp,
|
||||
headlineContent = {
|
||||
Text("$emptyLabelName [${downloadsCount.getOrDefault(null, 0)}]")
|
||||
},
|
||||
colors = listItemOnDrawerColor(),
|
||||
colors = listItemOnDrawerColor(filterState.label == null),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -385,7 +383,6 @@ fun AnimatedVisibilityScope.DownloadsScreen(navigator: DestinationsNavigator) =
|
||||
switchLabel(item)
|
||||
closeSheet()
|
||||
},
|
||||
tonalElevation = 1.dp,
|
||||
shadowElevation = elevation,
|
||||
headlineContent = {
|
||||
val name = if (filterMode == DownloadsFilterMode.ARTIST) getTranslation(label) else label
|
||||
@@ -437,7 +434,7 @@ fun AnimatedVisibilityScope.DownloadsScreen(navigator: DestinationsNavigator) =
|
||||
}
|
||||
}
|
||||
},
|
||||
colors = listItemOnDrawerColor(),
|
||||
colors = listItemOnDrawerColor(filterState.label == item),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
package com.hippo.ehviewer.ui.screen
|
||||
|
||||
import androidx.compose.material3.DrawerDefaults
|
||||
import androidx.compose.material3.ListItemDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
fun listItemOnDrawerColor() = ListItemDefaults.colors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainerLow,
|
||||
fun selectedListItemColor() = ListItemDefaults.colors(
|
||||
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||
headlineColor = MaterialTheme.colorScheme.onSecondaryContainer,
|
||||
trailingIconColor = MaterialTheme.colorScheme.onSecondaryContainer,
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun listItemOnDrawerColor(selected: Boolean) = if (selected) {
|
||||
selectedListItemColor()
|
||||
} else {
|
||||
ListItemDefaults.colors(
|
||||
containerColor = DrawerDefaults.modalContainerColor,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun topBarOnDrawerColor() = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainerLow,
|
||||
containerColor = DrawerDefaults.modalContainerColor,
|
||||
scrolledContainerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
|
||||
)
|
||||
@@ -220,7 +220,7 @@ fun AnimatedVisibilityScope.FavouritesScreen(navigator: DestinationsNavigator) =
|
||||
Settings.recentFavCat = newCat
|
||||
launch { sheetState.close() }
|
||||
},
|
||||
colors = listItemOnDrawerColor(),
|
||||
colors = listItemOnDrawerColor(urlBuilder.favCat == index - 2),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De
|
||||
headlineContent = {
|
||||
Text(text = name)
|
||||
},
|
||||
colors = listItemOnDrawerColor(),
|
||||
colors = listItemOnDrawerColor(urlBuilder.keyword == keyword),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -415,7 +415,6 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De
|
||||
}
|
||||
launch { sheetState.close() }
|
||||
},
|
||||
tonalElevation = 1.dp,
|
||||
shadowElevation = elevation,
|
||||
headlineContent = {
|
||||
Text(text = item.name)
|
||||
@@ -445,7 +444,7 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De
|
||||
Icon(imageVector = Icons.Default.Reorder, contentDescription = null)
|
||||
}
|
||||
},
|
||||
colors = listItemOnDrawerColor(),
|
||||
colors = listItemOnDrawerColor(false),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user