Skip to content

Native Android client for Spotify, built with Jetpack Compose

Merge PR #170: the Classic search field's hint in the theme's muted colour

kota-zo6b330edfeee4
diff --cc base/app/src/main/java/com/music/spotui/ui/screens/SearchScreen.kt
index e538eb64,388a9c8d..69e2b099
--- a/base/app/src/main/java/com/music/spotui/ui/screens/SearchScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/SearchScreen.kt
@@@ -872,79 -881,52 +873,80 @@@ fun SearchStickyBar
// The field is always attached to a requester, so the clear button can put the cursor back in it.
val ownFocus = remember { androidx.compose.ui.focus.FocusRequester() }
val fieldFocus = focusRequester ?: ownFocus
- Row(verticalAlignment = Alignment.CenterVertically,
+ val context = LocalContext.current
+ Row(
+ verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
- .padding(10.dp)
- .clip(RoundedCornerShape(10.dp))
- .height(55.dp)
- .background(tone(0xFF2A2A2A))
- .padding(10.dp, 0.dp)
- ){
- Icon(
- painterResource(id = R.drawable.ic_search_big),
- tint = AppMuted,
- contentDescription = "")
-
- TextField(
- enabled = true,
+ .padding(10.dp),
+ ) {
+ Row(verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
- .focusRequester(fieldFocus)
- .onFocusChanged { onFocusChange(it.isFocused) },
- value = text,
- textStyle = TextStyle.Default.copy(fontSize = 16.sp, color = AppText, fontWeight = FontWeight(500)),
- colors = TextFieldDefaults.colors(
- unfocusedContainerColor = Color.Transparent,
- disabledContainerColor = Color.Transparent,
- focusedContainerColor = Color.Transparent,
- disabledIndicatorColor = Color.Transparent,
- focusedIndicatorColor = Color.Transparent,
- unfocusedIndicatorColor = Color.Transparent,
- cursorColor = AppAccent
-
- ),
- singleLine = true,
- onValueChange = onTextChange,
- placeholder = {
- Text(
- textAlign = TextAlign.Center,
- color = AppMuted,
- fontWeight = FontWeight.Bold,
- text = stringResource(R.string.search_header_field_hint)
+ .weight(1f)
+ .clip(RoundedCornerShape(10.dp))
+ .height(55.dp)
+ .background(tone(0xFF2A2A2A))
+ .padding(10.dp, 0.dp)
+ ){
+ Icon(
+ painterResource(id = R.drawable.ic_search_big),
+ tint = AppText,
+ contentDescription = "")
+
+ TextField(
+ enabled = true,
+ // The rest of the bar, so the clear button sits at its end and not after a 280 dp field.
+ modifier = Modifier
+ .weight(1f)
+ .focusRequester(fieldFocus)
+ .onFocusChanged { onFocusChange(it.isFocused) },
+ value = text,
+ textStyle = TextStyle.Default.copy(fontSize = 16.sp, color = AppText, fontWeight = FontWeight(500)),
+ colors = TextFieldDefaults.colors(
+ unfocusedContainerColor = Color.Transparent,
+ disabledContainerColor = Color.Transparent,
+ focusedContainerColor = Color.Transparent,
+ disabledIndicatorColor = Color.Transparent,
+ focusedIndicatorColor = Color.Transparent,
+ unfocusedIndicatorColor = Color.Transparent,
+ focusedTextColor = AppText,
+ unfocusedTextColor = AppText,
+ cursorColor = AppPalette
+
+ ),
+ singleLine = true,
+ onValueChange = onTextChange,
+ placeholder = {
+ Text(
- textAlign = TextAlign.Center,
++ textAlign = TextAlign.Center,
++ color = AppMuted,
+ fontWeight = FontWeight.Bold,
+ text = stringResource(R.string.search_header_field_hint)
- )
- },
- trailingIcon = if (text.isEmpty()) null else {
- { SearchClearButton(fieldFocus, AppMuted) { onTextChange("") } }
- },
- )
+ )
+ },
+ trailingIcon = if (text.isEmpty()) null else {
+ { SearchClearButton(fieldFocus, AppText) { onTextChange("") } }
+ },
+ )
+ }
+ Spacer(Modifier.width(10.dp))
+ // Voice search: the Google app's own "Search with your voice" for music, one tap away.
+ Box(
+ contentAlignment = Alignment.Center,
+ modifier = Modifier
+ .size(55.dp)
+ .clip(CircleShape)
+ .background(tone(0xFF2A2A2A))
+ .pressable(0.9f) { launchVoiceSearch(context) },
+ ) {
+ Icon(
+ imageVector = Icons.Outlined.Mic,
+ contentDescription = stringResource(R.string.voice_search),
+ tint = AppText,
+ modifier = Modifier.size(24.dp),
+ )
+ }
}
}