Visual_Novel_iOS/crush/Crush/Src/Modules/Chat/ContentView/IMContentBaseView.swift

58 lines
1.6 KiB
Swift
Raw Normal View History

2025-10-09 10:29:35 +00:00
//
// IMContentBaseView.swift
// Crush
//
// Created by Leon on 2025/8/18.
//
import UIKit
protocol IMContentViewDelegate: NSObjectProtocol{
func onTapAction(event: IMEventModel)
}
class IMContentBaseView: UIView{
var model: SessionBaseModel!
var containerView: UIView = UIView()
weak var delegate: IMContentViewDelegate?
///
public func refreshModel(model: SessionBaseModel) {
self.model = model
//
let insets = model.config.contentInsets(model: model)
self.containerView.snp.makeConstraints { make in
make.leading.equalToSuperview().offset(insets.left)
make.trailing.equalToSuperview().offset(-insets.right)
make.top.equalToSuperview().offset(insets.top)
make.bottom.equalToSuperview().offset(-insets.bottom)
}
self.layoutIfNeeded()
}
override init(frame: CGRect) {
super.init(frame: frame)
self.addSubview(self.containerView)
// self.containerView.layer.cornerRadius = 16 // cellmaskLayer
//
self.containerView.snp.makeConstraints { make in
make.center.equalTo(self)
}
let tap = UITapGestureRecognizer.init(target: self, action: #selector(cellTapAction))
tap.cancelsTouchesInView = false
self.addGestureRecognizer(tap)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc func cellTapAction() {
// dlog("IMContentBaseView cellTapAction")
}
}