mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-21 13:53:37 +00:00
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
36 lines
1.2 KiB
Swift
36 lines
1.2 KiB
Swift
import UIKit
|
|
|
|
class BottomMenuItemCell: UITableViewCell {
|
|
@IBOutlet private var label: UILabel!
|
|
@IBOutlet private var badgeBackground: UIView!
|
|
@IBOutlet private var badgeCountLabel: UILabel!
|
|
@IBOutlet private var separator: UIView!
|
|
@IBOutlet private var icon: UIImageView!
|
|
@IBOutlet private var badgeSpacingConstraint: NSLayoutConstraint!
|
|
@IBOutlet private var badgeBackgroundWidthConstraint: NSLayoutConstraint!
|
|
var anchorView: UIView {
|
|
get {
|
|
return icon
|
|
}
|
|
}
|
|
|
|
private(set) var isEnabled: Bool = true
|
|
|
|
func configure(imageName: String, title: String, badgeCount: UInt = .zero, enabled: Bool = true) {
|
|
icon.image = UIImage(named: imageName)
|
|
label.text = title
|
|
badgeBackground.isHidden = badgeCount == 0
|
|
badgeCountLabel.text = "\(badgeCount)"
|
|
if badgeCount == 0 {
|
|
badgeSpacingConstraint.constant = 0
|
|
badgeBackgroundWidthConstraint.constant = 0
|
|
} else {
|
|
badgeSpacingConstraint.constant = 8
|
|
badgeBackgroundWidthConstraint.constant = 32
|
|
}
|
|
isEnabled = enabled
|
|
icon.setStyleAndApply(isEnabled ? .black : .gray)
|
|
label.setFontStyleAndApply(isEnabled ? .blackPrimary : .blackHint)
|
|
}
|
|
}
|