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

58 lines
1.6 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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")
}
}