Skip to content

Commit 166879f

Browse files
committed
refactor: rename and expand DiscoveryPlatform UI resources
- Rename `DiscoveryPlatformIconMapper.kt` to `DiscoveryPlatformUiResources.kt` to reflect its broader purpose. - Add `DiscoveryPlatform.toLabel()` extension function to provide localized and formatted display names for platforms. - Update `HomeRoot` to use the new `toLabel()` function for platform selection UI. - Adjust platform selection chip styling in the home screen, including smaller icon sizes and refined padding/spacing.
1 parent a664e0a commit 166879f

2 files changed

Lines changed: 30 additions & 7 deletions

File tree

core/presentation/src/commonMain/kotlin/zed/rainxch/core/presentation/utils/DiscoveryPlatformIconMapper.kt renamed to core/presentation/src/commonMain/kotlin/zed/rainxch/core/presentation/utils/DiscoveryPlatformUiResources.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package zed.rainxch.core.presentation.utils
22

33
import androidx.compose.runtime.Composable
44
import androidx.compose.ui.graphics.vector.ImageVector
5+
import org.jetbrains.compose.resources.stringResource
56
import org.jetbrains.compose.resources.vectorResource
67
import zed.rainxch.core.domain.model.DiscoveryPlatform
78
import zed.rainxch.githubstore.core.presentation.res.*
@@ -34,3 +35,27 @@ fun DiscoveryPlatform.toIcons(): List<ImageVector> =
3435
listOf(vectorResource(Res.drawable.ic_platform_linux))
3536
}
3637
}
38+
39+
@Composable
40+
fun DiscoveryPlatform.toLabel(): String =
41+
when (this) {
42+
DiscoveryPlatform.All -> {
43+
stringResource(Res.string.category_all)
44+
}
45+
46+
DiscoveryPlatform.Android -> {
47+
"Android"
48+
}
49+
50+
DiscoveryPlatform.Macos -> {
51+
"macOS"
52+
}
53+
54+
DiscoveryPlatform.Windows -> {
55+
"Windows"
56+
}
57+
58+
DiscoveryPlatform.Linux -> {
59+
"Linux"
60+
}
61+
}

feature/home/presentation/src/commonMain/kotlin/zed/rainxch/home/presentation/HomeRoot.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import zed.rainxch.core.presentation.locals.LocalBottomNavigationLiquid
7070
import zed.rainxch.core.presentation.theme.GithubStoreTheme
7171
import zed.rainxch.core.presentation.utils.ObserveAsEvents
7272
import zed.rainxch.core.presentation.utils.toIcons
73+
import zed.rainxch.core.presentation.utils.toLabel
7374
import zed.rainxch.githubstore.core.presentation.res.*
7475
import zed.rainxch.home.domain.model.HomeCategory
7576
import zed.rainxch.home.presentation.components.LiquidGlassCategoryChips
@@ -429,15 +430,15 @@ private fun TopAppBar(
429430
.clip(RoundedCornerShape(16.dp))
430431
.background(MaterialTheme.colorScheme.surfaceContainerHigh)
431432
.clickable(onClick = onTogglePlatformPopup)
432-
.padding(vertical = 4.dp, horizontal = 12.dp),
433+
.padding(vertical = 4.dp, horizontal = 8.dp),
433434
verticalAlignment = Alignment.CenterVertically,
434-
horizontalArrangement = Arrangement.spacedBy(4.dp),
435+
horizontalArrangement = Arrangement.spacedBy(2.dp),
435436
) {
436437
icons.forEach { icon ->
437438
Icon(
438439
imageVector = icon,
439440
contentDescription = null,
440-
modifier = Modifier.size(24.dp),
441+
modifier = Modifier.size(18.dp),
441442
tint = MaterialTheme.colorScheme.onSurface,
442443
)
443444
}
@@ -501,10 +502,7 @@ private fun PlatformsPopup(
501502
}
502503

503504
Text(
504-
text =
505-
platform.name
506-
.lowercase()
507-
.replaceFirstChar { it.uppercase() },
505+
text = platform.toLabel(),
508506
style = MaterialTheme.typography.titleMedium,
509507
fontWeight = FontWeight.Medium,
510508
color = MaterialTheme.colorScheme.onBackground,

0 commit comments

Comments
 (0)