mirror of
https://github.com/kalarina-bit/Fogwave.git
synced 2026-11-22 08:06:09 +00:00
Remove genre cards and the player's back arrow; fill the whole screen with the player on tablets
This commit is contained in:
@@ -1,193 +0,0 @@
|
||||
package cc.skysparkle.fogwave.ui.components
|
||||
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Shadow
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.selected
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import cc.skysparkle.fogwave.R
|
||||
import cc.skysparkle.fogwave.data.model.Genre
|
||||
import cc.skysparkle.fogwave.data.model.RadioStation
|
||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||
|
||||
/** Two glow colors per card; null is the "All stations" card. */
|
||||
private fun genrePalette(genre: Genre?): Pair<Color, Color> = when (genre) {
|
||||
null -> Color(0xFF3466F6) to Color(0xFF8E5CFF)
|
||||
Genre.HITS -> Color(0xFFFF3D8B) to Color(0xFF7A3CFF)
|
||||
Genre.POP -> Color(0xFFB04DFF) to Color(0xFF3FA9FF)
|
||||
Genre.DANCE -> Color(0xFF00D1FF) to Color(0xFFB13CFF)
|
||||
Genre.OLDIES -> Color(0xFFFFB13D) to Color(0xFFD9488A)
|
||||
Genre.ROCK -> Color(0xFFFF5640) to Color(0xFF5B1FA8)
|
||||
Genre.EASY_LISTENING -> Color(0xFF3DDCB0) to Color(0xFF3466F6)
|
||||
Genre.LITHUANIAN -> Color(0xFFFDB913) to Color(0xFF006A44)
|
||||
Genre.NEWS_TALK -> Color(0xFF8FA6C8) to Color(0xFF2F4B8C)
|
||||
Genre.LATVIAN -> Color(0xFFC8102E) to Color(0xFFE8E8F0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Horizontal row of genre cards in the spirit of the design's smoky category art.
|
||||
* The first card shows every station; tapping the selected genre again clears the filter.
|
||||
*/
|
||||
@Composable
|
||||
fun GenreCarousel(
|
||||
stations: List<RadioStation>,
|
||||
selectedGenre: Genre?,
|
||||
onSelectGenre: (Genre?) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val genres = Genre.entries.filter { g -> stations.any { g in it.genres } }
|
||||
|
||||
LazyRow(
|
||||
modifier = modifier.testTag("genre_carousel"),
|
||||
contentPadding = PaddingValues(horizontal = 20.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
item(key = "all") {
|
||||
GenreCard(
|
||||
genre = null,
|
||||
title = stringResource(R.string.genre_all),
|
||||
count = stations.size,
|
||||
selected = selectedGenre == null,
|
||||
onClick = { onSelectGenre(null) }
|
||||
)
|
||||
}
|
||||
items(genres, key = { it.name }) { genre ->
|
||||
GenreCard(
|
||||
genre = genre,
|
||||
title = stringResource(genre.labelRes),
|
||||
count = stations.count { genre in it.genres },
|
||||
selected = selectedGenre == genre,
|
||||
onClick = { onSelectGenre(if (selectedGenre == genre) null else genre) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun GenreCard(
|
||||
genre: Genre?,
|
||||
title: String,
|
||||
count: Int,
|
||||
selected: Boolean,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
val colors = LocalGeoColors.current
|
||||
val (glowA, glowB) = genrePalette(genre)
|
||||
val borderWidth by animateDpAsState(if (selected) 2.dp else 1.dp, label = "genre_border")
|
||||
val dim by animateFloatAsState(if (selected) 1f else 0.82f, label = "genre_dim")
|
||||
val shape = RoundedCornerShape(20.dp)
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(width = 124.dp, height = 156.dp)
|
||||
.clip(shape)
|
||||
.border(borderWidth, if (selected) colors.primary else colors.outlineVariant, shape)
|
||||
.clickable(role = Role.Tab, onClick = onClick)
|
||||
.semantics { this.selected = selected }
|
||||
.testTag("genre_${genre?.name?.lowercase() ?: "all"}")
|
||||
) {
|
||||
Canvas(
|
||||
modifier = Modifier
|
||||
.matchParentSize()
|
||||
.graphicsLayer { alpha = dim }
|
||||
) {
|
||||
drawRect(Color(0xFF0B0D14))
|
||||
// Soft overlapping glows read as colored smoke on the dark card.
|
||||
drawCircle(
|
||||
brush = Brush.radialGradient(
|
||||
colors = listOf(glowA.copy(alpha = 0.9f), Color.Transparent),
|
||||
center = Offset(size.width * 0.25f, size.height * 0.3f),
|
||||
radius = size.width * 0.85f
|
||||
),
|
||||
radius = size.width * 0.85f,
|
||||
center = Offset(size.width * 0.25f, size.height * 0.3f)
|
||||
)
|
||||
drawCircle(
|
||||
brush = Brush.radialGradient(
|
||||
colors = listOf(glowB.copy(alpha = 0.85f), Color.Transparent),
|
||||
center = Offset(size.width * 0.85f, size.height * 0.62f),
|
||||
radius = size.width * 0.75f
|
||||
),
|
||||
radius = size.width * 0.75f,
|
||||
center = Offset(size.width * 0.85f, size.height * 0.62f)
|
||||
)
|
||||
drawCircle(
|
||||
brush = Brush.radialGradient(
|
||||
colors = listOf(Color.White.copy(alpha = 0.22f), Color.Transparent),
|
||||
center = Offset(size.width * 0.55f, size.height * 0.42f),
|
||||
radius = size.width * 0.35f
|
||||
),
|
||||
radius = size.width * 0.35f,
|
||||
center = Offset(size.width * 0.55f, size.height * 0.42f)
|
||||
)
|
||||
drawRect(
|
||||
brush = Brush.verticalGradient(
|
||||
colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.7f)),
|
||||
startY = size.height * 0.45f,
|
||||
endY = size.height
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomStart)
|
||||
.padding(12.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(2.dp)
|
||||
) {
|
||||
val shadow = Shadow(color = Color.Black.copy(alpha = 0.6f), blurRadius = 8f)
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleSmall.copy(
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 14.sp,
|
||||
lineHeight = 17.sp,
|
||||
color = Color.White,
|
||||
shadow = shadow
|
||||
),
|
||||
maxLines = 2,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
Text(
|
||||
text = pluralStringResource(R.plurals.station_count, count, count),
|
||||
style = MaterialTheme.typography.labelSmall.copy(
|
||||
fontSize = 11.sp,
|
||||
color = Color.White.copy(alpha = 0.75f),
|
||||
shadow = shadow
|
||||
),
|
||||
maxLines = 1
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
@@ -147,7 +148,6 @@ fun NowPlayingSheet(
|
||||
.align(Alignment.TopCenter)
|
||||
.then(sheetModifier)
|
||||
.offset { IntOffset(0, drag.offsetPx.roundToInt()) }
|
||||
.then(pageWidth)
|
||||
.fillMaxSize()
|
||||
.background(colors.background)
|
||||
// Swallow taps so nothing underneath reacts to them.
|
||||
@@ -180,7 +180,9 @@ fun NowPlayingSheet(
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.align(Alignment.TopCenter)
|
||||
.then(pageWidth)
|
||||
.fillMaxHeight()
|
||||
// The page scrolls; drags the content cannot use pull it down to close.
|
||||
.nestedScroll(drag.nestedScrollConnection)
|
||||
.verticalScroll(rememberScrollState())
|
||||
@@ -195,14 +197,7 @@ fun NowPlayingSheet(
|
||||
.padding(horizontal = 8.dp, vertical = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
IconButton(onClick = onClose, modifier = Modifier.testTag("np_close_btn")) {
|
||||
AppIcon(
|
||||
resId = R.drawable.ic_chevron_left,
|
||||
contentDescription = stringResource(R.string.back_content_desc),
|
||||
tint = colors.onSurface,
|
||||
size = 26.dp
|
||||
)
|
||||
}
|
||||
// Closed by swiping down or the system Back gesture.
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
IconButton(onClick = onOpenEqualizer, modifier = Modifier.testTag("np_equalizer_toggle")) {
|
||||
AppIcon(
|
||||
|
||||
@@ -57,14 +57,12 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import cc.skysparkle.fogwave.R
|
||||
import cc.skysparkle.fogwave.data.model.AppTab
|
||||
import cc.skysparkle.fogwave.data.model.Genre
|
||||
import cc.skysparkle.fogwave.data.model.RadioStation
|
||||
import cc.skysparkle.fogwave.player.PlayerState
|
||||
import cc.skysparkle.fogwave.ui.components.AboutPanel
|
||||
import cc.skysparkle.fogwave.ui.components.BatteryOptimizationDialog
|
||||
import cc.skysparkle.fogwave.ui.components.EqualizerSheet
|
||||
import cc.skysparkle.fogwave.ui.components.FavoritesPanel
|
||||
import cc.skysparkle.fogwave.ui.components.GenreCarousel
|
||||
import cc.skysparkle.fogwave.ui.components.HomeBackdrop
|
||||
import cc.skysparkle.fogwave.ui.components.MiniPlayer
|
||||
import cc.skysparkle.fogwave.ui.components.NavigationTabs
|
||||
@@ -88,7 +86,6 @@ fun HomeScreen(
|
||||
|
||||
var isSearchOpen by rememberSaveable { mutableStateOf(false) }
|
||||
var query by rememberSaveable { mutableStateOf("") }
|
||||
var selectedGenre by rememberSaveable { mutableStateOf<Genre?>(null) }
|
||||
|
||||
val favoriteStations = remember(uiState.stations, uiState.favorites) {
|
||||
uiState.stations.filter { it.id in uiState.favorites }
|
||||
@@ -177,8 +174,6 @@ fun HomeScreen(
|
||||
currentStation = uiState.currentStation,
|
||||
isPlaying = isPlaying,
|
||||
query = query.trim(),
|
||||
selectedGenre = selectedGenre,
|
||||
onSelectGenre = { selectedGenre = it },
|
||||
onSelectStation = { viewModel.onStationClick(it) },
|
||||
bottomContentPadding = scrollBottomPadding
|
||||
)
|
||||
@@ -314,7 +309,7 @@ fun HomeScreen(
|
||||
}
|
||||
}
|
||||
|
||||
/** Genre cards on top, then the (filtered) station list. */
|
||||
/** Station list, filtered by the search query. */
|
||||
@Composable
|
||||
private fun RadioTab(
|
||||
listState: LazyListState,
|
||||
@@ -322,44 +317,28 @@ private fun RadioTab(
|
||||
currentStation: RadioStation?,
|
||||
isPlaying: Boolean,
|
||||
query: String,
|
||||
selectedGenre: Genre?,
|
||||
onSelectGenre: (Genre?) -> Unit,
|
||||
onSelectStation: (RadioStation) -> Unit,
|
||||
bottomContentPadding: Dp
|
||||
) {
|
||||
val descriptions = stations.associate { it.id to stationDescription(it) }
|
||||
val visible = remember(stations, query, selectedGenre, descriptions) {
|
||||
val visible = remember(stations, query, descriptions) {
|
||||
stations.filter { station ->
|
||||
(selectedGenre == null || selectedGenre in station.genres) &&
|
||||
(query.isEmpty() ||
|
||||
station.name.contains(query, ignoreCase = true) ||
|
||||
descriptions[station.id].orEmpty().contains(query, ignoreCase = true))
|
||||
query.isEmpty() ||
|
||||
station.name.contains(query, ignoreCase = true) ||
|
||||
descriptions[station.id].orEmpty().contains(query, ignoreCase = true)
|
||||
}
|
||||
}
|
||||
|
||||
LazyColumn(
|
||||
state = listState,
|
||||
contentPadding = PaddingValues(top = 4.dp, bottom = bottomContentPadding),
|
||||
contentPadding = PaddingValues(top = 12.dp, bottom = bottomContentPadding),
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
if (query.isEmpty()) {
|
||||
item(key = "genres") {
|
||||
GenreCarousel(
|
||||
stations = stations,
|
||||
selectedGenre = selectedGenre,
|
||||
onSelectGenre = onSelectGenre,
|
||||
modifier = Modifier.padding(bottom = 22.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item(key = "header") {
|
||||
SectionHeader(
|
||||
title = when {
|
||||
query.isNotEmpty() -> stringResource(R.string.search_results_title)
|
||||
selectedGenre != null -> stringResource(selectedGenre.labelRes)
|
||||
else -> stringResource(R.string.stations_title)
|
||||
},
|
||||
title = stringResource(
|
||||
if (query.isNotEmpty()) R.string.search_results_title else R.string.stations_title
|
||||
),
|
||||
trailing = pluralStringResource(R.plurals.station_count, visible.size, visible.size),
|
||||
modifier = Modifier.padding(start = 20.dp, end = 20.dp, bottom = 8.dp)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user