Skip to content

Commit e88e370

Browse files
committed
цвет Badge теперь по редкости карты берется
1 parent 157769d commit e88e370

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

BlackMagic/Extensions/UIColor/UIColor+normalRGBInit.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,26 @@ extension UIColor {
1717
alpha: 1.0
1818
)
1919
}
20+
21+
/// Возвращает цвет для бейджа в зависимости от редкости карты Scryfall
22+
/// - Parameter rarity: строка редкости (например, "common", "uncommon", "rare", "mythic")
23+
/// - Returns: UIColor для бейджа
24+
static func badgeColor(forRarity rarity: String?) -> UIColor {
25+
guard let rarity = rarity?.lowercased() else {
26+
// Серый по умолчанию
27+
return UIColor(red: 180, green: 180, blue: 180)
28+
}
29+
switch rarity {
30+
case "common":
31+
return UIColor(red: 160, green: 160, blue: 160) // Серый
32+
case "uncommon":
33+
return UIColor(red: 85, green: 180, blue: 120) // Зеленый
34+
case "rare":
35+
return UIColor(red: 255, green: 215, blue: 0) // Золотой
36+
case "mythic":
37+
return UIColor(red: 255, green: 85, blue: 0) // Оранжево-красный
38+
default:
39+
return UIColor(red: 120, green: 120, blue: 120) // Серый для неизвестных
40+
}
41+
}
2042
}

BlackMagic/Views/CardCell.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ final class CardCell: UICollectionViewCell {
6666
}
6767
badgeView.isHidden = !showBadge || badgeCount == 0
6868
badgeLabel.text = "\(badgeCount)"
69+
// Устанавливаем цвет бейджа по редкости карты
70+
badgeView.backgroundColor = UIColor.badgeColor(forRarity: card.rarity)
6971
updateSellTitle()
7072
}
7173

0 commit comments

Comments
 (0)