Add highlight to single result
This commit is contained in:
parent
238a01c15e
commit
df49cff350
@ -63,10 +63,14 @@ fun InnerCard(
|
||||
val bgColor by transition.animateColor(label = "bgColor", transitionSpec = {
|
||||
tween(250, if (targetState == InnerCardStyle.Raised) 0 else 250)
|
||||
}) {
|
||||
if (it == InnerCardStyle.Highlighted) {
|
||||
MaterialTheme.colorScheme.secondaryContainer
|
||||
} else {
|
||||
MaterialTheme.colorScheme.surfaceColorAtElevation(absoluteTonalElevation + elevation)
|
||||
when (it) {
|
||||
InnerCardStyle.Highlighted -> {
|
||||
MaterialTheme.colorScheme.secondaryContainer
|
||||
}
|
||||
InnerCardStyle.Default -> Color.Transparent
|
||||
else -> {
|
||||
MaterialTheme.colorScheme.surfaceColorAtElevation(absoluteTonalElevation + elevation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.draw.drawWithCache
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.RectangleShape
|
||||
import androidx.compose.ui.graphics.Shape
|
||||
import androidx.compose.ui.graphics.drawOutline
|
||||
@ -31,16 +32,18 @@ fun LauncherCard(
|
||||
elevation: Dp = 2.dp,
|
||||
backgroundOpacity: Float = LocalCardStyle.current.opacity,
|
||||
shape: Shape = MaterialTheme.shapes.medium,
|
||||
color: Color = MaterialTheme.colorScheme.surface.copy(alpha = backgroundOpacity.coerceIn(0f, 1f)),
|
||||
border: BorderStroke? = LocalCardStyle.current.borderWidth.takeIf { it > 0 }
|
||||
?.let { BorderStroke(it.dp, MaterialTheme.colorScheme.surface) },
|
||||
content: @Composable () -> Unit = {}
|
||||
) {
|
||||
Surface(
|
||||
modifier = modifier,
|
||||
shape = shape,
|
||||
border = LocalCardStyle.current.borderWidth.takeIf { it > 0 }
|
||||
?.let { BorderStroke(it.dp, MaterialTheme.colorScheme.surface) },
|
||||
border = border,
|
||||
content = content,
|
||||
contentColor = MaterialTheme.colorScheme.onSurface,
|
||||
color = MaterialTheme.colorScheme.surface.copy(alpha = backgroundOpacity.coerceIn(0f, 1f)),
|
||||
color = color,
|
||||
shadowElevation = if (backgroundOpacity == 1f) elevation else 0.dp,
|
||||
tonalElevation = elevation,
|
||||
)
|
||||
|
||||
@ -24,13 +24,13 @@ import androidx.compose.material.icons.rounded.Work
|
||||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.FloatingActionButtonDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.SmallFloatingActionButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
@ -57,6 +57,7 @@ import de.mm20.launcher2.ui.launcher.search.website.WebsiteItem
|
||||
import de.mm20.launcher2.ui.launcher.search.wikipedia.WikipediaItem
|
||||
import de.mm20.launcher2.ui.launcher.sheets.HiddenItemsSheet
|
||||
import de.mm20.launcher2.ui.launcher.sheets.LocalBottomSheetManager
|
||||
import de.mm20.launcher2.ui.locals.LocalCardStyle
|
||||
import de.mm20.launcher2.ui.locals.LocalGridSettings
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
@ -333,12 +334,12 @@ fun SearchColumn(
|
||||
highlightedItem = bestMatch as? SavableSearchable
|
||||
)
|
||||
for (wiki in wikipedia) {
|
||||
SingleResult {
|
||||
SingleResult(highlight = bestMatch == wiki) {
|
||||
WikipediaItem(wikipedia = wiki)
|
||||
}
|
||||
}
|
||||
for (ws in website) {
|
||||
SingleResult {
|
||||
SingleResult(highlight = bestMatch == ws) {
|
||||
WebsiteItem(website = ws)
|
||||
}
|
||||
}
|
||||
@ -370,7 +371,9 @@ fun SearchColumn(
|
||||
|
||||
val sheetManager = LocalBottomSheetManager.current
|
||||
if (sheetManager.hiddenItemsSheetShown.value) {
|
||||
HiddenItemsSheet(items = hiddenResults, onDismiss = { sheetManager.dismissHiddenItemsSheet() })
|
||||
HiddenItemsSheet(
|
||||
items = hiddenResults,
|
||||
onDismiss = { sheetManager.dismissHiddenItemsSheet() })
|
||||
}
|
||||
}
|
||||
|
||||
@ -539,7 +542,10 @@ fun ListRow(
|
||||
}
|
||||
}
|
||||
|
||||
fun LazyListScope.SingleResult(content: @Composable (() -> Unit)?) {
|
||||
fun LazyListScope.SingleResult(
|
||||
highlight: Boolean = false,
|
||||
content: @Composable (() -> Unit)?
|
||||
) {
|
||||
if (content == null) return
|
||||
item {
|
||||
LauncherCard(
|
||||
@ -548,7 +554,9 @@ fun LazyListScope.SingleResult(content: @Composable (() -> Unit)?) {
|
||||
horizontal = 8.dp,
|
||||
vertical = 4.dp,
|
||||
)
|
||||
.animateItemPlacement()
|
||||
.animateItemPlacement(),
|
||||
color = if (highlight) MaterialTheme.colorScheme.secondaryContainer
|
||||
else MaterialTheme.colorScheme.surface.copy(LocalCardStyle.current.opacity)
|
||||
) {
|
||||
content()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user