mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 21:35:59 +00:00
feat(): Achievements UI for GOG & Epic game details page (#641)
* feat(): gog & epic achievements UI * feat(): AI-generated translations - Please get review for these * build_local: run on macOS hosts with Docker Desktop Two steps of tools/build_local.sh failed on a Mac: - The uruntime staging runs on the host, where macOS's BSD install has no -D, so `install -Dm644` stopped with "No such file or directory". The folders are now made first and the files copied with install -m644. - Inside the cross-compile container, Docker Desktop's VirtioFS share now and then refuses the chmod that install -m makes (EPERM, on a different file each run, e.g. "setting permissions for .../droiddeck-esync: Operation not permitted"). The overlay and desktop scripts are copied with a plain write instead. Nothing is lost: the APK keeps no file modes, and the app sets them when it stages the runtime. * feat(): adjust the store * feat(): store-achievements adjustment for UI * feat(): translation fixes and separate hidden achievements * Show all achievements directly on store game details --------- Co-authored-by: xXJsonDeruloXx <danielhimebauch@gmail.com>
This commit is contained in:
1 parent
3b99f2d990
commit
d9b152c7d2
21 files changed
+922
-15
No files matched your search
@@ -223,6 +223,10 @@ class DrawerActions(
|
||||
val onHardwareKeyboard: () -> Unit,
|
||||
val onSteamMenu: (() -> Unit)?,
|
||||
val onQam: (() -> Unit)?,
|
||||
/** Null hides the achievements row. */
|
||||
val onAchievements: (() -> Unit)? = null,
|
||||
/** (unlocked, total), or null when unknown. */
|
||||
val achievementsProgress: Pair<Int, Int>? = null,
|
||||
val onOsc: (String) -> Unit,
|
||||
/** Edits the Steam touch layout of the game in front, when Steam's controls are up. */
|
||||
val onEditSteamTouch: (() -> Unit)? = null,
|
||||
@@ -409,6 +413,11 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
}
|
||||
StopSessionButton(modifier = focus.track(page, "stop").onGloballyPositioned { stopCoords = it }) { host.open = null; confirmStop = true }
|
||||
}
|
||||
a.onAchievements?.let { show ->
|
||||
DrawerAchievementsRow(a.achievementsProgress, Modifier.padding(top = if (short) 6.dp else 10.dp).then(focus.track(page, "achievements"))) {
|
||||
host.open = null; show()
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
||||
@@ -0,0 +1,381 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.LocalIndication
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.focusable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.interaction.collectIsFocusedAsState
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
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
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.EmojiEvents
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.withFrameNanos
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import coil.compose.AsyncImage
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.stores.StoreAchievements
|
||||
import com.droiddeck.launcher.stores.StoreAchievements.Achievement
|
||||
import com.droiddeck.launcher.stores.StoreAchievements.Reason
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.text.DateFormat
|
||||
import java.util.Date
|
||||
|
||||
private val TrophyGold = Color(0xFFF5C542)
|
||||
|
||||
internal class AchievementsState(val list: List<Achievement>?, val reason: Reason?, val reading: Boolean) {
|
||||
val done: Int get() = list?.count { it.unlocked } ?: 0
|
||||
val all: Boolean get() = !list.isNullOrEmpty() && list.all { it.unlocked }
|
||||
|
||||
companion object { val READING = AchievementsState(null, null, true) }
|
||||
}
|
||||
|
||||
/** The cached list at once, then the store's answer (the cache stays if the store fails). */
|
||||
@Composable
|
||||
internal fun rememberAchievements(game: StoreAchievements.Game?): AchievementsState? {
|
||||
val ctx = LocalContext.current.applicationContext
|
||||
var state by remember(game) { mutableStateOf(if (game == null) null else AchievementsState.READING) }
|
||||
LaunchedEffect(game) {
|
||||
if (game == null) return@LaunchedEffect
|
||||
val source = StoreAchievements.forSource(game.source) ?: return@LaunchedEffect
|
||||
val cached = withContext(Dispatchers.IO) { source.cached(ctx, game) }
|
||||
if (cached != null) state = AchievementsState(cached, null, true)
|
||||
state = when (val r = withContext(Dispatchers.IO) { source.fetch(ctx, game) }) {
|
||||
is StoreAchievements.Result.Found -> AchievementsState(r.list, null, false)
|
||||
is StoreAchievements.Result.Failed -> AchievementsState(cached, r.reason, false)
|
||||
}
|
||||
}
|
||||
return state
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun achievementsNote(state: AchievementsState, label: String): String? = when {
|
||||
!state.list.isNullOrEmpty() -> null
|
||||
state.reading -> stringResource(R.string.achievements_reading)
|
||||
state.reason == Reason.SIGNED_OUT -> stringResource(R.string.achievements_signed_out, label)
|
||||
state.reason == Reason.UNREACHABLE -> stringResource(R.string.achievements_unreachable, label)
|
||||
else -> stringResource(R.string.achievements_none, label)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun Trophy(size: Dp = 18.dp, modifier: Modifier = Modifier) {
|
||||
Icon(Icons.Filled.EmojiEvents, stringResource(R.string.achievements_all), modifier.size(size), tint = TrophyGold)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun AchievementsProgress(state: AchievementsState, compact: Boolean = false) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val list = state.list ?: return
|
||||
if (list.isEmpty()) return
|
||||
Column(verticalArrangement = Arrangement.spacedBy(if (compact) 6.dp else 8.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Text(stringResource(R.string.achievements_count, state.done, list.size), fontSize = 13.sp, color = colors.onSurfaceVariant)
|
||||
if (state.all) Trophy(16.dp)
|
||||
}
|
||||
LinearProgressIndicator(
|
||||
progress = { state.done / list.size.toFloat() },
|
||||
color = pal.signal, trackColor = pal.line,
|
||||
modifier = Modifier.fillMaxWidth().height(4.dp).clip(RoundedCornerShape(2.dp)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AchievementGroupLabel(label: String) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().padding(top = 6.dp, bottom = 2.dp)) {
|
||||
Text(label.uppercase(), fontSize = 11.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.2.sp, color = colors.onSurfaceVariant)
|
||||
Box(Modifier.weight(1f).height(1.dp).background(pal.line))
|
||||
}
|
||||
}
|
||||
|
||||
/** Unlocked (newest first), locked, then hidden ones not yet unlocked. */
|
||||
private fun groups(list: List<Achievement>): List<Pair<Int, List<Achievement>>> = listOf(
|
||||
R.string.achievements_group_unlocked to list.filter { it.unlocked }.sortedByDescending { it.unlockedAt },
|
||||
R.string.achievements_group_locked to list.filter { !it.unlocked && !it.hidden },
|
||||
R.string.achievements_group_hidden to list.filter { !it.unlocked && it.hidden },
|
||||
).filter { it.second.isNotEmpty() }
|
||||
|
||||
/** Focusable so the pad can scroll the list. */
|
||||
@Composable
|
||||
internal fun AchievementRow(a: Achievement, compact: Boolean, modifier: Modifier = Modifier) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
val hot = interaction.collectIsFocusedAsState().value
|
||||
val shape = RoundedCornerShape(12.dp)
|
||||
val secret = a.hidden && !a.unlocked
|
||||
val icon = if (compact) 36.dp else 48.dp
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = modifier.fillMaxWidth().clip(shape)
|
||||
.background(if (hot) pal.signal.copy(alpha = 0.10f) else colors.surface)
|
||||
.glideBorder(hot, shape, pal.signal, pal.line)
|
||||
.focusable(interactionSource = interaction)
|
||||
.padding(if (compact) 8.dp else 10.dp),
|
||||
) {
|
||||
Box(Modifier.size(icon).clip(RoundedCornerShape(8.dp)).background(pal.surfaceVariant)) {
|
||||
val url = if (a.unlocked) a.icon else a.iconLocked ?: a.icon
|
||||
if (url != null) AsyncImage(
|
||||
model = url, contentDescription = null, contentScale = ContentScale.Crop,
|
||||
modifier = Modifier.fillMaxSize().alpha(if (a.unlocked) 1f else 0.55f),
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.width(12.dp))
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(
|
||||
if (secret) stringResource(R.string.achievements_hidden) else a.name,
|
||||
fontSize = if (compact) 14.sp else 15.sp, fontWeight = FontWeight.SemiBold,
|
||||
color = if (a.unlocked) colors.onBackground else colors.onSurfaceVariant,
|
||||
maxLines = if (compact) 1 else 2, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
val desc = if (secret) stringResource(R.string.achievements_hidden_detail) else a.description
|
||||
if (desc.isNotEmpty()) Text(
|
||||
desc, fontSize = if (compact) 12.sp else 13.sp, lineHeight = if (compact) 16.sp else 18.sp,
|
||||
color = colors.onSurfaceVariant, maxLines = if (compact) 1 else 3, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
if (a.unlocked && a.unlockedAt > 0) {
|
||||
Spacer(Modifier.width(10.dp))
|
||||
Text(
|
||||
DateFormat.getDateInstance(DateFormat.MEDIUM).format(Date(a.unlockedAt * 1000)),
|
||||
fontSize = 12.sp, fontWeight = FontWeight.Medium, color = pal.signal,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun StoreAchievementsSection(game: StoreAchievements.Game) {
|
||||
val label = StoreAchievements.forSource(game.source)?.label ?: return
|
||||
StoreAchievementsSectionContent(label, rememberAchievements(game) ?: return)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun StoreAchievementsSectionContent(label: String, state: AchievementsState) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val list = state.list
|
||||
// Hidden for games without achievements.
|
||||
if (list.isNullOrEmpty() && !state.reading && state.reason != Reason.SIGNED_OUT && state.reason != Reason.UNREACHABLE) return
|
||||
val narrow = LocalNarrowPane.current
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().padding(top = 18.dp)) {
|
||||
Text(stringResource(R.string.achievements_title), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = colors.onBackground)
|
||||
achievementsNote(state, label)?.let { Text(it, fontSize = 13.sp, color = colors.onSurfaceVariant) }
|
||||
if (!list.isNullOrEmpty()) {
|
||||
AchievementsProgress(state)
|
||||
for ((label, group) in groups(list)) {
|
||||
AchievementGroupLabel(stringResource(label, group.size))
|
||||
for (a in group) AchievementRow(a, compact = narrow)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun LazyListScope.achievementItems(list: List<Achievement>, compact: Boolean, first: FocusRequester) {
|
||||
var index = 0
|
||||
for ((label, group) in groups(list)) {
|
||||
item(key = "group-$label") { AchievementGroupLabel(stringResource(label, group.size)) }
|
||||
val offset = index
|
||||
itemsIndexed(group, key = { _, a -> "a-" + a.id }) { i, a ->
|
||||
AchievementRow(a, compact, if (offset + i == 0) Modifier.focusRequester(first) else Modifier)
|
||||
}
|
||||
index += group.size
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun SessionAchievements(game: StoreAchievements.Game, title: String?, onClose: () -> Unit) {
|
||||
val label = StoreAchievements.forSource(game.source)?.label.orEmpty()
|
||||
SessionAchievementsPanel(label, rememberAchievements(game) ?: AchievementsState.READING, title, onClose)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun SessionAchievementsPanel(label: String, state: AchievementsState, title: String?, onClose: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
BackHandler(onBack = onClose)
|
||||
BoxWithConstraints(
|
||||
Modifier.fillMaxSize().background(Color.Black.copy(alpha = 0.45f))
|
||||
.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null, onClick = onClose),
|
||||
contentAlignment = Alignment.CenterEnd,
|
||||
) {
|
||||
val short = maxHeight < 440.dp
|
||||
Column(
|
||||
Modifier.fillMaxHeight().width(minOf(420.dp, maxWidth * 0.92f))
|
||||
.background(pal.background.copy(alpha = 0.97f))
|
||||
.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null) {}
|
||||
.controllerBack(onClose)
|
||||
.padding(if (short) 12.dp else 16.dp),
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(stringResource(R.string.achievements_title), fontSize = if (short) 18.sp else 20.sp, fontWeight = FontWeight.Bold, color = colors.onBackground)
|
||||
if (title != null) Text(title, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
state.list?.takeIf { it.isNotEmpty() }?.let { list ->
|
||||
if (state.all) Trophy(20.dp, Modifier.padding(end = 6.dp))
|
||||
Text(stringResource(R.string.achievements_count_short, state.done, list.size), fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = pal.signal)
|
||||
}
|
||||
}
|
||||
val list = state.list
|
||||
if (list.isNullOrEmpty()) {
|
||||
Text(achievementsNote(state, label).orEmpty(), fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 14.dp))
|
||||
} else {
|
||||
LinearProgressIndicator(
|
||||
progress = { state.done / list.size.toFloat() },
|
||||
color = pal.signal, trackColor = pal.line,
|
||||
modifier = Modifier.padding(top = if (short) 6.dp else 10.dp).fillMaxWidth().height(4.dp).clip(RoundedCornerShape(2.dp)),
|
||||
)
|
||||
val first = remember { FocusRequester() }
|
||||
LazyColumn(
|
||||
Modifier.weight(1f).padding(top = 6.dp),
|
||||
contentPadding = PaddingValues(vertical = 6.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
) { achievementItems(list, short, first) }
|
||||
LaunchedEffect(list.isNotEmpty()) {
|
||||
withFrameNanos {} // rows lay out a frame after composition
|
||||
runCatching { first.requestFocus() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** [progress]: (unlocked, total), or null when unknown. */
|
||||
@Composable
|
||||
internal fun DrawerAchievementsRow(progress: Pair<Int, Int>?, modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
val hot = interaction.collectIsFocusedAsState().value
|
||||
val shape = RoundedCornerShape(12.dp)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
modifier = modifier.fillMaxWidth().height(44.dp).clip(shape)
|
||||
.background(if (hot) pal.signal.copy(alpha = 0.14f) else colors.surface)
|
||||
.glideBorder(hot, shape, pal.signal, pal.line)
|
||||
.clickable(interactionSource = interaction, indication = LocalIndication.current, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick)
|
||||
.padding(horizontal = 12.dp),
|
||||
) {
|
||||
val all = progress != null && progress.second > 0 && progress.first == progress.second
|
||||
Icon(Icons.Filled.EmojiEvents, null, tint = if (all) TrophyGold else if (hot) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(20.dp))
|
||||
Text(stringResource(R.string.achievements_title), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, modifier = Modifier.weight(1f))
|
||||
if (progress != null && progress.second > 0) {
|
||||
Text(stringResource(R.string.achievements_count_short, progress.first, progress.second), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = pal.signal)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private val previewList = listOf(
|
||||
Achievement("first", "First Steps", "Finish the tutorial.", hidden = false, unlocked = true, unlockedAt = 1_759_000_000, icon = null, iconLocked = null),
|
||||
Achievement("boss", "Giant Slayer", "Defeat the warden of the old keep without taking damage.", hidden = false, unlocked = true, unlockedAt = 1_760_100_000, icon = null, iconLocked = null),
|
||||
Achievement("collector", "Collector", "Find every relic in the valley.", hidden = false, unlocked = false, unlockedAt = 0, icon = null, iconLocked = null),
|
||||
Achievement("secret", "The Last Door", "Open it.", hidden = true, unlocked = false, unlockedAt = 0, icon = null, iconLocked = null),
|
||||
)
|
||||
|
||||
@Composable
|
||||
private fun PreviewSurface(content: @Composable () -> Unit) {
|
||||
DroidDeckTheme(theme = Themes.GRAPHITE) {
|
||||
Box(Modifier.fillMaxSize().background(LocalPalette.current.background).padding(16.dp)) { content() }
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(name = "Store page section", widthDp = 800, heightDp = 600)
|
||||
@Composable
|
||||
private fun StoreAchievementsSectionPreview() = PreviewSurface {
|
||||
Column(Modifier.width(560.dp)) { StoreAchievementsSectionContent("GOG", AchievementsState(previewList, null, false)) }
|
||||
}
|
||||
|
||||
@Preview(name = "Store page section, signed out", widthDp = 800, heightDp = 200)
|
||||
@Composable
|
||||
private fun StoreAchievementsSectionSignedOutPreview() = PreviewSurface {
|
||||
Column(Modifier.width(560.dp)) { StoreAchievementsSectionContent("Epic", AchievementsState(null, Reason.SIGNED_OUT, false)) }
|
||||
}
|
||||
|
||||
@Preview(name = "Session panel", widthDp = 800, heightDp = 500)
|
||||
@Composable
|
||||
private fun SessionAchievementsPanelPreview() = DroidDeckTheme(theme = Themes.GRAPHITE) {
|
||||
SessionAchievementsPanel("Epic", AchievementsState(previewList, null, false), "Hollow Valley", onClose = {})
|
||||
}
|
||||
|
||||
@Preview(name = "Session panel, 4:3", widthDp = 560, heightDp = 420)
|
||||
@Composable
|
||||
private fun SessionAchievementsPanelShortPreview() = DroidDeckTheme(theme = Themes.GRAPHITE) {
|
||||
SessionAchievementsPanel("GOG", AchievementsState(previewList.map {
|
||||
Achievement(it.id, it.name, it.description, it.hidden, true, 1_760_000_000, null, null)
|
||||
}, null, false), "Hollow Valley", onClose = {})
|
||||
}
|
||||
|
||||
@Preview(name = "Session panel, offline", widthDp = 800, heightDp = 500)
|
||||
@Composable
|
||||
private fun SessionAchievementsPanelOfflinePreview() = DroidDeckTheme(theme = Themes.GRAPHITE) {
|
||||
SessionAchievementsPanel("GOG", AchievementsState(null, Reason.UNREACHABLE, false), "Hollow Valley", onClose = {})
|
||||
}
|
||||
|
||||
@Preview(name = "Drawer row", widthDp = 360, heightDp = 160)
|
||||
@Composable
|
||||
private fun DrawerAchievementsRowPreview() = PreviewSurface {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
DrawerAchievementsRow(2 to 4) {}
|
||||
DrawerAchievementsRow(4 to 4) {}
|
||||
DrawerAchievementsRow(null) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(name = "Rows", widthDp = 480, heightDp = 300)
|
||||
@Composable
|
||||
private fun AchievementRowPreview() = PreviewSurface {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
AchievementsProgress(AchievementsState(previewList, null, false))
|
||||
for (a in previewList) AchievementRow(a, compact = false)
|
||||
AchievementRow(previewList[0], compact = true)
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ import coil.compose.AsyncImage
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.stores.CatalogItem
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoreAchievements
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import com.droiddeck.launcher.stores.download.DownloadState
|
||||
import com.droiddeck.launcher.stores.formatBytes
|
||||
@@ -128,6 +129,15 @@ internal fun StoreGameDetail(store: Store, key: String, s: FrontEndState, a: Fro
|
||||
if (description.isNotBlank()) Rise(2) {
|
||||
Text(description, fontSize = 13.sp, lineHeight = 19.sp, color = colors.onSurfaceVariant, maxLines = 6, overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(top = 12.dp))
|
||||
}
|
||||
val achievements = remember(store, id, item?.owned, installed) {
|
||||
when {
|
||||
StoreAchievements.forSource(store.id) == null -> null
|
||||
item?.owned == true -> StoreAchievements.Game.of(item)
|
||||
installed != null -> StoreAchievements.Game.of(installed.sidecar)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
if (achievements != null) Rise(3) { StoreAchievementsSection(achievements) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user