-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
achievements: Optimize achievements detail pane UI
- Loading branch information
Showing
5 changed files
with
132 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...mmonMain/kotlin/dev/omico/wwm/feature/achievements/component/AchievementsDetailContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2024 Omico. All Rights Reserved. | ||
*/ | ||
package dev.omico.wwm.feature.achievements.component | ||
|
||
import androidx.compose.foundation.ExperimentalFoundationApi | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.derivedStateOf | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import dev.omico.wwm.feature.achievements.AchievementsUiState | ||
import dev.omico.wwm.resources.model.game.WwAchievement | ||
import dev.omico.wwm.resources.model.game.WwAchievementGroup | ||
import dev.omico.wwm.resources.rememberWwText | ||
|
||
@OptIn(ExperimentalFoundationApi::class) | ||
@Composable | ||
internal fun AchievementsDetailContent( | ||
state: AchievementsUiState, | ||
achievementGroup: WwAchievementGroup, | ||
contentPadding: PaddingValues, | ||
) { | ||
val achievements by remember(achievementGroup.id) { | ||
derivedStateOf { | ||
state.achievements.achievements.filter { achievement -> achievement.groupId == achievementGroup.id } | ||
} | ||
} | ||
LazyColumn( | ||
contentPadding = contentPadding, | ||
content = { | ||
items( | ||
items = achievements, | ||
key = WwAchievement::id, | ||
itemContent = { achievement -> | ||
AchievementsDetailItem( | ||
marked = false, | ||
onMarkedChange = {}, | ||
name = rememberWwText( | ||
multiText = state.achievements.multiText, | ||
name = achievement.name, | ||
), | ||
description = rememberWwText( | ||
multiText = state.achievements.multiText, | ||
name = achievement.desc, | ||
), | ||
modifier = Modifier.animateItemPlacement(), | ||
) | ||
}, | ||
) | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...onMain/kotlin/dev/omico/wwm/feature/achievements/component/AchievementsDetailTopAppBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2024 Omico. All Rights Reserved. | ||
*/ | ||
package dev.omico.wwm.feature.achievements.component | ||
|
||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.rounded.ArrowBack | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBar | ||
import androidx.compose.material3.adaptive.navigationsuite.ExperimentalMaterial3AdaptiveNavigationSuiteApi | ||
import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteType | ||
import androidx.compose.runtime.Composable | ||
import dev.omico.wwm.feature.achievements.AchievementsUiState | ||
import dev.omico.wwm.resources.model.game.WwAchievementGroup | ||
import dev.omico.wwm.resources.rememberWwText | ||
import dev.omico.wwm.ui.LocalNavigationSuiteType | ||
|
||
@OptIn( | ||
ExperimentalMaterial3AdaptiveNavigationSuiteApi::class, | ||
ExperimentalMaterial3Api::class, | ||
) | ||
@Composable | ||
internal fun AchievementsDetailTopAppBar( | ||
state: AchievementsUiState, | ||
achievementGroup: WwAchievementGroup, | ||
onNavigateBack: () -> Unit, | ||
) { | ||
TopAppBar( | ||
title = { | ||
Text( | ||
text = rememberWwText( | ||
multiText = state.achievements.multiText, | ||
name = achievementGroup.name, | ||
), | ||
) | ||
}, | ||
navigationIcon = { | ||
if (LocalNavigationSuiteType.current == NavigationSuiteType.NavigationBar) { | ||
IconButton( | ||
onClick = onNavigateBack, | ||
content = { | ||
Icon( | ||
imageVector = Icons.AutoMirrored.Rounded.ArrowBack, | ||
contentDescription = "Back", | ||
) | ||
}, | ||
) | ||
} | ||
}, | ||
) | ||
} |