@@ -30,15 +30,16 @@ import androidx.compose.material3.MaterialTheme
3030import androidx.compose.material3.Surface
3131import androidx.compose.material3.Text
3232import androidx.compose.runtime.Composable
33+ import androidx.compose.runtime.derivedStateOf
3334import androidx.compose.runtime.getValue
35+ import androidx.compose.runtime.remember
3436import androidx.compose.ui.Alignment
3537import androidx.compose.ui.Modifier
3638import androidx.compose.ui.draw.clip
3739import androidx.compose.ui.graphics.StrokeCap
3840import androidx.compose.ui.text.font.FontWeight
3941import androidx.compose.ui.unit.dp
4042import com.skydoves.landscapist.coil3.CoilImage
41- import zed.rainxch.githubstore.core.presentation.res.*
4243import org.jetbrains.compose.resources.stringResource
4344import zed.rainxch.core.domain.model.GithubRelease
4445import zed.rainxch.core.domain.model.GithubRepoSummary
@@ -48,6 +49,13 @@ import zed.rainxch.core.presentation.components.ForkBadge
4849import zed.rainxch.core.presentation.components.PlatformChip
4950import zed.rainxch.core.presentation.utils.formatReleasedAt
5051import zed.rainxch.details.presentation.model.DownloadStage
52+ import zed.rainxch.githubstore.core.presentation.res.Res
53+ import zed.rainxch.githubstore.core.presentation.res.by_author
54+ import zed.rainxch.githubstore.core.presentation.res.installed
55+ import zed.rainxch.githubstore.core.presentation.res.installed_version
56+ import zed.rainxch.githubstore.core.presentation.res.no_description
57+ import zed.rainxch.githubstore.core.presentation.res.pending_install
58+ import zed.rainxch.githubstore.core.presentation.res.update_available
5159
5260@OptIn(ExperimentalMaterial3ExpressiveApi ::class , ExperimentalLayoutApi ::class )
5361@Composable
@@ -66,6 +74,12 @@ fun AppHeader(
6674 label = " avatar_progress_animation"
6775 )
6876
77+ val supportedPlatforms by remember(release?.assets) {
78+ derivedStateOf {
79+ derivePlatformsFromAssets(release)
80+ }
81+ }
82+
6983 Column (
7084 modifier = modifier.fillMaxWidth()
7185 ) {
@@ -128,7 +142,7 @@ fun AppHeader(
128142 )
129143 }
130144
131- else -> { }
145+ else -> {}
132146 }
133147 }
134148 }
@@ -151,16 +165,17 @@ fun AppHeader(
151165 modifier = Modifier .weight(1f , fill = false )
152166 )
153167
154- if (repository.isFork) {
155- ForkBadge ()
156- }
157- }
158-
159- Text (
160- text = stringResource(Res .string.by_author, author?.login.toString()),
161- style = MaterialTheme .typography.bodyMedium,
162- color = MaterialTheme .colorScheme.primary,
163- )
168+ if (repository.isFork) {
169+ ForkBadge ()
170+ }
171+ }
172+ author?.login?.let { author ->
173+ Text (
174+ text = stringResource(Res .string.by_author, author),
175+ style = MaterialTheme .typography.bodyMedium,
176+ color = MaterialTheme .colorScheme.primary,
177+ )
178+ }
164179
165180 Spacer (Modifier .height(8 .dp))
166181
@@ -208,15 +223,14 @@ fun AppHeader(
208223 }
209224 }
210225
211- val platforms = derivePlatformsFromAssets(release)
212- if (platforms.isNotEmpty()) {
226+ if (supportedPlatforms.isNotEmpty()) {
213227 Spacer (Modifier .height(12 .dp))
214228
215229 FlowRow (
216230 horizontalArrangement = Arrangement .spacedBy(6 .dp),
217231 verticalArrangement = Arrangement .spacedBy(6 .dp)
218232 ) {
219- platforms .forEach { platform ->
233+ supportedPlatforms .forEach { platform ->
220234 PlatformChip (platform = platform)
221235 }
222236 }
@@ -235,12 +249,18 @@ fun AppHeader(
235249private fun derivePlatformsFromAssets (release : GithubRelease ? ): List <String > {
236250 if (release == null ) return emptyList()
237251 val names = release.assets.map { it.name.lowercase() }
238- val platforms = mutableListOf<String >()
239- if (names.any { it.endsWith(" .apk" ) }) platforms.add(" Android" )
240- if (names.any { it.endsWith(" .exe" ) || it.endsWith(" .msi" ) }) platforms.add(" Windows" )
241- if (names.any { it.endsWith(" .dmg" ) || it.endsWith(" .pkg" ) }) platforms.add(" macOS" )
242- if (names.any { it.endsWith(" .appimage" ) || it.endsWith(" .deb" ) || it.endsWith(" .rpm" ) }) platforms.add(" Linux" )
243- return platforms
252+ return buildList {
253+ when {
254+ names.any { it.endsWith(" .apk" ) } -> add(" Android" )
255+ names.any { it.endsWith(" .exe" ) || it.endsWith(" .msi" ) } -> add(" Windows" )
256+ names.any { it.endsWith(" .dmg" ) || it.endsWith(" .pkg" ) } -> add(" macOS" )
257+ names.any {
258+ it.endsWith(" .appimage" ) ||
259+ it.endsWith(" .deb" ) ||
260+ it.endsWith(" .rpm" )
261+ } -> add(" Linux" )
262+ }
263+ }
244264}
245265
246266@Composable
0 commit comments