Revert "use lazy grid for search results"
This reverts commit 32031d6ef8.
This commit is contained in:
@@ -4,7 +4,7 @@ import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
@@ -42,24 +42,24 @@ internal class SearchComponent(
|
||||
state: LauncherScaffoldState
|
||||
) {
|
||||
val searchVM = viewModel<SearchVM>()
|
||||
val lazyGridState = rememberLazyGridState()
|
||||
val lazyListState = rememberLazyListState()
|
||||
|
||||
LaunchedEffect(isActive) {
|
||||
if (!isActive) {
|
||||
searchVM.reset()
|
||||
lazyGridState.scrollToItem(0, 0)
|
||||
lazyListState.scrollToItem(0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(searchVM.searchQuery.value, searchVM.filters.value) {
|
||||
lazyGridState.requestScrollToItem(0, 0)
|
||||
lazyListState.requestScrollToItem(0, 0)
|
||||
}
|
||||
|
||||
LaunchedEffect(lazyGridState.canScrollForward, lazyGridState.canScrollBackward) {
|
||||
LaunchedEffect(lazyListState.canScrollForward, lazyListState.canScrollBackward) {
|
||||
isAtBottom.value =
|
||||
!lazyGridState.canScrollForward && !reverse || !lazyGridState.canScrollBackward && reverse
|
||||
!lazyListState.canScrollForward && !reverse || !lazyListState.canScrollBackward && reverse
|
||||
isAtTop.value =
|
||||
!lazyGridState.canScrollForward && reverse || !lazyGridState.canScrollBackward && !reverse
|
||||
!lazyListState.canScrollForward && reverse || !lazyListState.canScrollBackward && !reverse
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ internal class SearchComponent(
|
||||
SearchColumn(
|
||||
modifier = Modifier.nestedScroll(scrollConnection).widthIn(max = 916.dp).fillMaxHeight(),
|
||||
paddingValues = insets,
|
||||
state = lazyGridState,
|
||||
state = lazyListState,
|
||||
reverse = reverse,
|
||||
userScrollEnabled = !state.isDragged,
|
||||
onHideKeyboard = {
|
||||
|
||||
@@ -12,11 +12,6 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridState
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.surfaceColorAtElevation
|
||||
@@ -63,7 +58,7 @@ import de.mm20.launcher2.ui.theme.transparency.transparency
|
||||
fun SearchColumn(
|
||||
modifier: Modifier = Modifier,
|
||||
paddingValues: PaddingValues = PaddingValues(0.dp),
|
||||
state: LazyGridState = rememberLazyGridState(),
|
||||
state: LazyListState = rememberLazyListState(),
|
||||
reverse: Boolean = false,
|
||||
userScrollEnabled: Boolean = true,
|
||||
onHideKeyboard: () -> Unit = {},
|
||||
@@ -161,12 +156,11 @@ fun SearchColumn(
|
||||
)
|
||||
}
|
||||
} else {
|
||||
LazyVerticalGrid(
|
||||
LazyColumn(
|
||||
state = state,
|
||||
userScrollEnabled = userScrollEnabled,
|
||||
contentPadding = paddingValues,
|
||||
reverseLayout = reverse,
|
||||
columns = GridCells.Fixed(columns),
|
||||
) {
|
||||
if (!hideFavs && favoritesEnabled) {
|
||||
SearchFavorites(
|
||||
@@ -184,7 +178,7 @@ fun SearchColumn(
|
||||
)
|
||||
} else {
|
||||
// Empty item to maintain scroll position
|
||||
item(key = "favorites", span = { GridItemSpan(maxLineSpan) }) {
|
||||
item(key = "favorites") {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.FilledTonalButton
|
||||
@@ -36,7 +35,7 @@ import de.mm20.launcher2.ui.launcher.search.common.list.ListResults
|
||||
import de.mm20.launcher2.ui.layout.BottomReversed
|
||||
import de.mm20.launcher2.ui.locals.LocalGridSettings
|
||||
|
||||
fun LazyGridScope.AppResults(
|
||||
fun LazyListScope.AppResults(
|
||||
onProfileSelected: (Int) -> Unit,
|
||||
profiles: List<Profile> = emptyList(),
|
||||
selectedProfileIndex: Int = -1,
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
package de.mm20.launcher2.ui.launcher.search.calculator
|
||||
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import de.mm20.launcher2.search.data.Calculator
|
||||
import de.mm20.launcher2.ui.launcher.search.common.list.ListItemSurface
|
||||
|
||||
fun LazyGridScope.CalculatorResults(
|
||||
fun LazyListScope.CalculatorResults(
|
||||
calculator: List<Calculator>,
|
||||
reverse: Boolean,
|
||||
) {
|
||||
if (calculator.isNotEmpty()) {
|
||||
item(
|
||||
key = "calculator",
|
||||
span = {
|
||||
GridItemSpan(maxLineSpan)
|
||||
}
|
||||
) {
|
||||
item(key = "calculator") {
|
||||
ListItemSurface(
|
||||
isFirst = true,
|
||||
isLast = true,
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.mm20.launcher2.ui.launcher.search.calendar
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -16,7 +16,7 @@ import de.mm20.launcher2.ui.launcher.search.common.list.ListItem
|
||||
import de.mm20.launcher2.ui.launcher.search.common.list.ListResults
|
||||
import kotlin.math.min
|
||||
|
||||
fun LazyGridScope.CalendarResults(
|
||||
fun LazyListScope.CalendarResults(
|
||||
events: List<CalendarEvent>,
|
||||
missingPermission: Boolean,
|
||||
onPermissionRequest: () -> Unit,
|
||||
@@ -39,7 +39,7 @@ fun LazyGridScope.CalendarResults(
|
||||
.fillMaxWidth(),
|
||||
item = calendar,
|
||||
showDetails = showDetails,
|
||||
onShowDetails = { onSelect(if (it) index else -1) },
|
||||
onShowDetails = { onSelect(if(it) index else -1) },
|
||||
highlight = highlightedItem?.key == calendar.key
|
||||
)
|
||||
},
|
||||
|
||||
@@ -2,29 +2,21 @@ package de.mm20.launcher2.ui.launcher.search.common.grid
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.IntrinsicSize
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.sizeIn
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import de.mm20.launcher2.search.SavableSearchable
|
||||
import de.mm20.launcher2.ui.ktx.withCorners
|
||||
import de.mm20.launcher2.ui.theme.transparency.transparency
|
||||
import kotlin.math.ceil
|
||||
|
||||
fun <T : SavableSearchable> LazyGridScope.GridResults(
|
||||
fun <T : SavableSearchable> LazyListScope.GridResults(
|
||||
key: String,
|
||||
items: List<T>,
|
||||
itemContent: @Composable (T) -> Unit,
|
||||
@@ -37,9 +29,6 @@ fun <T : SavableSearchable> LazyGridScope.GridResults(
|
||||
item(
|
||||
key = "$key-before",
|
||||
contentType = { "$key-before" },
|
||||
span = {
|
||||
GridItemSpan(maxLineSpan)
|
||||
}
|
||||
) {
|
||||
val isTop = !reverse || items.isEmpty() && after == null
|
||||
val isBottom = reverse || items.isEmpty() && after == null
|
||||
@@ -65,56 +54,54 @@ fun <T : SavableSearchable> LazyGridScope.GridResults(
|
||||
}
|
||||
|
||||
val rows = ceil(items.size / columns.toFloat()).toInt()
|
||||
// cells at the end of the grid that are empty
|
||||
val emptySlots = rows * columns - items.size
|
||||
items(
|
||||
items.size,
|
||||
key = { "$key-${items[it].key}" },
|
||||
contentType = { key },
|
||||
span = {
|
||||
if (it == items.lastIndex) {
|
||||
GridItemSpan(maxCurrentLineSpan)
|
||||
} else {
|
||||
GridItemSpan(1)
|
||||
}
|
||||
}
|
||||
rows,
|
||||
key = {
|
||||
"$key-$it"
|
||||
},
|
||||
contentType = { key }
|
||||
) {
|
||||
val item = items[it]
|
||||
|
||||
val isFirstRow = before == null && it < columns
|
||||
val isLastRow = after == null && it >= items.lastIndex - (items.lastIndex % columns)
|
||||
val isFirstInRow = it % columns == 0
|
||||
val isLastInRow = it % columns == columns - 1 || it == items.lastIndex
|
||||
Box(
|
||||
val isFirst = it == 0 && before == null
|
||||
val isLast = it == rows - 1 && after == null
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(
|
||||
top = if (reverse && isLastRow) 8.dp else 0.dp,
|
||||
bottom = if (!reverse && isLastRow) 8.dp else 0.dp,
|
||||
top = if (reverse && isLast) 8.dp else 0.dp,
|
||||
bottom = if (!reverse && isLast) 8.dp else 0.dp,
|
||||
)
|
||||
.background(
|
||||
MaterialTheme.colorScheme.surface.copy(alpha = MaterialTheme.transparency.surface),
|
||||
MaterialTheme.shapes.medium.withCorners(
|
||||
topStart = isFirstInRow && (isFirstRow && !reverse || isLastRow && reverse),
|
||||
topEnd = isLastInRow && (isFirstRow && !reverse || isLastRow && reverse),
|
||||
bottomStart = isFirstInRow && (isLastRow && !reverse || isFirstRow && reverse),
|
||||
bottomEnd = isLastInRow && (isLastRow && !reverse || isFirstRow && reverse),
|
||||
topStart = isFirst && !reverse || isLast && reverse,
|
||||
topEnd = isFirst && !reverse || isLast && reverse,
|
||||
bottomEnd = isLast && !reverse || isFirst && reverse,
|
||||
bottomStart = isLast && !reverse || isFirst && reverse,
|
||||
)
|
||||
)
|
||||
.padding(
|
||||
top = if (isFirstRow) 8.dp else 0.dp,
|
||||
bottom = if (isLastRow) 8.dp else 0.dp,
|
||||
start = if (columns == 1 || !isFirstInRow) 0.dp else 4.dp,
|
||||
end = if (columns == 1 || !isLastInRow) 0.dp else 4.dp,
|
||||
top = if (it == 0) 8.dp else 0.dp,
|
||||
bottom = if (it == rows - 1) 8.dp else 0.dp,
|
||||
start = if (columns == 1) 0.dp else 4.dp,
|
||||
end = if (columns == 1) 0.dp else 4.dp,
|
||||
)
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth(
|
||||
if (it == items.lastIndex) 1f / (1f + emptySlots)
|
||||
else 1f
|
||||
)
|
||||
) {
|
||||
itemContent(item)
|
||||
Row {
|
||||
for (i in 0 until columns) {
|
||||
val item = items.getOrNull(it * columns + i)
|
||||
if (item != null) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
) {
|
||||
itemContent(item)
|
||||
}
|
||||
} else {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,9 +110,6 @@ fun <T : SavableSearchable> LazyGridScope.GridResults(
|
||||
item(
|
||||
key = "$key-after",
|
||||
contentType = { "$key-after" },
|
||||
span = {
|
||||
GridItemSpan(maxLineSpan)
|
||||
}
|
||||
) {
|
||||
val isTop = reverse || items.isEmpty() && before == null
|
||||
val isBottom = !reverse || items.isEmpty() && before == null
|
||||
|
||||
@@ -11,9 +11,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyItemScope
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridItemScope
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -27,7 +24,7 @@ import de.mm20.launcher2.ui.ktx.animateShapeAsState
|
||||
import de.mm20.launcher2.ui.layout.BottomReversed
|
||||
import de.mm20.launcher2.ui.theme.transparency.transparency
|
||||
|
||||
fun <T : SavableSearchable> LazyGridScope.ListResults(
|
||||
fun <T : SavableSearchable> LazyListScope.ListResults(
|
||||
key: String,
|
||||
items: List<T>,
|
||||
itemContent: @Composable ColumnScope.(T, Boolean, Int) -> Unit,
|
||||
@@ -40,9 +37,6 @@ fun <T : SavableSearchable> LazyGridScope.ListResults(
|
||||
item(
|
||||
key = "$key-before",
|
||||
contentType = { "$key-before" },
|
||||
span = {
|
||||
GridItemSpan(maxLineSpan)
|
||||
}
|
||||
) {
|
||||
ListItemSurface(
|
||||
isFirst = true,
|
||||
@@ -61,9 +55,6 @@ fun <T : SavableSearchable> LazyGridScope.ListResults(
|
||||
"$key-${items[it].key}"
|
||||
},
|
||||
contentType = { key },
|
||||
span = {
|
||||
GridItemSpan(maxLineSpan)
|
||||
}
|
||||
) {
|
||||
val item = items[it]
|
||||
val showDetails = it == selectedIndex
|
||||
@@ -83,9 +74,6 @@ fun <T : SavableSearchable> LazyGridScope.ListResults(
|
||||
item(
|
||||
key = "$key-after",
|
||||
contentType = { "$key-after" },
|
||||
span = {
|
||||
GridItemSpan(maxLineSpan)
|
||||
}
|
||||
) {
|
||||
ListItemSurface(
|
||||
isFirst = before == null && items.isEmpty(),
|
||||
@@ -100,7 +88,7 @@ fun <T : SavableSearchable> LazyGridScope.ListResults(
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun LazyGridItemScope.ListItemSurface(
|
||||
fun LazyItemScope.ListItemSurface(
|
||||
isFirst: Boolean = false,
|
||||
isLast: Boolean = false,
|
||||
reverse: Boolean = false,
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.mm20.launcher2.ui.launcher.search.contacts
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -16,7 +16,7 @@ import de.mm20.launcher2.ui.launcher.search.common.list.ListItem
|
||||
import de.mm20.launcher2.ui.launcher.search.common.list.ListResults
|
||||
import kotlin.math.min
|
||||
|
||||
fun LazyGridScope.ContactResults(
|
||||
fun LazyListScope.ContactResults(
|
||||
contacts: List<Contact>,
|
||||
missingPermission: Boolean,
|
||||
onPermissionRequest: () -> Unit,
|
||||
|
||||
@@ -5,8 +5,6 @@ import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -23,7 +21,7 @@ import de.mm20.launcher2.ui.launcher.search.common.grid.SearchResultGrid
|
||||
import de.mm20.launcher2.ui.layout.BottomReversed
|
||||
import de.mm20.launcher2.ui.theme.transparency.transparency
|
||||
|
||||
fun LazyGridScope.SearchFavorites(
|
||||
fun LazyListScope.SearchFavorites(
|
||||
favorites: List<SavableSearchable>,
|
||||
pinnedTags: List<Tag>,
|
||||
selectedTag: String?,
|
||||
@@ -36,9 +34,6 @@ fun LazyGridScope.SearchFavorites(
|
||||
) {
|
||||
item(
|
||||
key = "favorites",
|
||||
span = {
|
||||
GridItemSpan(maxLineSpan)
|
||||
}
|
||||
) {
|
||||
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
|
||||
Column(
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.mm20.launcher2.ui.launcher.search.files
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -16,7 +16,7 @@ import de.mm20.launcher2.ui.launcher.search.common.list.ListItem
|
||||
import de.mm20.launcher2.ui.launcher.search.common.list.ListResults
|
||||
import kotlin.math.min
|
||||
|
||||
fun LazyGridScope.FileResults(
|
||||
fun LazyListScope.FileResults(
|
||||
files: List<File>,
|
||||
missingPermission: Boolean,
|
||||
onPermissionRequest: () -> Unit,
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.mm20.launcher2.ui.launcher.search.location
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -16,7 +16,7 @@ import de.mm20.launcher2.ui.launcher.search.common.list.ListItem
|
||||
import de.mm20.launcher2.ui.launcher.search.common.list.ListResults
|
||||
import kotlin.math.min
|
||||
|
||||
fun LazyGridScope.LocationResults(
|
||||
fun LazyListScope.LocationResults(
|
||||
locations: List<Location>,
|
||||
missingPermission: Boolean,
|
||||
onPermissionRequest: () -> Unit,
|
||||
@@ -39,7 +39,7 @@ fun LazyGridScope.LocationResults(
|
||||
.fillMaxWidth(),
|
||||
item = location,
|
||||
showDetails = showDetails,
|
||||
onShowDetails = { onSelect(if (it) index else -1) },
|
||||
onShowDetails = { onSelect(if(it) index else -1) },
|
||||
highlight = highlightedItem?.key == location.key
|
||||
)
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.mm20.launcher2.ui.launcher.search.shortcut
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -16,7 +16,7 @@ import de.mm20.launcher2.ui.launcher.search.common.list.ListItem
|
||||
import de.mm20.launcher2.ui.launcher.search.common.list.ListResults
|
||||
import kotlin.math.min
|
||||
|
||||
fun LazyGridScope.ShortcutResults(
|
||||
fun LazyListScope.ShortcutResults(
|
||||
shortcuts: List<AppShortcut>,
|
||||
missingPermission: Boolean,
|
||||
onPermissionRequest: () -> Unit,
|
||||
|
||||
@@ -11,8 +11,6 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -41,7 +39,7 @@ import de.mm20.launcher2.unitconverter.Dimension
|
||||
import java.util.Date
|
||||
import kotlin.math.min
|
||||
|
||||
fun LazyGridScope.UnitConverterResults(
|
||||
fun LazyListScope.UnitConverterResults(
|
||||
converters: List<UnitConverter>,
|
||||
truncate: Boolean,
|
||||
onShowAll: () -> Unit,
|
||||
@@ -51,9 +49,6 @@ fun LazyGridScope.UnitConverterResults(
|
||||
val converter = converters.first()
|
||||
item(
|
||||
key = "converter-header",
|
||||
span = {
|
||||
GridItemSpan(maxLineSpan)
|
||||
}
|
||||
) {
|
||||
ListItemSurface(
|
||||
isFirst = true,
|
||||
@@ -134,10 +129,7 @@ fun LazyGridScope.UnitConverterResults(
|
||||
val count = if (truncate) min(5, converter.values.size) else converter.values.size
|
||||
items(
|
||||
count,
|
||||
key = { "converter-${converter.values[it].symbol}" },
|
||||
span = {
|
||||
GridItemSpan(maxLineSpan)
|
||||
}
|
||||
key = { "converter-${converter.values[it].symbol}" }
|
||||
) {
|
||||
val value = converter.values[it]
|
||||
ListItemSurface(
|
||||
@@ -201,10 +193,7 @@ fun LazyGridScope.UnitConverterResults(
|
||||
}
|
||||
if (truncate && converter.values.size > 5) {
|
||||
item(
|
||||
key = "converter-footer",
|
||||
span = {
|
||||
GridItemSpan(maxLineSpan)
|
||||
}
|
||||
key = "converter-footer"
|
||||
) {
|
||||
ListItemSurface(
|
||||
isLast = true,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package de.mm20.launcher2.ui.launcher.search.website
|
||||
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import de.mm20.launcher2.search.Website
|
||||
import de.mm20.launcher2.ui.launcher.search.common.list.ListItem
|
||||
import de.mm20.launcher2.ui.launcher.search.common.list.ListResults
|
||||
|
||||
fun LazyGridScope.WebsiteResults(
|
||||
fun LazyListScope.WebsiteResults(
|
||||
websites: List<Website>,
|
||||
selectedIndex: Int,
|
||||
onSelect: (Int) -> Unit,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package de.mm20.launcher2.ui.launcher.search.wikipedia
|
||||
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import de.mm20.launcher2.search.Article
|
||||
import de.mm20.launcher2.ui.launcher.search.common.list.ListItem
|
||||
import de.mm20.launcher2.ui.launcher.search.common.list.ListResults
|
||||
|
||||
fun LazyGridScope.ArticleResults(
|
||||
fun LazyListScope.ArticleResults(
|
||||
articles: List<Article>,
|
||||
selectedIndex: Int,
|
||||
onSelect: (Int) -> Unit,
|
||||
@@ -19,7 +19,7 @@ fun LazyGridScope.ArticleResults(
|
||||
ListItem(
|
||||
item = article,
|
||||
showDetails = showDetails,
|
||||
onShowDetails = { onSelect(if (it) index else -1) },
|
||||
onShowDetails = { onSelect(if(it) index else -1) },
|
||||
highlight = article.key == highlightedItem?.key,
|
||||
)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user