fix: progression screen theme colors and XP bar styling

This commit is contained in:
cmclark00 2025-03-29 01:58:53 -04:00
parent 1980f15a46
commit 42b9bcfab4
3 changed files with 30 additions and 28 deletions

View file

@ -31,6 +31,9 @@ class ProgressionScreen @JvmOverloads constructor(
private val rewardsContainer: LinearLayout private val rewardsContainer: LinearLayout
private val continueButton: TextView private val continueButton: TextView
// Current theme
private var currentTheme: String = PlayerProgressionManager.THEME_CLASSIC
// Callback for when the player dismisses the screen // Callback for when the player dismisses the screen
var onContinue: (() -> Unit)? = null var onContinue: (() -> Unit)? = null
@ -62,6 +65,9 @@ class ProgressionScreen @JvmOverloads constructor(
newRewards: List<String>, newRewards: List<String>,
themeId: String = PlayerProgressionManager.THEME_CLASSIC themeId: String = PlayerProgressionManager.THEME_CLASSIC
) { ) {
// Update current theme
currentTheme = themeId
// Hide rewards container initially if there are no new rewards // Hide rewards container initially if there are no new rewards
rewardsContainer.visibility = if (newRewards.isEmpty()) View.GONE else View.INVISIBLE rewardsContainer.visibility = if (newRewards.isEmpty()) View.GONE else View.INVISIBLE
@ -74,6 +80,10 @@ class ProgressionScreen @JvmOverloads constructor(
playerLevelText.text = "Player Level: $playerLevel" playerLevelText.text = "Player Level: $playerLevel"
xpGainText.text = "+$xpGained XP" xpGainText.text = "+$xpGained XP"
// Update level up text visibility
val progressionTitle = findViewById<TextView>(R.id.progression_title)
progressionTitle.visibility = if (newRewards.any { it.contains("Level") }) View.VISIBLE else View.GONE
// Start with initial animations // Start with initial animations
AnimatorSet().apply { AnimatorSet().apply {
// Fade in the XP gain text // Fade in the XP gain text
@ -146,8 +156,17 @@ class ProgressionScreen @JvmOverloads constructor(
cardElevation = 4f cardElevation = 4f
useCompatPadding = true useCompatPadding = true
// Default background color - will be adjusted based on theme // Set background color based on current theme
setCardBackgroundColor(Color.BLACK) val backgroundColor = when (currentTheme) {
PlayerProgressionManager.THEME_CLASSIC -> Color.BLACK
PlayerProgressionManager.THEME_NEON -> Color.parseColor("#0D0221")
PlayerProgressionManager.THEME_MONOCHROME -> Color.parseColor("#1A1A1A")
PlayerProgressionManager.THEME_RETRO -> Color.parseColor("#3F2832")
PlayerProgressionManager.THEME_MINIMALIST -> Color.WHITE
PlayerProgressionManager.THEME_GALAXY -> Color.parseColor("#0B0C10")
else -> Color.BLACK
}
setCardBackgroundColor(backgroundColor)
layoutParams = LinearLayout.LayoutParams( layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT,
@ -176,6 +195,8 @@ class ProgressionScreen @JvmOverloads constructor(
* Apply the current theme to the progression screen * Apply the current theme to the progression screen
*/ */
fun applyTheme(themeId: String) { fun applyTheme(themeId: String) {
currentTheme = themeId
// Get reference to the title text // Get reference to the title text
val progressionTitle = findViewById<TextView>(R.id.progression_title) val progressionTitle = findViewById<TextView>(R.id.progression_title)
val rewardsTitle = findViewById<TextView>(R.id.rewards_title) val rewardsTitle = findViewById<TextView>(R.id.rewards_title)
@ -257,10 +278,10 @@ class ProgressionScreen @JvmOverloads constructor(
} }
} }
// Set theme color on XP progress bar // Update XP progress bar theme color
xpProgressBar.setThemeColor(xpThemeColor) xpProgressBar.setThemeColor(xpThemeColor)
// Update card colors for any existing reward cards // Update reward card colors
updateRewardCardColors(themeId) updateRewardCardColors(themeId)
} }
@ -268,8 +289,7 @@ class ProgressionScreen @JvmOverloads constructor(
* Update colors of existing reward cards to match the theme * Update colors of existing reward cards to match the theme
*/ */
private fun updateRewardCardColors(themeId: String) { private fun updateRewardCardColors(themeId: String) {
// Color for card backgrounds based on theme val backgroundColor = when (themeId) {
val cardBackgroundColor = when (themeId) {
PlayerProgressionManager.THEME_CLASSIC -> Color.BLACK PlayerProgressionManager.THEME_CLASSIC -> Color.BLACK
PlayerProgressionManager.THEME_NEON -> Color.parseColor("#0D0221") PlayerProgressionManager.THEME_NEON -> Color.parseColor("#0D0221")
PlayerProgressionManager.THEME_MONOCHROME -> Color.parseColor("#1A1A1A") PlayerProgressionManager.THEME_MONOCHROME -> Color.parseColor("#1A1A1A")
@ -279,28 +299,9 @@ class ProgressionScreen @JvmOverloads constructor(
else -> Color.BLACK else -> Color.BLACK
} }
// Text color for rewards based on theme
val rewardTextColor = when (themeId) {
PlayerProgressionManager.THEME_CLASSIC -> Color.WHITE
PlayerProgressionManager.THEME_NEON -> Color.parseColor("#FF00FF")
PlayerProgressionManager.THEME_MONOCHROME -> Color.LTGRAY
PlayerProgressionManager.THEME_RETRO -> Color.parseColor("#FF5A5F")
PlayerProgressionManager.THEME_MINIMALIST -> Color.BLACK
PlayerProgressionManager.THEME_GALAXY -> Color.parseColor("#66FCF1")
else -> Color.WHITE
}
// Update each card in the rewards container
for (i in 0 until rewardsContainer.childCount) { for (i in 0 until rewardsContainer.childCount) {
val card = rewardsContainer.getChildAt(i) as? CardView val card = rewardsContainer.getChildAt(i) as? CardView
card?.let { card?.setCardBackgroundColor(backgroundColor)
it.setCardBackgroundColor(cardBackgroundColor)
// Update text color in the card
if (it.childCount > 0 && it.getChildAt(0) is TextView) {
(it.getChildAt(0) as TextView).setTextColor(rewardTextColor)
}
}
} }
} }
} }

View file

@ -99,6 +99,8 @@ class XPProgressBar @JvmOverloads constructor(
*/ */
fun setThemeColor(color: Int) { fun setThemeColor(color: Int) {
themeColor = color themeColor = color
progressPaint.color = color
textPaint.color = color
levelBadgePaint.color = color levelBadgePaint.color = color
invalidate() invalidate()
} }

View file

@ -3,8 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:padding="16dp" android:padding="16dp">
android:background="@color/black">
<TextView <TextView
android:id="@+id/progression_title" android:id="@+id/progression_title"