Skip to content

Commit de2e6a1

Browse files
committed
fix: white list items background
1 parent 0d037c1 commit de2e6a1

File tree

3 files changed

+127
-106
lines changed

3 files changed

+127
-106
lines changed

app/src/main/java/org/shirabox/app/ui/activity/search/SearchActivity.kt

Lines changed: 122 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import androidx.compose.animation.fadeIn
1616
import androidx.compose.animation.fadeOut
1717
import androidx.compose.foundation.clickable
1818
import androidx.compose.foundation.layout.Box
19+
import androidx.compose.foundation.layout.Column
1920
import androidx.compose.foundation.layout.fillMaxSize
2021
import androidx.compose.foundation.layout.fillMaxWidth
2122
import androidx.compose.foundation.layout.padding
@@ -25,12 +26,14 @@ import androidx.compose.material.icons.Icons
2526
import androidx.compose.material.icons.filled.Close
2627
import androidx.compose.material.icons.filled.History
2728
import androidx.compose.material.icons.filled.Search
28-
import androidx.compose.material3.CircularProgressIndicator
2929
import androidx.compose.material3.ExperimentalMaterial3Api
3030
import androidx.compose.material3.Icon
3131
import androidx.compose.material3.IconButton
32+
import androidx.compose.material3.LinearProgressIndicator
33+
import androidx.compose.material3.ListItemDefaults
3234
import androidx.compose.material3.MaterialTheme
3335
import androidx.compose.material3.SearchBar
36+
import androidx.compose.material3.SearchBarDefaults
3437
import androidx.compose.material3.Surface
3538
import androidx.compose.material3.Text
3639
import androidx.compose.runtime.Composable
@@ -47,7 +50,7 @@ import androidx.compose.ui.Alignment
4750
import androidx.compose.ui.Modifier
4851
import androidx.compose.ui.focus.FocusRequester
4952
import androidx.compose.ui.focus.focusRequester
50-
import androidx.compose.ui.graphics.StrokeCap
53+
import androidx.compose.ui.graphics.Color
5154
import androidx.compose.ui.platform.LocalContext
5255
import androidx.compose.ui.res.stringResource
5356
import androidx.compose.ui.text.font.FontWeight
@@ -141,116 +144,131 @@ fun SearchScreen() {
141144
queryText.value = text
142145
}
143146

144-
SearchBar(
145-
modifier = Modifier
146-
.fillMaxWidth()
147-
.focusRequester(focusRequester),
148-
query = text,
149-
onQueryChange = { text = it },
150-
onSearch = { searchHistory.add(text) },
151-
active = true,
152-
onActiveChange = {},
153-
placeholder = {
154-
Text(text = stringResource(id = R.string.search_by_name))
155-
},
156-
leadingIcon = {
157-
Icon(imageVector = Icons.Default.Search, contentDescription = "Search icon")
158-
},
159-
trailingIcon = {
160-
IconButton(onClick = {
161-
if (text.isNotEmpty()) {
162-
searchHistory.add(text)
163-
text = ""
164-
} else activity?.finish()
165-
}) {
166-
Icon(imageVector = Icons.Default.Close, contentDescription = "Close icon")
167-
}
168-
}) {
169-
170-
LazyColumn(
171-
horizontalAlignment = Alignment.CenterHorizontally,
172-
) {
173-
if (text.isEmpty()) {
174-
items(searchHistory) {
175-
if (it.isNotEmpty()) {
176-
androidx.compose.material3.ListItem(
177-
modifier = Modifier.clickable {
178-
text = it
179-
},
180-
headlineContent = {
181-
Text(it)
182-
},
183-
leadingContent = {
184-
Icon(imageVector = Icons.Default.History, contentDescription = null)
185-
},
186-
)
147+
Column {
148+
SearchBar(
149+
inputField = {
150+
SearchBarDefaults.InputField(
151+
query = text,
152+
onQueryChange = { text = it },
153+
onSearch = { searchHistory.add(text) },
154+
expanded = true,
155+
onExpandedChange = { },
156+
enabled = true,
157+
placeholder = {
158+
Text(text = stringResource(id = R.string.search_by_name))
159+
},
160+
leadingIcon = {
161+
Icon(imageVector = Icons.Default.Search, contentDescription = "Search icon")
162+
},
163+
trailingIcon = {
164+
IconButton(onClick = {
165+
if (text.isNotEmpty()) {
166+
searchHistory.add(text)
167+
text = ""
168+
} else activity?.finish()
169+
}) {
170+
Icon(imageVector = Icons.Default.Close, contentDescription = "Close icon")
171+
}
172+
},
173+
interactionSource = null,
174+
)
175+
},
176+
expanded = true,
177+
onExpandedChange = {},
178+
modifier = Modifier
179+
.fillMaxWidth()
180+
.focusRequester(focusRequester),
181+
shape = SearchBarDefaults.inputFieldShape,
182+
tonalElevation = SearchBarDefaults.TonalElevation,
183+
shadowElevation = SearchBarDefaults.ShadowElevation,
184+
windowInsets = SearchBarDefaults.windowInsets,
185+
content = {
186+
LazyColumn(
187+
horizontalAlignment = Alignment.CenterHorizontally,
188+
) {
189+
if (text.isEmpty()) {
190+
items(searchHistory) {
191+
if (it.isNotEmpty()) {
192+
androidx.compose.material3.ListItem(
193+
modifier = Modifier.clickable {
194+
text = it
195+
},
196+
headlineContent = {
197+
Text(it)
198+
},
199+
leadingContent = {
200+
Icon(
201+
imageVector = Icons.Default.History,
202+
contentDescription = null
203+
)
204+
},
205+
colors = ListItemDefaults.colors(containerColor = Color.Transparent)
206+
)
207+
}
208+
}
209+
return@LazyColumn
187210
}
188-
}
189-
return@LazyColumn
190-
}
191211

192-
item {
193-
if(showProgressIndicator && !noResultsState.value) {
194-
Box(
195-
modifier = Modifier
196-
.fillMaxWidth()
197-
.padding(32.dp),
198-
contentAlignment = Alignment.Center
199-
) {
200-
CircularProgressIndicator(
201-
strokeCap = StrokeCap.Round
202-
)
212+
item {
213+
AnimatedVisibility(
214+
visible = showProgressIndicator && !noResultsState.value
215+
) {
216+
LinearProgressIndicator(
217+
modifier = Modifier.fillMaxWidth()
218+
)
219+
}
203220
}
204-
}
205-
}
206221

207-
item {
208-
AnimatedVisibility(
209-
visible = noResultsState.value,
210-
enter = fadeIn(),
211-
exit = fadeOut()
212-
) {
213-
Box(
214-
modifier = Modifier
215-
.fillMaxWidth()
216-
.padding(32.dp),
217-
contentAlignment = Alignment.Center
218-
) {
219-
DespondencyEmoticon(text = stringResource(id = R.string.nothing_found))
222+
item {
223+
AnimatedVisibility(
224+
visible = noResultsState.value,
225+
enter = fadeIn(),
226+
exit = fadeOut()
227+
) {
228+
Box(
229+
modifier = Modifier
230+
.fillMaxWidth()
231+
.padding(32.dp),
232+
contentAlignment = Alignment.Center
233+
) {
234+
DespondencyEmoticon(text = stringResource(id = R.string.nothing_found))
235+
}
236+
}
220237
}
221-
}
222-
}
223238

224-
items(resultsList) {
225-
AnimatedVisibility(
226-
visible = !showProgressIndicator,
227-
enter = fadeIn(
228-
animationSpec = tween(300, easing = LinearEasing)
229-
)
230-
) {
231-
ListItem(
232-
headlineContent = {
233-
Text(
234-
text = it.name.ifBlank { it.enName }, fontWeight = FontWeight.Bold
239+
items(resultsList) {
240+
AnimatedVisibility(
241+
visible = !showProgressIndicator,
242+
enter = fadeIn(
243+
animationSpec = tween(300, easing = LinearEasing)
235244
)
236-
},
237-
supportingString = "${it.releaseYear}, ${
238-
ValuesHelper.decodeKind(
239-
it.kind,
240-
context
241-
)
242-
}",
243-
coverImage = it.image
244-
) {
245-
context.startActivity(Intent(
246-
context, ResourceActivity::class.java
247-
).apply {
248-
putExtra("id", it.shikimoriId)
249-
putExtra("type", it.type)
250-
})
245+
) {
246+
ListItem(
247+
headlineContent = {
248+
Text(
249+
text = it.name.ifBlank { it.enName },
250+
fontWeight = FontWeight.Bold
251+
)
252+
},
253+
supportingString = "${it.releaseYear}, ${
254+
ValuesHelper.decodeKind(
255+
it.kind,
256+
context
257+
)
258+
}",
259+
coverImage = it.image,
260+
) {
261+
context.startActivity(Intent(
262+
context, ResourceActivity::class.java
263+
).apply {
264+
putExtra("id", it.shikimoriId)
265+
putExtra("type", it.type)
266+
})
267+
}
268+
}
251269
}
252270
}
253-
}
254-
}
271+
},
272+
)
255273
}
256274
}

app/src/main/java/org/shirabox/app/ui/activity/settings/category/playback/Dialogs.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import androidx.compose.material.icons.outlined.Sd
1313
import androidx.compose.material3.AlertDialog
1414
import androidx.compose.material3.Icon
1515
import androidx.compose.material3.ListItem
16+
import androidx.compose.material3.ListItemDefaults
1617
import androidx.compose.material3.MaterialTheme
1718
import androidx.compose.material3.OutlinedTextField
1819
import androidx.compose.material3.RadioButton
@@ -150,7 +151,8 @@ private fun QualityListItem(
150151
RadioButton(
151152
selected = selected,
152153
onClick = { onClick() })
153-
}
154+
},
155+
colors = ListItemDefaults.colors(containerColor = Color.Transparent)
154156
)
155157
}
156158

app/src/main/java/org/shirabox/app/ui/component/general/ListItem.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ fun ListItem(
8686
contentDescription = stringResource(id = R.string.history),
8787
contentScale = ContentScale.Crop
8888
)
89-
}
89+
},
90+
colors = ListItemDefaults.colors(containerColor = Color.Transparent)
9091
)
9192
}
9293

0 commit comments

Comments
 (0)