jsdw_ios/QuickLocation/Section/Home/InteractionEmojiCell.swift

77 lines
3.0 KiB
Swift

//
// InteractionEmojiCell.swift
// QuickLocation
//
import UIKit
final class InteractionEmojiCell: UICollectionViewCell {
static let normalPngMap: [String: String] = [
"normal_1": "cold-face-emoji-103", "normal_10": "nervous-face-emoji-121",
"normal_11": "phone-call-141", "normal_12": "question-face-emoji-167",
"normal_13": "chill-face-emoji-073", "normal_14": "driving-face-emoji-085",
"normal_15": "heart-eyes-107", "normal_16": "house-face-emoji-169",
"normal_17": "lifiting-face-emoji-111","normal_18": "like-face-emoji-077",
"normal_19": "looking-face-emoji-137","normal_2": "crying-face-emoji-121",
"normal_20": "no-face-emoji-133", "normal_21": "party-face-emoji-078",
"normal_22": "plane-face-emoji-124", "normal_23": "rose-face-emoji-114",
"normal_24": "sleep-face-emoji-091", "normal_3": "dizzy-face-emoji-118",
"normal_4": "broken-face-emoji-142", "normal_5": "angry-face-emoji-027",
"normal_6": "eating-popcorn-073", "normal_7": "face-using-laptop-009",
"normal_8": "hi-face-emoji-129", "normal_9": "laughing-face-emoji-136",
]
static let funPngMap: [String: String] = [
"fun_1": "1-001",
"fun_10": "10-020", "fun_11": "11-043", "fun_13": "13-005", "fun_14": "14-145",
"fun_15": "15-073", "fun_16": "16-031", "fun_17": "17-034", "fun_18": "18-092",
"fun_19": "19-124", "fun_2": "2-002", "fun_3": "3-029", "fun_4": "4-005",
"fun_5": "5-046", "fun_6": "6-021", "fun_7": "7-030", "fun_8": "8-033",
"fun_9": "9-166",
]
static let normalFileNames: [String] = normalPngMap.keys.sorted()
static let funFileNames: [String] = funPngMap.keys.sorted()
private let imageView: UIImageView = {
let v = UIImageView()
v.contentMode = .scaleAspectFit
return v
}()
let lockView: UIImageView = {
let iv = UIImageView(image: UIImage(named: "Home/emoji_lock"))
iv.isHidden = true
return iv
}()
override init(frame: CGRect) {
super.init(frame: frame)
contentView.addSubview(imageView)
contentView.addSubview(lockView)
imageView.layoutChain.edges()
lockView.layoutChain
.bottom(1)
.right(1)
.width(16)
.height(16)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func configure(name: String) {
let isNormal = name.hasPrefix("normal_")
let map = isNormal ? Self.normalPngMap : Self.funPngMap
if let pngName = map[name],
let path = Bundle.main.path(forResource: "\(pngName)", ofType: "png") {
imageView.image = UIImage(contentsOfFile: path)
}
guard AppContextManager.shared.systemConfig?.isIntercept == false else { return }
lockView.isHidden = name.hasPrefix("normal_") || AppContextManager.shared.vip > 1
}
}