Skip to content

Commit

Permalink
[Feat/#81] HomeViewCell - 분기 처리 영상 및 라이팅 업데이트 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
boyeon0119 committed Jan 14, 2024
1 parent 04d8f6f commit 3d6b0fe
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@
//

import UIKit
import AVFoundation

import SnapKit
import Then


final class BlackHoleImageCell: UICollectionViewCell {

static let identifier = "BlackHoleImageCell"

private let blackHoleImageView = UIImageView().then {
$0.alpha = 0.1
}
private var videoHandler = VideoHandler()
private let blackHoleImageView = UIImageView()
private lazy var blackHoleVideoView = VideoView(videoHandler: videoHandler)

private let homeBlackHoleStateLabel = UILabel().then {
$0.font = .iosTitle3Semibold22
$0.textColor = .whiteText
Expand All @@ -38,7 +41,7 @@ final class BlackHoleImageCell: UICollectionViewCell {
}

private func setHierarchy() {
self.addSubviews(blackHoleImageView, homeBlackHoleStateLabel)
self.addSubviews(blackHoleImageView, blackHoleVideoView, homeBlackHoleStateLabel)
}

private func setConstraints() {
Expand All @@ -47,16 +50,39 @@ final class BlackHoleImageCell: UICollectionViewCell {
$0.height.equalTo(blackHoleImageView.snp.width)
}

blackHoleVideoView.snp.makeConstraints {
$0.top.horizontalEdges.equalToSuperview()
$0.height.equalTo(blackHoleImageView.snp.width)
}

homeBlackHoleStateLabel.snp.makeConstraints {
$0.top.equalToSuperview().inset(23.adjusted)
$0.leading.equalToSuperview().inset(21.adjusted)
}
}

func configureCell (image: UIImage, text: String){
blackHoleImageView.image = image
func configureCell (image: UIImage? = nil,
videoUrl: URL?,
text: String){
homeBlackHoleStateLabel.text = text
homeBlackHoleStateLabel.setTextWithLineHeight(text: text, lineHeight: 33.adjusted)
homeBlackHoleStateLabel.textAlignment = .left

DispatchQueue.main.async {
if let image {
self.blackHoleImageView.isHidden = false
self.blackHoleVideoView.isHidden = true
self.blackHoleImageView.image = image
} else {
self.blackHoleVideoView.isHidden = false
self.blackHoleImageView.isHidden = true
}
if let videoUrl {
self.blackHoleVideoView.isHidden = false
self.videoHandler.bindVideoItem(videoURL: videoUrl)
} else {
self.blackHoleVideoView.isHidden = true
}
}
}
}

0 comments on commit 3d6b0fe

Please sign in to comment.