90 lines
2.1 KiB
Swift
90 lines
2.1 KiB
Swift
//
|
|
// AddImageCell.swift
|
|
// SHECommunity
|
|
//
|
|
// Created by Lin on 2024/12/23.
|
|
//
|
|
|
|
import UIKit
|
|
import RxSwift
|
|
import RxDataSources
|
|
|
|
enum ImageUploadItem {
|
|
case image(image: UIImage?=nil, imageUrl: String?=nil)
|
|
case add
|
|
}
|
|
|
|
typealias ImageUploadSectionModel = SectionModel<String, ImageUploadItem>
|
|
|
|
class AddImageCell: UICollectionViewCell {
|
|
|
|
var disposeBag = DisposeBag()
|
|
|
|
private func setupSubViews() {
|
|
addSubview(bgView)
|
|
addSubview(iconView)
|
|
addSubview(titleLab)
|
|
addSubview(addBtn)
|
|
setupLayout()
|
|
}
|
|
|
|
private func setupLayout() {
|
|
bgView.layoutChain.edges()
|
|
|
|
iconView.layoutChain
|
|
.centerX()
|
|
.bottomToCenterYOfView(self, offset: -5)
|
|
.width(30)
|
|
.heightToWidth(1.0)
|
|
|
|
titleLab.layoutChain
|
|
.topToBottomOfView(iconView, offset: 5)
|
|
.edgesHorzontal()
|
|
|
|
addBtn.layoutChain.edges()
|
|
}
|
|
|
|
lazy var bgView: UIView = {
|
|
let view = UIView()
|
|
view.cornerRadius = 8
|
|
view.borderWidth = 0.5
|
|
view.borderColor = UIColor(hexStr: "E6E6E6")//ThemeManager.shared.color.lineColor
|
|
return view
|
|
}()
|
|
|
|
lazy var iconView: UIImageView = {
|
|
let icon = UIImageView()
|
|
icon.image = UIImage(named: "Common/add_photo")
|
|
return icon
|
|
}()
|
|
|
|
lazy var titleLab: UILabel = {
|
|
let label = UILabel()
|
|
label.text = "添加图片"
|
|
label.textColor = ThemeManager.shared.color.titleColor
|
|
label.font = .systemFont(ofSize: 12, weight: .regular)
|
|
label.textAlignment = .center
|
|
return label
|
|
}()
|
|
|
|
lazy var addBtn: UIButton = {
|
|
let button = UIButton (type: .custom)
|
|
return button
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
contentView.backgroundColor = .clear
|
|
setupSubViews()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
override func prepareForReuse() {
|
|
super.prepareForReuse()
|
|
disposeBag = DisposeBag()
|
|
}
|
|
}
|