|
@@ -1,188 +0,0 @@
|
|
|
-//
|
|
|
-// TSDiscoverStyleMoreCell.swift
|
|
|
-// AIEmoji
|
|
|
-//
|
|
|
-// Created by 100Years on 2025/6/23.
|
|
|
-//
|
|
|
-private let identifier = "TSDiscoverStyleMoreCellCell"
|
|
|
-class TSDiscoverStyleMoreCell : TSDiscoverBaseCell {
|
|
|
-
|
|
|
- lazy var collectionView: UICollectionView = {
|
|
|
- let layout = UICollectionViewFlowLayout()
|
|
|
- layout.scrollDirection = .horizontal
|
|
|
- layout.minimumLineSpacing = 16
|
|
|
- layout.minimumInteritemSpacing = 16
|
|
|
- layout.itemSize = CGSize(width: 150, height: 200)
|
|
|
- let collectionView = TSBaseCollectionView(frame: .zero, collectionViewLayout: layout)
|
|
|
- collectionView.delegate = self
|
|
|
- collectionView.dataSource = self
|
|
|
- collectionView.register(TSDiscoverStyleMoreCellCell.self, forCellWithReuseIdentifier: identifier)
|
|
|
- collectionView.register(TSDiscoverStyleMoreAnimationCellCell.self, forCellWithReuseIdentifier: "TSDiscoverStyleMoreAnimationCellCell")
|
|
|
- collectionView.contentInset = kDiscoverSection
|
|
|
- return collectionView
|
|
|
- }()
|
|
|
- var models:[TSDiscoverItemModel] = []
|
|
|
- override func upDateModel() {
|
|
|
- if let models = items as? [TSDiscoverItemModel] {
|
|
|
- self.models = models
|
|
|
- }
|
|
|
- collectionView.reloadData()
|
|
|
- }
|
|
|
-
|
|
|
- override func creatUI() {
|
|
|
- bgContentView.addSubview(collectionView)
|
|
|
- collectionView.snp.makeConstraints { make in
|
|
|
- make.edges.equalToSuperview()
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-extension TSDiscoverStyleMoreCell: UICollectionViewDataSource ,UICollectionViewDelegate {
|
|
|
- public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
|
|
- return models.count
|
|
|
- }
|
|
|
-
|
|
|
- public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
-
|
|
|
- if let dbModel = models.safeObj(At: indexPath.row) {
|
|
|
- if dbModel.viewModel is TSDiscoverAnimationItemVM {
|
|
|
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TSDiscoverStyleMoreAnimationCellCell", for: indexPath) as? TSDiscoverStyleMoreAnimationCellCell{
|
|
|
- cell.model = dbModel
|
|
|
- return cell
|
|
|
- }
|
|
|
-
|
|
|
- }else{
|
|
|
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as? TSDiscoverStyleMoreCellCell{
|
|
|
- cell.model = dbModel
|
|
|
- return cell
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return UICollectionViewCell()
|
|
|
- }
|
|
|
-
|
|
|
- public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
- if let model = models.safeObj(At: indexPath.row) {
|
|
|
- clickBlock?(model)
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-class TSDiscoverStyleMoreCellCell: TSBaseCollectionCell {
|
|
|
- var model:TSDiscoverItemModel? {
|
|
|
- didSet {
|
|
|
- guard let model = model else { return }
|
|
|
- imageView.image = UIImage(named: model.viewModel.imageNamed)
|
|
|
- textLabel.text = model.name
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- lazy var imageView: UIImageView = {
|
|
|
- let imageView = UIImageView.createImageView(contentMode: .scaleToFill,backgroundColor: .white.withAlphaComponent(0.2))
|
|
|
- return imageView
|
|
|
- }()
|
|
|
-
|
|
|
-
|
|
|
- lazy var shadowView: UIImageView = {
|
|
|
- let imageView = UIImageView.createImageView(image:.discoverSmallShaow,contentMode: .scaleToFill)
|
|
|
- return imageView
|
|
|
- }()
|
|
|
-
|
|
|
- lazy var textLabel: UILabel = {
|
|
|
- let textLabel = UILabel.createLabel(font: .font(size: 11,weight: .medium),textColor: .white)
|
|
|
- return textLabel
|
|
|
- }()
|
|
|
-
|
|
|
- override func creatUI() {
|
|
|
-
|
|
|
- bgContentView.addSubview(imageView)
|
|
|
- bgContentView.addSubview(shadowView)
|
|
|
- bgContentView.addSubview(textLabel)
|
|
|
-
|
|
|
- imageView.snp.makeConstraints { make in
|
|
|
- make.edges.equalToSuperview()
|
|
|
- }
|
|
|
- shadowView.snp.makeConstraints { make in
|
|
|
- make.height.equalTo(40)
|
|
|
- make.leading.trailing.bottom.equalToSuperview()
|
|
|
- }
|
|
|
-
|
|
|
- textLabel.snp.makeConstraints { make in
|
|
|
- make.leading.equalTo(8)
|
|
|
- make.trailing.bottom.equalTo(-8)
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- kMainAsync {
|
|
|
- self.shadowView.addGradientBg(
|
|
|
- colors: [UIColor.black.withAlphaComponent(0.0).cgColor,UIColor.black.withAlphaComponent(0.6).cgColor],
|
|
|
- startPoint: CGPointMake(0.5, 0),
|
|
|
- endPoint: CGPointMake(0.5, 1.0)
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-class TSDiscoverStyleMoreAnimationCellCell: TSBaseCollectionCell {
|
|
|
- var model:TSDiscoverItemModel? {
|
|
|
- didSet {
|
|
|
- guard let model = model else { return }
|
|
|
- textLabel.text = model.name
|
|
|
-
|
|
|
- if let animationModel = model.viewModel as? TSDiscoverAnimationItemVM {
|
|
|
- var images = [UIImage]()
|
|
|
- for imageNamed in animationModel.imageNameds {
|
|
|
- if let image = UIImage(named: imageNamed) {
|
|
|
- images.append(image)
|
|
|
- }
|
|
|
- }
|
|
|
- comparisonView.images = images
|
|
|
-
|
|
|
-// comparisonView.startAnimation(direction: .rightToLeft)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- lazy var comparisonView: TSImagesComparisonView = {
|
|
|
- let comparisonView = TSImagesComparisonView(frame: CGRect(x: 0, y: 300, width: 300, height: 400))
|
|
|
- comparisonView.isRunloop = true
|
|
|
- return comparisonView
|
|
|
- }()
|
|
|
-
|
|
|
-
|
|
|
- lazy var shadowView: UIView = {
|
|
|
- let shadowView = UIView()
|
|
|
- shadowView.alpha = 0.7
|
|
|
- return shadowView
|
|
|
- }()
|
|
|
-
|
|
|
- lazy var textLabel: UILabel = {
|
|
|
- let textLabel = UILabel.createLabel(font: .font(size: 11,weight: .medium),textColor: .white)
|
|
|
- return textLabel
|
|
|
- }()
|
|
|
-
|
|
|
- override func creatUI() {
|
|
|
-
|
|
|
- bgContentView.addSubview(comparisonView)
|
|
|
- bgContentView.addSubview(shadowView)
|
|
|
- bgContentView.addSubview(textLabel)
|
|
|
-
|
|
|
- comparisonView.snp.makeConstraints { make in
|
|
|
- make.edges.equalToSuperview()
|
|
|
- }
|
|
|
- shadowView.snp.makeConstraints { make in
|
|
|
- make.height.equalTo(40)
|
|
|
- make.leading.trailing.bottom.equalToSuperview()
|
|
|
- }
|
|
|
-
|
|
|
- textLabel.snp.makeConstraints { make in
|
|
|
- make.leading.equalTo(8)
|
|
|
- make.trailing.bottom.equalTo(-8)
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- kMainAsync {
|
|
|
- self.comparisonView.startAnimation(direction: .rightToLeft)
|
|
|
- }
|
|
|
- }
|
|
|
-}
|