Skip to content

Commit

Permalink
[Feat] #434 - 카테고리 태그 UI 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
dlwogus0128 committed Nov 19, 2024
1 parent c13d105 commit 8349704
Showing 1 changed file with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// HomeCategoryTagView.swift
// HomeFeature
//
// Created by Jae Hyun Lee on 11/20/24.
// Copyright © 2024 SOPT-iOS. All rights reserved.
//

import UIKit

import Core
import DSKit

final public class HomeCategoryTagView: UIView {

// MARK: - UI Components

private let titleLabel = UILabel().then {
$0.font = DSKitFontFamily.SuitV1.extraBold.font(size: 12)
$0.textColor = DSKitAsset.Colors.secondary.color
$0.textAlignment = .center
}

private let contentStackView = UIStackView().then {
$0.axis = .horizontal
}

private let hotIconImageView = UIImageView().then {
$0.image = DSKitAsset.Assets.icHot.image
}

// MARK: - Initialization

public override init(frame: CGRect) {
super.init(frame: frame)
setStackView()
setLayout()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

// MARK: - UI & Layout

extension HomeCategoryTagView {
private func setStackView() {
self.contentStackView.addArrangedSubviews(
titleLabel
)
}

private func setLayout() {
self.addSubview(self.contentStackView)

contentStackView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}

hotIconImageView.snp.makeConstraints { make in
make.size.equalTo(12)
}
}
}

// MARK: - Methods

extension HomeCategoryTagView {
func setData(with text: String, isHotTag: Bool) {
self.titleLabel.text = text
if isHotTag {
self.contentStackView.insertArrangedSubview(hotIconImageView, at: 0)
}
layoutIfNeeded()
}
}

0 comments on commit 8349704

Please sign in to comment.