fix(history): keep history actions visible while scrolling
This commit is contained in:
1 parent
938d920725
commit
98867a2407
1 file changed
+48
-42
@@ -4,9 +4,12 @@ import androidx.compose.foundation.background
|
|||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
@@ -42,52 +45,55 @@ fun SearchHistoryList(
|
|||||||
listState: LazyListState = rememberLazyListState(),
|
listState: LazyListState = rememberLazyListState(),
|
||||||
contentPadding: PaddingValues = PaddingValues(),
|
contentPadding: PaddingValues = PaddingValues(),
|
||||||
) {
|
) {
|
||||||
LazyColumn(
|
Column(modifier = modifier) {
|
||||||
modifier = modifier
|
Row(
|
||||||
.appTestTag("search_history"),
|
modifier = Modifier
|
||||||
state = listState,
|
.fillMaxWidth()
|
||||||
contentPadding = contentPadding,
|
.padding(vertical = Spacing.listItemVertical),
|
||||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
item(key = "history_header", contentType = "history_header") {
|
Text(
|
||||||
Row(
|
text = stringResource(R.string.recent_searches),
|
||||||
|
style = MaterialTheme.typography.titleSmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.weight(1f)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.clear_search_history),
|
||||||
|
style = MaterialTheme.typography.titleSmall,
|
||||||
|
color = MaterialTheme.colorScheme.primary,
|
||||||
|
softWrap = false,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.padding(end = 18.dp)
|
||||||
.padding(vertical = Spacing.listItemVertical),
|
.clip(CircleShape)
|
||||||
verticalAlignment = Alignment.CenterVertically
|
.background(MaterialTheme.colorScheme.surfaceContainerHighest)
|
||||||
) {
|
.appTestTag("clear_history")
|
||||||
Text(
|
.clickable { onClearAll() }
|
||||||
text = stringResource(R.string.recent_searches),
|
.padding(horizontal = 12.dp, vertical = 6.dp)
|
||||||
style = MaterialTheme.typography.titleSmall,
|
)
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
}
|
||||||
modifier = Modifier.weight(1f)
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
)
|
LazyColumn(
|
||||||
Text(
|
modifier = Modifier
|
||||||
text = stringResource(R.string.clear_search_history),
|
.fillMaxWidth()
|
||||||
style = MaterialTheme.typography.titleSmall,
|
.weight(1f, fill = false)
|
||||||
color = MaterialTheme.colorScheme.primary,
|
.appTestTag("search_history"),
|
||||||
softWrap = false,
|
state = listState,
|
||||||
modifier = Modifier
|
contentPadding = contentPadding,
|
||||||
.padding(end = 18.dp)
|
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
.clip(CircleShape)
|
) {
|
||||||
.background(MaterialTheme.colorScheme.surfaceContainerHighest)
|
items(
|
||||||
.appTestTag("clear_history")
|
items = history,
|
||||||
.clickable { onClearAll() }
|
key = { it },
|
||||||
.padding(horizontal = 12.dp, vertical = 6.dp)
|
contentType = { "history_entry" }
|
||||||
|
) { entry ->
|
||||||
|
SearchHistoryItem(
|
||||||
|
entry = entry,
|
||||||
|
onEntryClick = onEntryClick,
|
||||||
|
onEntryRemove = onEntryRemove
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
items(
|
|
||||||
items = history,
|
|
||||||
key = { it },
|
|
||||||
contentType = { "history_entry" }
|
|
||||||
) { entry ->
|
|
||||||
SearchHistoryItem(
|
|
||||||
entry = entry,
|
|
||||||
onEntryClick = onEntryClick,
|
|
||||||
onEntryRemove = onEntryRemove
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user